From 4b012fdf446152c61da857bab7b0fc124939b040 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 9 Jan 2021 10:19:47 -0800 Subject: [PATCH] Chop apart index to try to make more stable. --- ueforth/arduino/arduino_server.fs | 24 +++++++++++++++++++++--- ueforth/common/boot.fs | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ueforth/arduino/arduino_server.fs b/ueforth/arduino/arduino_server.fs index 1b2ebc3..5b66ae4 100644 --- a/ueforth/arduino/arduino_server.fs +++ b/ueforth/arduino/arduino_server.fs @@ -37,7 +37,11 @@ Upload File:


- + +| s>z constant index-html + +r| var prompt = document.getElementById('prompt'); var filepick = document.getElementById('filepick'); var output = document.getElementById('output'); @@ -67,6 +71,9 @@ function ask(cmd, callback) { if (callback !== undefined) { callback(); } }); } +| s>z constant terminal1-js + +r| prompt.onkeyup = function(event) { if (event.keyCode === 13) { event.preventDefault(); @@ -93,7 +100,7 @@ window.onload = function() { prompt.focus(); }; -| s>z constant index-html +| s>z constant terminal2-js variable webserver 20000 constant out-size @@ -106,6 +113,16 @@ create out-string out-size 1+ allot align 200 z" text/html" index-html webserver @ WebServer.send ; +: handle-terminal1 + terminal1-js z>s nip webserver @ WebServer.setContentLength + 200 z" text/html" terminal1-js webserver @ WebServer.send +; + +: handle-terminal2 + terminal2-js z>s nip webserver @ WebServer.setContentLength + 200 z" text/html" terminal2-js webserver @ WebServer.send +; + : handle-input z" cmd" webserver @ WebServer.hasArg if z" cmd" webserver @ WebServer.arg input-stream >stream pause @@ -122,8 +139,9 @@ create out-string out-size 1+ allot align : do-serve 80 WebServer.new webserver ! - z" /webui" ['] handle-index webserver @ WebServer.on z" /" ['] handle-index webserver @ WebServer.on + z" /terminal1.js" ['] handle-terminal1 webserver @ WebServer.on + z" /terminal2.js" ['] handle-terminal2 webserver @ WebServer.on z" /input" ['] handle-input webserver @ WebServer.on webserver @ WebServer.begin begin diff --git a/ueforth/common/boot.fs b/ueforth/common/boot.fs index 2ab194b..6f9a919 100644 --- a/ueforth/common/boot.fs +++ b/ueforth/common/boot.fs @@ -146,7 +146,7 @@ variable hld : #> ( w -- b u ) drop hld @ pad over - ; : str ( n -- b u ) dup >r abs <# #s r> sign #> ; : hex ( -- ) 16 base ! ; : octal ( -- ) 8 base ! ; -: decimal ( -- ) 10 base ! ; +: decimal ( -- ) 10 base ! ; : binary ( -- ) 2 base ! ; : u. ( u -- ) <# #s #> type space ; : . ( w -- ) base @ 10 xor if u. exit then str type space ; : ? ( a -- ) @ . ;