retroforth/takawiri.retro
crc 9aafe73529 in takawiri, some refactoring & start on a new s:evaluate alternative
FossilOrigin-Name: 018bc6d8f0025aae2a177da7051b1109f0014336ab03b35f400f9c6152f826ca
2024-01-19 17:40:14 +00:00

111 lines
2.4 KiB
Forth
Executable file

#!/usr/bin/env retro
================================================================
_ _ _ _
| |_ __ _| | ____ ___ _(_)_ __(_) crc's new listener for
| __/ _` | |/ / _` \ \ /\ / / | '__| | RetroForth
| || (_| | < (_| |\ V V /| | | | |
\__\__,_|_|\_\__,_| \_/\_/ |_|_| |_| ** UNDER DEVELOPMENT **
================================================================
~~~
#80 'TOB:W const
#23 'TOB:H const
~~~
Load depenencies from the library.
~~~
{ 'konilo 'termina 'tob } &library:load a:for-each
~~~
# ui
Configure the UI colors.
~~~
:dss:label (-) fg:red ;
:dss:value (-) fg:cyan ;
:dss:sep (-) fg:blue ;
:dss:prompt (-) fg:magenta ;
~~~
~~~
:~left dss:sep #23 [ I n:inc #82 vt:row,col $| c:put ] indexed-times vt:reset ;
:~bottom dss:sep #24 #1 vt:row,col #81 [ $= c:put ] times $+ c:put vt:reset ;
'Items d:create #0 comma #32 allot
:dss
[ depth #32 n:min !Items
&Items fetch-next [ store-next ] times drop
&Items a:reverse [ ] a:for-each
#0 &Items [
over n:inc #6 n:add #84 vt:row,col
dss:label
over n:zero? [ 'TOS:___ s:put ] [ '_______ s:put ] choose
vt:reset
n:put
n:inc ] a:for-each
drop ] gc ;
:layout:stat,col (-n) #84 ;
:layout:stat (sn-) layout:stat,col vt:row,col dss:label s:put dss:value ;
:stats
'HERE:__ #1 layout:stat here n:put
'FREE:__ #2 layout:stat FREE n:put
'DEPTH:_ #3 layout:stat depth n:put
'ROW:___ #4 layout:stat @TY n:put
'COL:___ #5 layout:stat @TX n:put
vt:reset
;
#1 #2 #3 #4 #5
:prompt (-)
dss:prompt #25 #1 vt:row,col '>>_ s:put vt:reset ;
~~~
Start of work on a new input model. The current one uses
`s:evaluate`, which works, but burns through the temporary
strings pool. For this to be practical, I need to avoid doing
that, so it's time to write a replacement.
~~~
'InputStream d:create #1025 allot
'Len var
'At var
:end? (-f) @At @Len gt? ;
:s:get/input s:get &InputStream s:copy ;
~~~
~~~
:ui
&err:notfound unhook
&banner tob:with
[ vt:clear vt:home tob:display
~left stats dss
~bottom
prompt s:get
[ dup s:put nl s:evaluate ] tob:with
] forever ;
ui
~~~
================================================================
Things needed:
- termios device & words (or add termios to unix device?)
- colors for interface elements
- write a better alternative to `s:evaluate` to avoid consuming
the temporary string space
- refactor & document everything
================================================================