2024-01-19 18:40:14 +01:00
|
|
|
#!/usr/bin/env retro
|
|
|
|
|
2024-01-19 14:11:51 +01:00
|
|
|
================================================================
|
|
|
|
_ _ _ _
|
|
|
|
| |_ __ _| | ____ ___ _(_)_ __(_) crc's new listener for
|
|
|
|
| __/ _` | |/ / _` \ \ /\ / / | '__| | RetroForth
|
|
|
|
| || (_| | < (_| |\ V V /| | | | |
|
|
|
|
\__\__,_|_|\_\__,_| \_/\_/ |_|_| |_| ** UNDER DEVELOPMENT **
|
|
|
|
|
|
|
|
================================================================
|
|
|
|
|
2024-01-20 19:57:15 +01:00
|
|
|
# Terminal Configuration
|
|
|
|
|
|
|
|
Setup the text output buffer dimensions.
|
|
|
|
|
2024-01-19 18:40:14 +01:00
|
|
|
~~~
|
|
|
|
#80 'TOB:W const
|
2024-01-22 12:21:09 +01:00
|
|
|
#25 'TOB:H const
|
2024-01-19 18:40:14 +01:00
|
|
|
~~~
|
|
|
|
|
2024-01-20 19:57:15 +01:00
|
|
|
Setup the local terminal dimensions.
|
|
|
|
|
|
|
|
~~~
|
2024-01-22 12:21:09 +01:00
|
|
|
#105 'LT:W const
|
2024-01-20 19:57:15 +01:00
|
|
|
#30 'LT:H const
|
|
|
|
~~~
|
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
|
2024-01-19 14:11:51 +01:00
|
|
|
Load depenencies from the library.
|
|
|
|
|
|
|
|
~~~
|
|
|
|
{ 'konilo 'termina 'tob } &library:load a:for-each
|
|
|
|
~~~
|
|
|
|
|
2024-01-20 19:57:15 +01:00
|
|
|
# Utilities
|
2024-01-20 19:25:24 +01:00
|
|
|
|
|
|
|
I intend for takawiri to provide a variety of useful tools to
|
|
|
|
aid in using RetroForth interactively.
|
|
|
|
|
|
|
|
This word provides access to retro-describe(1).
|
|
|
|
|
|
|
|
~~~
|
|
|
|
:describe (s-)
|
|
|
|
'retro-describe_"%s" s:format file:R unix:popen
|
|
|
|
[ dup file:read dup c:put n:zero? ] until unix:pclose ;
|
|
|
|
~~~
|
|
|
|
|
2024-01-20 19:57:15 +01:00
|
|
|
# Watchlist
|
|
|
|
|
|
|
|
The watchlist will allow monitoring a small number of addresses
|
|
|
|
in the right panel of the interface. A use case might be to
|
|
|
|
do something like:
|
|
|
|
|
|
|
|
'Base &Base watch
|
|
|
|
'Compiler &Compiler watch
|
|
|
|
|
|
|
|
~~~
|
|
|
|
{ '________
|
|
|
|
'________
|
|
|
|
'________
|
|
|
|
'________
|
|
|
|
'________
|
2024-01-20 20:06:04 +01:00
|
|
|
} 'WatchlistLabels d:create #5 , &, a:for-each
|
2024-01-20 19:57:15 +01:00
|
|
|
|
2024-01-20 20:06:04 +01:00
|
|
|
'Watchlist d:create #5 , #5 allot
|
2024-01-20 19:57:15 +01:00
|
|
|
|
|
|
|
:watch (sa-) drop-pair ;
|
|
|
|
:unwatch (a-) drop ;
|
2024-01-20 20:06:04 +01:00
|
|
|
:watchlist (-)
|
|
|
|
#18 #84 vt:row,col #20 [ $- c:put ] times
|
|
|
|
#19 #5 [ dup #84 vt:row,col
|
|
|
|
&Watchlist over #19 n:sub a:fetch
|
|
|
|
fetch n:put n:inc ] times drop ;
|
2024-01-20 19:57:15 +01:00
|
|
|
~~~
|
|
|
|
|
2024-01-19 14:11:51 +01:00
|
|
|
# ui
|
|
|
|
|
2024-01-19 18:40:14 +01:00
|
|
|
Configure the UI colors.
|
|
|
|
|
2024-01-19 14:11:51 +01:00
|
|
|
~~~
|
2024-01-19 18:40:14 +01:00
|
|
|
:dss:label (-) fg:red ;
|
2024-01-19 14:11:51 +01:00
|
|
|
:dss:value (-) fg:cyan ;
|
|
|
|
:dss:sep (-) fg:blue ;
|
2024-01-20 19:57:15 +01:00
|
|
|
:dss:prompt (-) bg:blue fg:white ;
|
2024-01-19 18:40:14 +01:00
|
|
|
~~~
|
2024-01-19 14:11:51 +01:00
|
|
|
|
2024-01-19 18:40:14 +01:00
|
|
|
~~~
|
2024-01-22 12:21:09 +01:00
|
|
|
:~left dss:sep TOB:H n:inc [ I n:inc #82 vt:row,col $| c:put ] indexed-times vt:reset ;
|
|
|
|
:~bottom dss:sep TOB:H n:inc #1 vt:row,col #81 [ $= c:put ] times $+ c:put vt:reset ;
|
2024-01-19 14:11:51 +01:00
|
|
|
|
|
|
|
'Items d:create #0 comma #32 allot
|
|
|
|
|
|
|
|
:dss
|
2024-01-20 20:06:04 +01:00
|
|
|
#6 #84 vt:row,col #20 [ $- c:put ] times
|
2024-01-20 19:25:24 +01:00
|
|
|
[ depth #5 n:min !Items
|
2024-01-19 14:11:51 +01:00
|
|
|
&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 ;
|
2024-01-20 19:25:24 +01:00
|
|
|
~~~
|
|
|
|
|
|
|
|
This is the start of code to display temporary strings on the
|
|
|
|
data stack. The plan is to have it show below the stack values,
|
|
|
|
in a format like:
|
2024-01-19 14:11:51 +01:00
|
|
|
|
2024-01-20 19:25:24 +01:00
|
|
|
<depth> <first XX characters>
|
|
|
|
|
|
|
|
The <depth> data will match up to the values in the stack disp.
|
|
|
|
|
|
|
|
Note: this won't be useful until after the alternate `s:evaluate`
|
|
|
|
is done.
|
|
|
|
|
|
|
|
~~~
|
|
|
|
:ss (-)
|
2024-01-20 20:06:04 +01:00
|
|
|
#12 #84 vt:row,col #20 [ $- c:put ] times ;
|
|
|
|
|
|
|
|
:ss/later (-)
|
2024-01-20 19:25:24 +01:00
|
|
|
#0 &Items [ dup STRINGS gt? [ over n:inc #12 n:add #84 vt:row,col s:put ] &drop choose n:inc ] a:for-each drop
|
|
|
|
;
|
|
|
|
~~~
|
|
|
|
|
|
|
|
~~~
|
2024-01-19 18:40:14 +01:00
|
|
|
:layout:stat,col (-n) #84 ;
|
|
|
|
:layout:stat (sn-) layout:stat,col vt:row,col dss:label s:put dss:value ;
|
|
|
|
|
2024-01-19 14:11:51 +01:00
|
|
|
:stats
|
2024-01-19 18:40:14 +01:00
|
|
|
'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
|
2024-01-19 14:11:51 +01:00
|
|
|
vt:reset
|
|
|
|
;
|
|
|
|
|
|
|
|
#1 #2 #3 #4 #5
|
|
|
|
|
2024-01-19 18:40:14 +01:00
|
|
|
:prompt (-)
|
2024-01-20 19:57:15 +01:00
|
|
|
dss:prompt
|
2024-01-22 12:21:09 +01:00
|
|
|
LT:H #1 vt:row,col LT:W [ sp ] times
|
|
|
|
LT:H #1 vt:row,col '>>_ s:put ;
|
2024-01-19 18:40:14 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
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? ;
|
|
|
|
|
2024-01-20 19:25:24 +01:00
|
|
|
:c:get-from-input (-c)
|
|
|
|
&InputStream @At fetch &At v:inc end? [ &c:get unhook ] if ;
|
|
|
|
:s:get/input s:get &InputStream s:copy &c:get-from-input &c:get set-hook ;
|
2024-01-19 18:40:14 +01:00
|
|
|
~~~
|
|
|
|
|
|
|
|
~~~
|
2024-01-19 14:11:51 +01:00
|
|
|
:ui
|
|
|
|
&err:notfound unhook
|
|
|
|
&banner tob:with
|
|
|
|
[ vt:clear vt:home tob:display
|
2024-01-20 20:06:04 +01:00
|
|
|
~left stats dss ss watchlist
|
2024-01-19 14:11:51 +01:00
|
|
|
~bottom
|
2024-01-20 19:57:15 +01:00
|
|
|
prompt s:get vt:reset
|
2024-01-19 14:11:51 +01:00
|
|
|
[ 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
|
|
|
|
|
|
|
|
================================================================
|