retroforth/source/interfaces/barebones.forth
crc f7a0698486 source tree reorganizations
FossilOrigin-Name: 654eda2d23299be894f94e8b615e7432de6a3bd5dbb6f4caa454cc20e65a510b
2019-05-02 16:25:16 +00:00

23 lines
528 B
Forth

~~~
{{
:eol? (c-f)
[ ASCII:CR eq? ] [ ASCII:LF eq? ] [ ASCII:SPACE eq? ] tri or or ;
:valid? (s-sf)
dup s:length n:-zero? ;
:check-bs (c-c)
dup [ #8 eq? ] [ #127 eq? ] bi or [ buffer:get buffer:get drop-pair ] if ;
:c:get (-c) as{ 'liii.... i #1 d }as ;
:s:get (-s) [ #1025 buffer:set
[ c:get dup buffer:add check-bs eol? ] until
buffer:start s:chop ] buffer:preserve ;
:listen (-)
repeat s:get valid? &interpret &drop choose again ;
&listen #1 store
}}
~~~