duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit c711a0228a96415139eba8e5cdbf9883606f32a6
parent dbca6164f1e5e9f89dba17d02acc4e2f6d2d6461
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 20 Jan 2023 14:49:44 -0500

sys/rdln: fix character "ghosting" bug

With the previous approach to buffer management, typing a line, backspacing a
bit and then typing another shorter line would result in the "ghost" of the
previous line being executed. Example:

    42 .^H^H^H\n --> prints 4 instead of just pushing 4 to PS

Diffstat:
Mfs/sys/rdln.fs | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/sys/rdln.fs b/fs/sys/rdln.fs @@ -3,7 +3,7 @@ require /sys/kbd.fs $80 const LNSZ create in( LNSZ allot -here value in) +here const in) in) value in> : bs? BS over = swap $7f = or ; \ only emit c if it's within the visible ascii range @@ -18,7 +18,8 @@ in) value in> in( LNSZ SPC fill S" ok\n" stype in( begin key lntype until 1- LF swap c! nl> ; : rdln<? ( -- c-or-0 ) - in> in) < if in> c@+ swap to in> else 0 then ; + in> in) < if + in> c@+ tuck LF = if drop in) then to in> else 0 then ; : rdln< ( -- c ) rdln<? ?dup not if rdln in( to in> SPC then ; create _buf 1 allot