retroforth/interface/barebones.forth
crc 00586f3354 move interfaces to interface/
FossilOrigin-Name: 95a4793e965f0787a8664e4dc3a4f49f66098c30c2a209b6a6d7c2c5fb79193a
2019-11-21 19:48:05 +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
}}
~~~