mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 19:58:06 +11:00
Don't emit BS when at beginning of input buffer
This commit is contained in:
parent
aad713c477
commit
b6c039589f
4
blk/427
4
blk/427
@ -1,10 +1,10 @@
|
|||||||
( handle backspace: go back one char in IN>, if possible, then
|
( handle backspace: go back one char in IN>, if possible, then
|
||||||
emit SPC + BS )
|
emit BS + SPC + BS )
|
||||||
: (inbs)
|
: (inbs)
|
||||||
( already at IN( ? )
|
( already at IN( ? )
|
||||||
IN> @ IN( = IF EXIT THEN
|
IN> @ IN( = IF EXIT THEN
|
||||||
IN> @ 1- IN> !
|
IN> @ 1- IN> !
|
||||||
SPC BS
|
BS SPC BS
|
||||||
;
|
;
|
||||||
|
|
||||||
: KEY
|
: KEY
|
||||||
|
12
blk/428
12
blk/428
@ -1,16 +1,16 @@
|
|||||||
: (rdlnc) ( -- f )
|
: (rdlnc) ( -- c )
|
||||||
( buffer overflow? same as if we typed a newline )
|
( buffer overflow? same as if we typed a newline )
|
||||||
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
|
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
|
||||||
DUP 0x7f = IF DROP 0x8 THEN ( del? same as backspace )
|
DUP 0x7f = IF DROP 0x8 THEN ( del? same as backspace )
|
||||||
DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
|
DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
|
||||||
( echo back )
|
|
||||||
DUP EMIT ( c )
|
|
||||||
( bacspace? handle and exit )
|
( bacspace? handle and exit )
|
||||||
DUP 0x8 = IF (inbs) EXIT THEN
|
DUP 0x8 = IF (inbs) EXIT THEN
|
||||||
|
( echo back )
|
||||||
|
DUP EMIT ( c )
|
||||||
( write and advance )
|
( write and advance )
|
||||||
DUP ( keep as result ) ( c c )
|
DUP ( keep as result ) ( c c )
|
||||||
( We take advantage of the fact that c's MSB is always zero and
|
( We take advantage of the fact that c's MSB is always zero and
|
||||||
thus ! automatically null-terminates our string )
|
thus ! automatically null-terminates our string )
|
||||||
IN> @ ! 1 IN> +! ( c )
|
IN> @ ! 1 IN> +! ( c )
|
||||||
( if newline, replace with zero to indicate EOL )
|
( if newline, replace with zero to indicate EOL )
|
||||||
DUP 0xd = IF DROP 0 THEN ;
|
DUP 0xd = IF DROP 0 THEN ;
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user