move from drawing to redrawing
This commit is contained in:
parent
19ea70c328
commit
33a23ed0c8
181
femto.tal
181
femto.tal
|
@ -117,6 +117,12 @@
|
|||
&saw-esc $1 ( did we just see ESC? )
|
||||
&saw-xterm $1 ( did we just see an ESC [ xterm sequence? )
|
||||
&saw-vt $1 ( did we just see an ESC [ $N vt sequence? )
|
||||
&redraw $1 ( redrawing: bits determine which parts )
|
||||
( 0x01 cursor )
|
||||
( 0x02 statusbar )
|
||||
( 0x04 prompt )
|
||||
( 0x08 matches )
|
||||
( 0x10 body and everything else )
|
||||
&modified $1 ( has the buffer been modified? )
|
||||
&quitting $1 ( are we in the process of quitting? )
|
||||
]
|
||||
|
@ -253,12 +259,14 @@
|
|||
|
||||
@bol ( -> )
|
||||
#0000 .cursor/col STZ2
|
||||
;draw-statusbar-and-cursor JSR2 BRK
|
||||
;redraw-statusbar-and-cursor JSR2
|
||||
;return JMP2
|
||||
|
||||
( FIXME: handle long lines )
|
||||
@eol ( -> )
|
||||
;cur-line JSR2 ;line-len JSR2 .cursor/col STZ2
|
||||
;draw-statusbar-and-cursor JSR2 BRK
|
||||
;redraw-statusbar-and-cursor JSR2
|
||||
;return JMP2
|
||||
|
||||
( FIXME: handle long lines )
|
||||
@forward ( -> )
|
||||
|
@ -266,38 +274,42 @@
|
|||
;cur-col JSR2 ;cur-len JSR2 LTH2 ,&normal JCN ,&next-line JMP
|
||||
&normal
|
||||
;cur-col JSR2 INC2 .cursor/col STZ2
|
||||
;draw-statusbar-and-cursor JSR2
|
||||
;redraw-statusbar-and-cursor JSR2
|
||||
,&skip JMP
|
||||
&next-line #0000 .cursor/col STZ2
|
||||
;inc-row JSR2
|
||||
;ensure-visible-cursor JSR2
|
||||
;draw-cursor JSR2
|
||||
&skip BRK
|
||||
;redraw-cursor JSR2
|
||||
&skip ;return JMP2
|
||||
|
||||
( FIXME: handle long lines )
|
||||
@back ( -> )
|
||||
@go-back ( -> )
|
||||
;cur-col JSR2 #0001 LTH2 ,&next-line JCN
|
||||
;cur-col JSR2 #0001 SUB2 .cursor/col STZ2
|
||||
;draw-statusbar-and-cursor JSR2 BRK
|
||||
;redraw-statusbar-and-cursor JSR2 JMP2r
|
||||
&next-line
|
||||
;dec-row JSR2
|
||||
;cur-len JSR2 .cursor/col STZ2
|
||||
;ensure-visible-cursor JSR2 ( FIXME )
|
||||
;draw-cursor JSR2 BRK
|
||||
;redraw-cursor JSR2
|
||||
JMP2r
|
||||
|
||||
@back ( -> )
|
||||
;go-back JSR2 ;return JMP2
|
||||
|
||||
@up ( -> )
|
||||
;cur-abs-row JSR2 #0000 EQU2 ,&done JCN
|
||||
;dec-row JSR2
|
||||
;ensure-visible-cursor JSR2
|
||||
;draw-statusbar JSR2
|
||||
&done ;draw-cursor JSR2 BRK
|
||||
;redraw-statusbar JSR2
|
||||
&done ;redraw-cursor JSR2 ;return JMP2
|
||||
|
||||
@down ( -> )
|
||||
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
||||
;inc-row JSR2
|
||||
;ensure-visible-cursor JSR2
|
||||
;draw-statusbar JSR2
|
||||
&done ;draw-cursor JSR2 BRK
|
||||
;redraw-statusbar JSR2
|
||||
&done ;redraw-cursor JSR2 ;return JMP2
|
||||
|
||||
@center-view
|
||||
;term/rows LDZ2 INC2 #0002 DIV2 STH2k
|
||||
|
@ -311,7 +323,7 @@
|
|||
DUP2 .buffer/line-offset STZ2
|
||||
;abs-line JSR2 .buffer/offset STZ2
|
||||
&done
|
||||
;draw-all JSR2 BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@page-up ( -> )
|
||||
.term/rows LDZ2 #0002 SUB2 STH2k
|
||||
|
@ -326,7 +338,8 @@
|
|||
DUP2 .buffer/line-offset STZ2
|
||||
;abs-line JSR2 .buffer/offset STZ2
|
||||
&done
|
||||
;draw-all JSR2 BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
|
||||
@page-down
|
||||
;eof-is-visible JSR2 ,&near-eof JCN
|
||||
|
@ -335,11 +348,11 @@
|
|||
DUP2 .buffer/line-offset STZ2
|
||||
;abs-line JSR2 .buffer/offset STZ2
|
||||
.cursor/row LDZ2 STH2r ADD2 .cursor/row STZ2
|
||||
;draw-all JSR2 BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
&near-eof
|
||||
.buffer/line-count LDZ2 #0001 SUB2 ;set-abs-row JSR2
|
||||
;cur-len JSR2 .cursor/col STZ2
|
||||
;draw-cursor JSR2 BRK
|
||||
;redraw-cursor JSR2 ;return JMP2
|
||||
|
||||
@quit
|
||||
#01 .state/quitting STZ
|
||||
|
@ -347,8 +360,7 @@
|
|||
quit!
|
||||
&is-modified
|
||||
;messages/quit-prompt ;messages/null ;do-quit ;start-prompt JSR2
|
||||
;draw-prompt-and-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
@do-quit
|
||||
.tmp/data LDZ LIT 'n EQU ;quit-now JCN2
|
||||
|
@ -362,22 +374,19 @@
|
|||
@quit-now quit!
|
||||
|
||||
@ignore
|
||||
;draw-cursor JSR2
|
||||
BRK
|
||||
;draw-cursor JSR2 BRK
|
||||
|
||||
@insert ( c^ -> )
|
||||
#01 .state/modified STZ
|
||||
;cur-pos JSR2 ;shift-right JSR2
|
||||
;cur-col JSR2 INC2 .cursor/col STZ2
|
||||
;draw-all JSR2
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@insert-prompt ( c^ -> )
|
||||
.tmp/pos LDZ2 STH2k STA ( data[pos] <- c )
|
||||
INC2r #00 STH2kr STA ( data[pos+1] <- 0 )
|
||||
STH2r .tmp/pos STZ2 ( pos <- pos+1 )
|
||||
;draw-prompt-and-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
@insert-tab ( -> )
|
||||
#01 .state/modified STZ
|
||||
|
@ -389,7 +398,7 @@
|
|||
INC2 ,&loop JMP
|
||||
&done
|
||||
;cur-col JSR2 .config/tab-width LDZ2 ADD2 .cursor/col STZ2
|
||||
;draw-all JSR2 BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
&use-tabs
|
||||
#09 ;insert JMP2
|
||||
|
||||
|
@ -401,8 +410,7 @@
|
|||
;inc-row JSR2
|
||||
.buffer/line-count LDZ2k INC2 ROT STZ2
|
||||
;ensure-visible-cursor JSR2
|
||||
;draw-all JSR2
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@at-buffer-start ( -> bool^ )
|
||||
;cur-pos JSR2 ;data EQU2 JMP2r
|
||||
|
@ -419,18 +427,17 @@
|
|||
GTH2 JMP2r
|
||||
|
||||
@backspace ( -> )
|
||||
;cur-col JSR2 #01 LTH ,&skip JCN
|
||||
;cur-col JSR2 #0001 SUB2 .cursor/col STZ2
|
||||
.buffer/offset LDZ2 ;data EQU2 ,&skip JCN
|
||||
;go-back JSR2
|
||||
;delete JMP2
|
||||
&skip BRK
|
||||
&skip
|
||||
;redraw-cursor JSR2 ;return JMP2
|
||||
|
||||
@backspace-prompt ( -> )
|
||||
#00 .tmp/pos LDZ2 #0001 SUB2 ( 0 pos-1 )
|
||||
STH2k STA ( data[pos-1] <- 0 )
|
||||
STH2r .tmp/pos STZ2 ( pos <- pos-1 )
|
||||
;draw-prompt JSR2
|
||||
;draw-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
@delete ( -> )
|
||||
#01 .state/modified STZ
|
||||
|
@ -439,8 +446,8 @@
|
|||
;shift-left JSR2 ( [c] )
|
||||
STHr #0a NEQ ,¬-newline JCN
|
||||
.buffer/line-count LDZ2k #0001 SUB2 ROT STZ2
|
||||
¬-newline ;draw-all JSR2 BRK
|
||||
&skip ;draw-cursor JSR2 BRK
|
||||
¬-newline ;redraw-all JSR2 ;return JMP2
|
||||
&skip ;redraw-cursor JSR2 ;return JMP2
|
||||
|
||||
@escape ( -> )
|
||||
#01 .state/saw-esc STZ BRK
|
||||
|
@ -455,18 +462,17 @@
|
|||
DUP2 .buffer/line-offset STZ2
|
||||
;abs-line JSR2 .buffer/offset STZ2
|
||||
;cur-len JSR2 .cursor/col STZ2
|
||||
;draw-all JSR2 BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@goto-start ( -> )
|
||||
;zero-row JSR2
|
||||
#0000 .cursor/col STZ2
|
||||
;draw-all JSR2
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
|
||||
@goto-line ( -> )
|
||||
;messages/goto-line ;messages/null ;do-goto-line ;start-prompt JSR2
|
||||
;draw-prompt-and-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
@parse-decimal-number ( addr* -> n* ok^ )
|
||||
LDAk ,&non-empty JCN
|
||||
|
@ -492,15 +498,14 @@
|
|||
;move-to-message-line JSR2
|
||||
;messages/unknown-input ;print JSR2
|
||||
;tmp/data ;print JSR2
|
||||
BRK
|
||||
;return JMP2
|
||||
&ok
|
||||
#0001 SUB2 ( convert 1-indexing to 0-indexing )
|
||||
DUP2 .buffer/line-count LDZ2 LTH2 ,&within JCN
|
||||
POP2 ;goto-end JMP2
|
||||
&within
|
||||
;jump-to-line JSR2
|
||||
;draw-all JSR2
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@jump-to-line ( n* -> )
|
||||
.term/rows LDZ2 INC2 #0002 DIV2 LTH2k ( n rows/2 n<rows/2? ) ,&early JCN
|
||||
|
@ -519,14 +524,13 @@
|
|||
.buffer/line-offset STZ2 ( n o [n-o] )
|
||||
;abs-line JSR2 .buffer/offset STZ2 ( n [n-o] )
|
||||
#0000 .cursor/col STZ2 ( n [n-o] )
|
||||
( POP2 STH2r .cursor/row STZ2 )
|
||||
POP2r .cursor/row STZ2
|
||||
JMP2r
|
||||
|
||||
@ensure-visible-cursor
|
||||
;cur-rel-row JSR2 .term/rows LDZ2 LTH2 ,&noop JCN
|
||||
;cur-abs-row JSR2 ;jump-to-line JSR2
|
||||
;draw-all JSR2
|
||||
;redraw-all JSR2
|
||||
&noop JMP2r
|
||||
|
||||
@debug
|
||||
|
@ -557,8 +561,7 @@
|
|||
&is-active
|
||||
#00 .prompt/active STZ
|
||||
#00 .state/quitting STZ
|
||||
;draw-prompt-and-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
( when called vector should end in BRK )
|
||||
@finish-prompt ( -> )
|
||||
|
@ -566,14 +569,12 @@
|
|||
#0000 DIV
|
||||
&is-active
|
||||
#00 .prompt/active STZ
|
||||
;draw-prompt JSR2
|
||||
;draw-cursor JSR2
|
||||
;redraw-prompt-and-cursor JSR2
|
||||
.prompt/vector LDZ2 JMP2
|
||||
|
||||
@save
|
||||
;messages/save-prompt ;filename ;do-save ;start-prompt JSR2
|
||||
;draw-prompt-and-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
@do-save ( -> )
|
||||
.buffer/limit LDZ2 ;data SUB2 STH2 ( [size] )
|
||||
|
@ -590,30 +591,28 @@
|
|||
;messages/save-ok
|
||||
&finish
|
||||
;print JSR2 ;tmp/data ;print JSR2
|
||||
;draw-all JSR2
|
||||
;redraw-all JSR2
|
||||
.state/quitting LDZ ;quit-now JCN2
|
||||
BRK
|
||||
;return JMP2
|
||||
|
||||
@search ( -> )
|
||||
;messages/search-prompt ;messages/null ;do-search ;start-prompt JSR2
|
||||
;draw-prompt-and-cursor JSR2
|
||||
BRK
|
||||
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
||||
|
||||
@do-search ( -> )
|
||||
#01 .searching/active STZ
|
||||
;draw-all JSR2
|
||||
( ;move-to-next-match JMP2 )
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
|
||||
@toggle-color ( -> )
|
||||
.config/color LDZ2 #3733 EQU2 ,&wrap-around JCN
|
||||
.config/color LDZ2 #0100 ADD2 .config/color STZ2 ,&done JMP
|
||||
&wrap-around #3033 .config/color STZ2
|
||||
&done ;draw-all JSR2 BRK
|
||||
&done ;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@toggle-tabs ( -> )
|
||||
.config/insert-tabs LDZk #01 EOR SWP STZ
|
||||
;draw-statusbar-and-cursor JSR2 BRK
|
||||
;redraw-statusbar-and-cursor JSR2 ;return JMP2
|
||||
|
||||
( TODO: M-f and M-b for next/previous word )
|
||||
( M-n and M-p for next/previous paragraph )
|
||||
|
@ -679,13 +678,11 @@
|
|||
|
||||
@cancel-search
|
||||
#00 .searching/active STZ
|
||||
;draw-all JSR2
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@finish-search
|
||||
#00 .searching/active STZ
|
||||
;draw-all JSR2
|
||||
BRK
|
||||
;redraw-all JSR2 ;return JMP2
|
||||
|
||||
@move-to-next-match BRK
|
||||
@move-to-prev-match BRK
|
||||
|
@ -758,6 +755,24 @@
|
|||
@term-erase-all ( -> )
|
||||
ansi emit-2 emit-J JMP2r
|
||||
|
||||
@redraw-is-set ( n^ -> ok^ )
|
||||
.state/redraw LDZ AND JMP2r
|
||||
|
||||
@redraw-is-unset ( n^ -> ok^ )
|
||||
;redraw-is-set JSR2 #00 EQU JMP2r
|
||||
|
||||
@redraw-add ( n^ -> )
|
||||
.state/redraw LDZk ROT ORA SWP STZ JMP2r
|
||||
|
||||
@redraw-clear ( -> ) #00 .state/redraw STZ JMP2r
|
||||
@redraw-cursor ( -> ) #01 ;redraw-add JMP2
|
||||
@redraw-statusbar ( -> ) #02 ;redraw-add JMP2
|
||||
@redraw-statusbar-and-cursor ( -> ) #03 ;redraw-add JMP2
|
||||
@redraw-prompt ( -> ) #04 ;redraw-add JMP2
|
||||
@redraw-prompt-and-cursor ( -> ) #05 ;redraw-add JMP2
|
||||
@redraw-matches ( -> ) #08 ;redraw-add JMP2
|
||||
@redraw-all ( -> ) #1f ;redraw-add JMP2
|
||||
|
||||
( @offset-for-cur-row
|
||||
.buffer/offset LDZ2 ( offset )
|
||||
#0000 ;cur-rel-row JSR2 SUB2 STH2 ( offset [-k] )
|
||||
|
@ -819,10 +834,6 @@
|
|||
;emit-reset JSR2
|
||||
JMP2r
|
||||
|
||||
@draw-statusbar-and-cursor ( -> )
|
||||
;draw-statusbar JSR2
|
||||
;draw-cursor JMP2
|
||||
|
||||
@draw-prompt ( -> )
|
||||
;clear-message-line JSR2
|
||||
.prompt/active LDZ ,&is-active JCN
|
||||
|
@ -840,9 +851,9 @@
|
|||
|
||||
@draw-linenum ( n* -> )
|
||||
;emit-reset JSR2
|
||||
ansi .config/color LDZ2 emit emit ( LIT 'm emit ) emit-m
|
||||
ansi .config/color LDZ2 emit emit emit-m
|
||||
;emit-dec2-pad JSR2
|
||||
ansi ( LIT2 'm '0 emit emit ) emit-0 emit-m JMP2r
|
||||
ansi emit-0 emit-m JMP2r
|
||||
|
||||
@matches-at ( s* -> limit* )
|
||||
LIT2r :tmp/data
|
||||
|
@ -882,7 +893,7 @@
|
|||
.searching/active LDZ #00 EQU ,&return JCN ( )
|
||||
;emit-color-reverse JSR2
|
||||
|
||||
.term/lmargin LDZ2 ( #0000 ) ,&x STR2 #0000 ,&y STR2 ( x <- 0, y <- 0 )
|
||||
.term/lmargin LDZ2 ,&x STR2 #0000 ,&y STR2 ( x <- 0, y <- 0 )
|
||||
|
||||
.buffer/offset LDZ2 DUP2
|
||||
;screen-limit JSR2 SUB2 STH2 ( offset [-count] )
|
||||
|
@ -906,7 +917,7 @@
|
|||
ADD2 ADD2r ( offset+n [n-count] )
|
||||
,&loop JMP
|
||||
&newline ( offset [-count] )
|
||||
.term/lmargin LDZ2 ( #0000 ) ,&x STR2
|
||||
.term/lmargin LDZ2 ,&x STR2
|
||||
,&y LDR2 INC2 ,&y STR2
|
||||
INC2 INC2r
|
||||
,&loop JMP
|
||||
|
@ -924,22 +935,18 @@
|
|||
&next DEOkr INC2 ,&loop JMP
|
||||
|
||||
@emit-red ( -> )
|
||||
( ansi LIT '3 emit LIT '1 emit LIT 'm emit JMP2r )
|
||||
ansi emit-3 emit-1 emit-m JMP2r
|
||||
|
||||
@emit-reset ( -> )
|
||||
( ansi LIT '0 emit LIT 'm emit JMP2r )
|
||||
ansi emit-0 emit-m JMP2r
|
||||
|
||||
@emit-red-dollar ( -> )
|
||||
;emit-red JSR2 ( LIT '$ emit ) emit-$ ;emit-reset JMP2
|
||||
;emit-red JSR2 emit-$ ;emit-reset JMP2
|
||||
|
||||
@emit-color-reverse ( -> )
|
||||
( ansi .config/color LDZ2 emit emit LIT2 '7 '; emit emit LIT 'm emit JMP2r )
|
||||
ansi .config/color LDZ2 emit emit emit-; emit-7 emit-m JMP2r
|
||||
|
||||
@emit-color-bold ( -> )
|
||||
( ansi .config/color LDZ2 emit emit LIT2 '1 '; emit emit LIT 'm emit JMP2r )
|
||||
ansi .config/color LDZ2 emit emit emit-; emit-1 emit-m JMP2r
|
||||
|
||||
@draw-all ( -> )
|
||||
|
@ -976,15 +983,26 @@
|
|||
STH2kr .term/rows LDZ2 GTH2 ,&done JCN
|
||||
cr nl
|
||||
.term/lmargin LDZ2 ;term-move-right JSR2
|
||||
( LIT '~ emit ) emit-~ INC2r
|
||||
emit-~ INC2r
|
||||
,&eof-loop JMP
|
||||
&done POP2 POP2r POP2r
|
||||
;emit-reset JSR2
|
||||
;draw-matches JSR2
|
||||
;draw-statusbar JSR2
|
||||
;draw-prompt-and-cursor JSR2
|
||||
;draw-prompt JSR2
|
||||
;draw-cursor JSR2
|
||||
JMP2r
|
||||
|
||||
( handler completion code to do necessary drawing and BRK )
|
||||
@return ( -> )
|
||||
#10 ;redraw-is-set JSR2 ,&everything JCN
|
||||
#08 ;redraw-is-unset JSR2 ,&skip-8 JCN ;draw-matches JSR2
|
||||
&skip-8 #04 ;redraw-is-unset JSR2 ,&skip-4 JCN ;draw-prompt JSR2
|
||||
&skip-4 #02 ;redraw-is-unset JSR2 ,&skip-2 JCN ;draw-statusbar JSR2
|
||||
&skip-2 #01 ;redraw-is-unset JSR2 ,&skip-1 JCN ;draw-cursor JSR2
|
||||
&skip-1 BRK
|
||||
&everything ;draw-all JSR2 BRK
|
||||
|
||||
@str-copy ( src* dst* -> )
|
||||
STH2 ( src [dst] )
|
||||
&loop LDAk #00 EQU ,&done JCN
|
||||
|
@ -1115,16 +1133,11 @@
|
|||
&tabs INC2 .config/tab-width LDZ2 STH2 ADD2r ,&loop JMP
|
||||
|
||||
@cur-rel-row ( -> row* )
|
||||
( .cursor/row LDZ2 JMP2r )
|
||||
.cursor/row LDZ2 .buffer/line-offset LDZ2 SUB2 JMP2r
|
||||
|
||||
@set-abs-row ( n* -> )
|
||||
( .buffer/line-offset LDZ2 SUB2 .cursor/row STZ2 JMP2r )
|
||||
.cursor/row STZ2 JMP2r
|
||||
|
||||
( @set-rel-row ( n* -> )
|
||||
.cursor/row STZ2 JMP2r )
|
||||
|
||||
@zero-row ( -> )
|
||||
;data .buffer/offset STZ2
|
||||
#0000 .buffer/line-offset STZ2
|
||||
|
|
Loading…
Reference in New Issue