Compare commits

...

2 commits

Author SHA1 Message Date
crc
5e521f3acd embed stack comments in various library/ files
FossilOrigin-Name: b4679cff7215b99fa283ced0915a0411dddc6c8bbaa808d54a02c141c2ff59fb
2024-09-18 00:40:34 +00:00
crc
de7e670060 embed stack comments in various library/ files
FossilOrigin-Name: fa9205cf084acd917af13e72a932f0133285215b2f163299dbd3dc76128ab68d
2024-09-18 00:34:56 +00:00
8 changed files with 77 additions and 80 deletions

View file

@ -57,6 +57,7 @@
i/o extension i/o extension
- adds "openbsd:pledge" - adds "openbsd:pledge"
- adds "openbsd:unveil" - adds "openbsd:unveil"
- remove "describe.retro"
- retro-compiler - retro-compiler

View file

@ -15,8 +15,8 @@ This begins by using these to implement the `block:load` and
~~~ ~~~
'ilo.blocks block:set-file 'ilo.blocks block:set-file
:block:load block:read ; :block:load (:na-) block:read ;
:block:save block:write ; :block:save (:na-) block:write ;
~~~ ~~~
In Konilo, the memory is constrained to 65,536 cells, with a In Konilo, the memory is constrained to 65,536 cells, with a
@ -37,14 +37,17 @@ are provided. Alter the `Blocks` count to match your actual
data store limits. data store limits.
~~~ ~~~
'Block var 'Block var (:-a)
#128 'Blocks var-n 'Variable;_current_block_number add-description
#128 'Blocks var-n (:-a)
'Variable;_number_of_blocks_in_block_store add-description
~~~ ~~~
`e:line` displays a line from the block buffer. `e:line` displays a line from the block buffer.
~~~ ~~~
:e:line (n-) :e:line (:n-)
#64 n:mul block:buffer n:add #64 n:mul block:buffer n:add
#64 [ fetch-next c:put ] times drop nl ; #64 [ fetch-next c:put ] times drop nl ;
~~~ ~~~
@ -63,9 +66,9 @@ data store limits.
:block# 'Editing_# s:put @Block n:put :block# 'Editing_# s:put @Block n:put
'_of_ s:put @Blocks n:dec n:put nl ; '_of_ s:put @Blocks n:dec n:put nl ;
---reveal--- ---reveal---
:list* nl #16 [ I e:line ] indexed-times ; :list* (:-) nl #16 [ I e:line ] indexed-times ;
:list# nl lines ; :list# (:-) nl lines ;
:list nl sep lines sep block# ; :list (:-) nl sep lines sep block# ;
}} }}
~~~ ~~~
@ -88,13 +91,13 @@ blocks.
{{ {{
:constrain @Block #0 @Blocks n:dec n:limit !Block ; :constrain @Block #0 @Blocks n:dec n:limit !Block ;
---reveal--- ---reveal---
:set &Block store constrain ; :set (:n-) &Block store constrain ;
:save &Block fetch block:buffer block:save ; :save (:-) &Block fetch block:buffer block:save ;
:load &Block fetch block:buffer block:load ; :load (:-) &Block fetch block:buffer block:load ;
:next &Block v:inc constrain load ; :next (:-) &Block v:inc constrain load ;
:prev &Block v:dec constrain load ; :prev (:-) &Block v:dec constrain load ;
:new block:buffer #1024 [ #32 swap store-next ] times drop ; :new (:-) block:buffer #1024 [ #32 swap store-next ] times drop ;
:edit set load @e:Display call ; :edit (:n-) set load @e:Display call ;
}} }}
~~~ ~~~
@ -160,7 +163,7 @@ arrays.
&set-input &count-words bi &set-input &count-words bi
[ parse-word valid? [ a:to-string interpret ] &drop choose ] times ; [ parse-word valid? [ a:to-string interpret ] &drop choose ] times ;
---reveal--- ---reveal---
:run &block:buffer n:dec #1024 over store s:evaluate ; :run (:-) &block:buffer n:dec #1024 over store s:evaluate ;
}} }}
~~~ ~~~
@ -172,9 +175,9 @@ arrays.
+-------+-----+--------------------------------------------+ +-------+-----+--------------------------------------------+
~~~ ~~~
:use (block) set load run ; :use (:block) set load run ;
:using (first,last) :using (:first,last)
over n:sub swap set load run [ next run ] times ; over n:sub swap set load run [ next run ] times ;
~~~ ~~~
@ -192,7 +195,7 @@ space.
:save &Block fetch ; :save &Block fetch ;
:restore &Block store load ; :restore &Block store load ;
---reveal--- ---reveal---
:titles save setup @Blocks &describe indexed-times restore ; :titles (:-) save setup @Blocks &describe indexed-times restore ;
}} }}
~~~ ~~~
@ -219,7 +222,7 @@ but not:
:actual block:buffer n:dec dup #32 a:index a:left a:to-string ; :actual block:buffer n:dec dup #32 a:index a:left a:to-string ;
:code? block:buffer fetch $( eq? ; :code? block:buffer fetch $( eq? ;
---reveal--- ---reveal---
:needs (s-) :needs (:s-)
@Hash [ @Block swap @Hash [ @Block swap
s:hash !Hash s:hash !Hash
@Blocks [ I set load reset code? @Blocks [ I set load reset code?

View file

@ -1,10 +1,10 @@
~~~ ~~~
:keys:UP #-300 ; :keys:UP (:-n) #-300 ;
:keys:DOWN #-301 ; :keys:DOWN (:-n) #-301 ;
:keys:RIGHT #-302 ; :keys:RIGHT (:-n) #-302 ;
:keys:LEFT #-303 ; :keys:LEFT (:-n) #-303 ;
:c:get/ext (-c) :c:get/ext (:-c)
c:get dup #27 eq? c:get dup #27 eq?
[ drop c:get drop c:get #235 + n:negate ] if ; [ drop c:get drop c:get #235 + n:negate ] if ;
~~~ ~~~

View file

@ -1,7 +0,0 @@
This adds a `describe` word which runs retro-describe(1). It's
a useful tool for looking up glossay data in an interactive
session.
~~~
:describe (s-) 'retro-describe_%s s:format unix:system ;
~~~

View file

@ -17,12 +17,12 @@ placed in the `n:` namespace. (In Konilo, these are the standard
names for these). names for these).
~~~ ~~~
:n:add + ; :n:add (:nn-n) + ;
:n:sub - ; :n:sub (:nn-n) - ;
:n:mul * ; :n:mul (:nn-n) * ;
:n:div / ; :n:div (:nn-nn) / ;
:n:mod mod ; :n:mod (:nn-n) mod ;
:n:divmod /mod ; :n:divmod (:nn-n) /mod ;
:comma , ; :comma (:n-) , ;
~~~ ~~~

View file

@ -2,19 +2,19 @@
#74 'ti:width var-n #74 'ti:width var-n
#21 'ti:height var-n #21 'ti:height var-n
:vt:esc (-) #27 c:put ; :vt:esc (:-) #27 c:put ;
:vt:csi (-) vt:esc $[ c:put ; :vt:csi (:-) vt:esc $[ c:put ;
:vt:home (-) vt:csi $H c:put ; :vt:home (:-) vt:csi $H c:put ;
:vt:row,col (nn-) vt:csi swap n:put $; c:put n:put $H c:put ; :vt:row,col (:nn-) vt:csi swap n:put $; c:put n:put $H c:put ;
:vt:up (-) vt:csi n:put $A c:put ; :vt:up (:-) vt:csi n:put $A c:put ;
:vt:down (-) vt:csi n:put $B c:put ; :vt:down (:-) vt:csi n:put $B c:put ;
:vt:right (-) vt:csi n:put $C c:put ; :vt:right (:-) vt:csi n:put $C c:put ;
:vt:left (-) vt:csi n:put $D c:put ; :vt:left (:-) vt:csi n:put $D c:put ;
:vt:clear (-) vt:csi '2J s:put ; :vt:clear (:-) vt:csi '2J s:put ;
:vt:reset vt:csi '0m s:put ; :vt:reset vt:csi '0m s:put ;
:vt:set/color (n-) vt:csi '1;34; s:put n:put $m c:put ; :vt:set/color (:n-) vt:csi '1;34; s:put n:put $m c:put ;
:fg:black #30 vt:set/color ; :bg:black #40 vt:set/color ; :fg:black #30 vt:set/color ; :bg:black #40 vt:set/color ;
:fg:red #31 vt:set/color ; :bg:red #41 vt:set/color ; :fg:red #31 vt:set/color ; :bg:red #41 vt:set/color ;
@ -27,17 +27,17 @@
'ti:Actions d:create #128 comma #128 allot 'ti:Actions d:create #128 comma #128 allot
:ti:set-action (qc-) &ti:Actions swap a:store ; :ti:set-action (:qc-) &ti:Actions swap a:store ;
:ti:reset-actions (-) :ti:reset-actions (:-)
#128 [ #0 I ti:set-action ] indexed-times ; #128 [ #0 I ti:set-action ] indexed-times ;
:ti:get-action (c-q) &ti:Actions swap a:fetch ; :ti:get-action (:c-q) &ti:Actions swap a:fetch ;
:ti:perform-action (c-) :ti:perform-action (:c-)
ti:get-action dup n:-zero? &call &drop choose ; ti:get-action dup n:-zero? &call &drop choose ;
:ti:input (-) c:get ti:perform-action ; :ti:input (:-) c:get ti:perform-action ;
{{ {{
'ti:Hints d:create #130 allot :empty (-s) '____________ ; 'ti:Hints d:create #130 allot :empty (-s) '____________ ;
@ -49,9 +49,9 @@
dup n:put sp start s:put sp ; dup n:put sp start s:put sp ;
:clean (-) '_ s:temp constrain pad I start #13 copy ; :clean (-) '_ s:temp constrain pad I start #13 copy ;
---reveal--- ---reveal---
:ti:add-hint (sn-) :ti:add-hint (:sn-)
#13 n:mul &ti:Hints n:add [ constrain pad ] dip #13 copy ; #13 n:mul &ti:Hints n:add [ constrain pad ] dip #13 copy ;
:ti:reset-hints (-) #10 &clean indexed-times ; :ti:reset-hints (:-) #10 &clean indexed-times ;
:ti:hints #10 [ display I #4 eq? &nl if ] indexed-times ; :ti:hints #10 [ display I #4 eq? &nl if ] indexed-times ;
}} }}
@ -59,22 +59,22 @@
&ti:display/none 'ti:Display var-n &ti:display/none 'ti:Display var-n
:ti:set-display (a-) !ti:Display ; :ti:set-display (:a-) !ti:Display ;
:ti:reset-display (-) &ti:display/none ti:set-display ; :ti:reset-display (:-) &ti:display/none ti:set-display ;
:ti:display (-) :ti:display (:-)
vt:home @ti:Display call vt:home @ti:Display call
@ti:height #3 n:sub #0 vt:row,col @ti:width [ $- c:put ] times @ti:height #3 n:sub #0 vt:row,col @ti:width [ $- c:put ] times
nl ti:hints nl ; nl ti:hints nl ;
'ti:ptrs d:create #0 comma #5 allot 'ti:ptrs d:create #0 comma #5 allot
:ti:add-program (a-) &ti:ptrs v:inc &ti:ptrs @ti:ptrs a:store ; :ti:add-program (:a-) &ti:ptrs v:inc &ti:ptrs @ti:ptrs a:store ;
:ti:current (-a) &ti:ptrs @ti:ptrs a:fetch ; :ti:current (:-a) &ti:ptrs @ti:ptrs a:fetch ;
:ti:more? (-f) @ti:ptrs n:-zero? ; :ti:more? (:-f) @ti:ptrs n:-zero? ;
:ti:remove &ti:ptrs v:dec ; :ti:remove &ti:ptrs v:dec ;
:ti:load (-) :ti:load (:-)
ti:current call ti:current call
!ti:Display ti:reset-hints call ti:reset-actions call ; !ti:Display ti:reset-hints call ti:reset-actions call ;
@ -82,10 +82,10 @@
:ti:done #-1 !ti:Done vt:reset nl ; :ti:done #-1 !ti:Done vt:reset nl ;
:ti:done? @ti:Done ; :ti:done? @ti:Done ;
:ti:application/run (-) :ti:application/run (:-)
[ #0 !ti:Done ti:display ti:input ti:done? ] until [ #0 !ti:Done ti:display ti:input ti:done? ] until
ti:remove ti:more? [ ti:load #0 !ti:Done ] if ; ti:remove ti:more? [ ti:load #0 !ti:Done ] if ;
:ti:application (q-) :ti:application (:q-)
ti:add-program ti:load ti:application/run ; ti:add-program ti:load ti:application/run ;
~~~ ~~~

View file

@ -58,14 +58,14 @@ them for an 80x25 display.
#13 [ #0 !TX &TY v:inc ] case #13 [ #0 !TX &TY v:inc ] case
&TOB TOB:W @TY n:mul n:add @TX n:add store &TX v:inc ; &TOB TOB:W @TY n:mul n:add @TX n:add store &TX v:inc ;
:tob:put (c-) handle advance-cursor ; :tob:put (:c-) handle advance-cursor ;
:tob:display :tob:display
&TOB TOB:H [ TOB:W [ fetch-next c:put ] times nl ] times drop ; &TOB TOB:H [ TOB:W [ fetch-next c:put ] times nl ] times drop ;
:tob:with (q-) &tob:put &c:put set-hook call &c:put unhook ; :tob:with (:q-) &tob:put &c:put set-hook call &c:put unhook ;
:tob:clear (-) :tob:clear (:-)
TOB:W TOB:H n:mul [ #32 tob:put ] times #0 !TX #0 !TY ; TOB:W TOB:H n:mul [ #32 tob:put ] times #0 !TX #0 !TY ;
tob:clear tob:clear

View file

@ -1,29 +1,29 @@
~~~ ~~~
:pixel (xyc-) #33 io:scan-for io:invoke ; :pixel (:xyc-) #33 io:scan-for io:invoke ;
:get-pixel (xy-c) #34 io:scan-for io:invoke ; :get-pixel (:xy-c) #34 io:scan-for io:invoke ;
:mouse (-xyb) #35 io:scan-for io:invoke ; :mouse (:-xyb) #35 io:scan-for io:invoke ;
:hline (xyw-) :hline (:xyw-)
[ dup-pair #1 pixel &n:inc dip ] times drop-pair ; [ dup-pair #1 pixel &n:inc dip ] times drop-pair ;
:vline (xyh-) :vline (:xyh-)
[ dup-pair #1 pixel n:inc ] times drop-pair ; [ dup-pair #1 pixel n:inc ] times drop-pair ;
:dline\ (xyl-) :dline\ (:xyl-)
[ dup-pair #1 pixel &n:inc bi@ ] times drop-pair ; [ dup-pair #1 pixel &n:inc bi@ ] times drop-pair ;
:dline/ (xyl-) :dline/ (:xyl-)
[ dup-pair #1 pixel &n:dec &n:inc bi* ] times drop-pair ; [ dup-pair #1 pixel &n:dec &n:inc bi* ] times drop-pair ;
'X var 'Y var 'H var 'W var 'X var 'Y var 'H var 'W var
:rect (xyhw-) !W !H !Y !X :rect (:xyhw-) !W !H !Y !X
@X @Y @W hline @X @Y @H n:add @W hline @X @Y @W hline @X @Y @H n:add @W hline
@X @Y @H vline @X @W n:add @Y @H vline ; @X @Y @H vline @X @W n:add @Y @H vline ;
'XC var 'YC var 'X var 'Y var 'XC var 'YC var 'X var 'Y var
:octant (xc,yc,x,y) :octant (:xc,yc,x,y)
!Y !X !YC !XC !Y !X !YC !XC
@XC @X n:add @YC @Y n:add #1 pixel @XC @X n:add @YC @Y n:add #1 pixel
@XC @X n:sub @YC @Y n:add #1 pixel @XC @X n:sub @YC @Y n:add #1 pixel
@ -36,7 +36,7 @@
'XC var 'YC var 'X var 'Y var 'D var 'R var 'XC var 'YC var 'X var 'Y var 'D var 'R var
:circle (xyr-) :circle (:xyr-)
!R !YC !XC #0 !X @R [ !Y ] [ !D ] bi !R !YC !XC #0 !X @R [ !Y ] [ !D ] bi
@XC @YC @X @Y octant @XC @YC @X @Y octant
[ &X v:inc [ &X v:inc
@ -55,8 +55,8 @@
:t:right [ &X v:inc ] !D ; :t:right [ &X v:inc ] !D ;
:t:up [ &Y v:dec ] !D ; :t:up [ &Y v:dec ] !D ;
:t:down [ &Y v:inc ] !D ; :t:down [ &Y v:inc ] !D ;
:t:at (xy-) !Y !X ; :t:at (:xy-) !Y !X ;
:t:forward (n-) [ @X @Y @C pixel @D call ] times ; :t:forward (:n-) [ @X @Y @C pixel @D call ] times ;
#320 #240 t:at t:lower t:right #320 #240 t:at t:lower t:right