diff --git a/ueforth/Makefile b/ueforth/Makefile
index ac3306d..106a2de 100644
--- a/ueforth/Makefile
+++ b/ueforth/Makefile
@@ -115,21 +115,21 @@ core_test: $(POSIX)/ueforth common/core_test.fs \
$(GEN):
mkdir -p $@
-POSIX_BOOT = common/boot.fs common/terminal.fs \
+POSIX_BOOT = common/boot.fs common/ansi.fs \
posix/posix.fs posix/posix_highlevel.fs \
- common/filetools.fs posix/posix_desktop.fs \
+ common/highlevel.fs common/filetools.fs posix/posix_desktop.fs \
common/tasks.fs common/streams.fs common/blocks.fs
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
echo "ok" | cat $(POSIX_BOOT) - | $< boot >$@
-WINDOWS_BOOT = common/boot.fs common/terminal.fs \
- windows/windows.fs \
+WINDOWS_BOOT = common/boot.fs common/ansi.fs \
+ windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \
common/tasks.fs common/streams.fs common/blocks.fs
$(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
echo "ok" | cat $(WINDOWS_BOOT) - | $< boot >$@
ARDUINO_BOOT = common/boot.fs arduino/arduino.fs \
- posix/posix_highlevel.fs common/filetools.fs \
+ posix/posix_highlevel.fs common/highlevel.fs common/filetools.fs \
common/tasks.fs common/streams.fs arduino/arduino_server.fs \
arduino/esp_camera.fs common/blocks.fs \
arduino/autoboot.fs
diff --git a/ueforth/common/terminal.fs b/ueforth/common/ansi.fs
similarity index 95%
rename from ueforth/common/terminal.fs
rename to ueforth/common/ansi.fs
index 17d0b8a..c997724 100644
--- a/ueforth/common/terminal.fs
+++ b/ueforth/common/ansi.fs
@@ -1,4 +1,4 @@
-( Terminal handling )
+( ANSI Codes )
: n. ( n -- ) base @ swap decimal <# #s #> type base ! ;
: esc 27 emit ; : bel 7 emit ;
: at-xy ( x y -- ) esc ." [" 1+ n. ." ;" 1+ n. ." H" ;
diff --git a/ueforth/common/boot.fs b/ueforth/common/boot.fs
index 81b67a8..758ca71 100644
--- a/ueforth/common/boot.fs
+++ b/ueforth/common/boot.fs
@@ -205,8 +205,15 @@ variable echo
: ?echo ( n -- ) echo @ if emit else drop then ;
: ?echo-prompt echo @ if ." --> " then ;
: accept ( a n -- n ) ?echo-prompt 0 swap begin 2dup < while
- key dup ?echo dup nl = if 2drop nip exit then
- >r rot r> over c! 1+ -rot swap 1+ swap repeat drop nip ;
+ key
+ dup nl = if ?echo drop nip exit then
+ dup 8 = over 127 = or if
+ drop over if rot 1- rot 1- rot 8 ?echo bl ?echo 8 ?echo then
+ else
+ dup ?echo
+ >r rot r> over c! 1+ -rot swap 1+ swap
+ then
+ repeat drop nip ;
200 constant input-limit
: tib ( -- a ) 'tib @ ;
create input-buffer input-limit allot
diff --git a/ueforth/common/highlevel.fs b/ueforth/common/highlevel.fs
new file mode 100644
index 0000000..35d32ca
--- /dev/null
+++ b/ueforth/common/highlevel.fs
@@ -0,0 +1,11 @@
+( Including Files )
+: included ( a n -- )
+ r/o open-file dup if nip throw else drop then
+ dup file-size throw
+ dup allocate throw
+ swap 2dup >r >r
+ rot dup >r read-file throw drop
+ r> close-file throw
+ r> r> over >r evaluate
+ r> free throw ;
+: include ( "name" -- ) bl parse included ;
diff --git a/ueforth/posix/posix.fs b/ueforth/posix/posix.fs
index 04dd9d0..9389961 100644
--- a/ueforth/posix/posix.fs
+++ b/ueforth/posix/posix.fs
@@ -66,6 +66,7 @@ octal
100 constant O_CREAT
200 constant O_TRUNC
2000 constant O_APPEND
+4000 constant O_NONBLOCK
decimal
( Hookup I/O )
@@ -103,3 +104,6 @@ octal 777 constant 0777 decimal
( Other Utils )
: ms ( n -- ) 1000 * usleep drop ;
+
+( errno.h )
+11 constant EAGAIN
diff --git a/ueforth/posix/posix_highlevel.fs b/ueforth/posix/posix_highlevel.fs
index b5c2280..a47de85 100644
--- a/ueforth/posix/posix_highlevel.fs
+++ b/ueforth/posix/posix_highlevel.fs
@@ -3,14 +3,3 @@
: free ( a -- ior ) sysfree drop 0 ;
: resize ( a n -- a ior ) realloc dup 0= ;
-( Including Files )
-: included ( a n -- )
- r/o open-file dup if nip throw else drop then
- dup file-size throw
- dup allocate throw
- swap 2dup >r >r
- rot dup >r read-file throw drop
- r> close-file throw
- r> r> over >r evaluate
- r> free throw ;
-: include ( "name" -- ) bl parse included ;
diff --git a/ueforth/posix/terminal.fs b/ueforth/posix/terminal.fs
new file mode 100644
index 0000000..ca2e5a4
--- /dev/null
+++ b/ueforth/posix/terminal.fs
@@ -0,0 +1,10 @@
+include posix/termios.fs
+
+s" /dev/ttyS3" r/w O_NONBLOCK or open-file throw constant remote
+: remote-type ( a n -- ) remote write-file throw ;
+: remote-emit ( ch -- ) >r rp@ 1 remote-type rdrop ;
+: remote-key ( -- ch|0 )
+ 0 >r rp@ 1 remote read-file dup EAGAIN = if rdrop 2drop 0 exit then
+ throw if r> else rdrop 0 then ;
+: terminal nodelay-mode begin key dup if remote-emit else drop then
+ remote-key dup if emit else drop then again ;
diff --git a/ueforth/web/terminal.html b/ueforth/web/terminal.html
index 52ab718..e16c864 100644
--- a/ueforth/web/terminal.html
+++ b/ueforth/web/terminal.html
@@ -1,4 +1,4 @@