clean up, use insert-cell

This commit is contained in:
~d6 2023-02-11 22:34:06 -05:00
parent 56200a1c59
commit 675af45ff3
1 changed files with 56 additions and 63 deletions

View File

@ -156,7 +156,7 @@
update-tint update-tint
( set initial modes ) ( set initial modes )
#01 .irm STZ ( insert and move right ) #00 .irm STZ ( insert and move right )
#01 .awm STZ ( wrap at margin ) #01 .awm STZ ( wrap at margin )
#01 .tcem STZ ( show cursor ) #01 .tcem STZ ( show cursor )
#00 .paste STZ ( bracketed paste is off ) #00 .paste STZ ( bracketed paste is off )
@ -179,7 +179,7 @@
#01 .visual-bell STZ #01 .visual-bell STZ
( set to 01 to enable debug log ) ( set to 01 to enable debug log )
#01 .debug STZ #00 .debug STZ
.debug LDZ ?&continue BRK &continue .debug LDZ ?&continue BRK &continue
#99 #010e DEO #99 #010e DEO
@ -781,22 +781,22 @@
&skip POP2 POP2 JMP2r ( ) &skip POP2 POP2 JMP2r ( )
@exec-move-row ( c^ -> BRK ) @exec-move-row ( c^ -> BRK )
POP POP ( )
#0001 read-arg-1 dec-floor ( row ) #0001 read-arg-1 dec-floor ( row )
.cur-x LDZ2 ( col ) .cur-x LDZ2 ( col )
goto BRK goto BRK ( )
@exec-move-col ( c^ -> BRK ) @exec-move-col ( c^ -> BRK )
POP POP ( )
.cur-y LDZ2 ( row ) .cur-y LDZ2 ( row )
#0001 read-arg-1 dec-floor ( col ) #0001 read-arg-1 dec-floor ( col )
goto BRK goto BRK ( )
@exec-move ( c^ -> BRK ) @exec-move ( c^ -> BRK )
POP POP ( )
#0001 read-arg-1 dec-floor ( row ) #0001 read-arg-1 dec-floor ( row )
#0001 read-arg-2 dec-floor ( col ) #0001 read-arg-2 dec-floor ( col )
goto BRK goto BRK ( )
@dec-floor ( x* -> x==0 ? 0* : x-1* ) @dec-floor ( x* -> x==0 ? 0* : x-1* )
ORAk ?&sub JMP2r &sub #0001 SUB2 JMP2r ORAk ?&sub JMP2r &sub #0001 SUB2 JMP2r
@ -848,8 +848,7 @@
.Console/r DEI .Console/r DEI
DUP debug-read DUP debug-read
DUP ?&ok POP BRK DUP ?&ok POP BRK
&ok ( #42 .tint STZ ) &ok !read
!read
@read ( c^ -> BRK ) @read ( c^ -> BRK )
DUP #20 LTH ?read-ctrl DUP #20 LTH ?read-ctrl
@ -901,13 +900,10 @@
.cur-y LDZ2 .max-y LDZ2 EQU2 JMP2r .cur-y LDZ2 .max-y LDZ2 EQU2 JMP2r
@read-nl ( 0a -> BRK ) @read-nl ( 0a -> BRK )
POP clear-cursor POP clear-cursor at-max-y ?scroll down BRK
at-max-y ?scroll down BRK
@read-printable ( c^ -> BRK ) @read-printable ( c^ -> BRK )
.tint LDZ SWP DUP2 cur-addr STA2 .tint LDZ SWP DUP2 insert-cell draw-cell forward BRK
draw-cell
forward BRK
@goto ( y* x* -> ) @goto ( y* x* -> )
clear-cursor clear-cursor
@ -945,16 +941,13 @@
@down ( -> ) @down ( -> )
#0001 !down-n #0001 !down-n
@insert ( c^ -> )
.attr LDZ SWP !insert-cell
@insert-cell ( cell* -> ) @insert-cell ( cell* -> )
.irm LDZ #00 EQU ?&replace ( cell* ) .irm LDZ #00 EQU ?&replace ( cell* )
eol-addr #0001 SUB2 ( cell* last=eol-1* ) cur-addr ( cell* lim* )
cur-addr ( cell* last* cur* ) eol-addr #0002 SUB2 ( cell* lim* last=eol-2* )
&loop ( cell* last* pos* ) &loop ( cell* lim* pos* )
LDA2k OVR2 INC2 STA2 ( cell* last* pos* ; pos+1<-pos ) STH2k #0002 SUB2 LDA2k ( cell* lim* pos-2* cell* [pos*] )
INC2 GTH2k ?&loop ( cell* last pos+1* ) STH2r STA2 LTH2k ?&loop ( cell* lim* pos-2* )
POP2 POP2 ( cell* ) POP2 POP2 ( cell* )
&replace ( cell* ) &replace ( cell* )
cur-addr STA2 JMP2r ( ) cur-addr STA2 JMP2r ( )