converted to absolute cursor, fixed a lot of bugs
This commit is contained in:
parent
42ea10b6f9
commit
df70eb0848
103
femto.tal
103
femto.tal
|
@ -281,14 +281,10 @@
|
||||||
|
|
||||||
@up ( -> )
|
@up ( -> )
|
||||||
;cur-abs-row JSR2 #0000 EQU2 ,&done JCN
|
;cur-abs-row JSR2 #0000 EQU2 ,&done JCN
|
||||||
;cur-rel-row JSR2 #0001 LTH2 ,&screen-up JCN
|
|
||||||
;dec-row JSR2
|
;dec-row JSR2
|
||||||
|
;ensure-visible-cursor JSR2
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
&done ;draw-cursor JSR2 BRK
|
&done ;draw-cursor JSR2 BRK
|
||||||
&screen-up
|
|
||||||
;cur-abs-row JSR2 #0001 SUB2
|
|
||||||
;jump-to-line JSR2
|
|
||||||
;draw-all JSR2 BRK
|
|
||||||
|
|
||||||
@down ( -> )
|
@down ( -> )
|
||||||
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
||||||
|
@ -297,31 +293,42 @@
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
&done ;draw-cursor JSR2 BRK
|
&done ;draw-cursor JSR2 BRK
|
||||||
|
|
||||||
|
@center-view
|
||||||
|
;term/rows LDZ2 INC2 #0002 DIV2 STH2k
|
||||||
|
.cursor/row LDZ2 LTH2 ,&standard JCN
|
||||||
|
POP2r
|
||||||
|
#0000 .buffer/line-offset STZ2
|
||||||
|
;data .buffer/offset STZ2
|
||||||
|
,&done JMP
|
||||||
|
&standard
|
||||||
|
.cursor/row LDZ2 STH2r SUB2
|
||||||
|
DUP2 .buffer/line-offset STZ2
|
||||||
|
;abs-line JSR2 .buffer/offset STZ2
|
||||||
|
&done
|
||||||
|
;draw-all JSR2 BRK
|
||||||
|
|
||||||
@page-up ( -> )
|
@page-up ( -> )
|
||||||
;bof-is-visible JSR2 ,&at-bof JCN
|
.term/rows LDZ2 #0002 SUB2 STH2k
|
||||||
.buffer/line-offset LDZ2
|
.buffer/line-offset LDZ2 LTH2 ,&move-full JCN
|
||||||
.term/rows LDZ2 #0003 SUB2
|
POP2r
|
||||||
LTH2k ,&near-bof JCN
|
|
||||||
SUB2 DUP2 ;abs-line JSR2 .buffer/offset STZ2
|
|
||||||
.buffer/line-offset STZ2
|
|
||||||
;ensure-visible-cursor JSR2
|
|
||||||
;draw-all JSR2 BRK
|
|
||||||
&near-bof POP2 POP2
|
|
||||||
;zero-row JSR2
|
;zero-row JSR2
|
||||||
#0000 .cursor/col STZ2
|
#0000 .cursor/col STZ2
|
||||||
|
,&done JMP
|
||||||
|
&move-full
|
||||||
|
.cursor/row LDZ2 STH2kr SUB2 .cursor/row STZ2
|
||||||
|
.buffer/line-offset LDZ2 STH2r SUB2
|
||||||
|
DUP2 .buffer/line-offset STZ2
|
||||||
|
;abs-line JSR2 .buffer/offset STZ2
|
||||||
|
&done
|
||||||
;draw-all JSR2 BRK
|
;draw-all JSR2 BRK
|
||||||
&at-bof
|
|
||||||
;zero-row JSR2
|
|
||||||
#0000 .cursor/col STZ2
|
|
||||||
;draw-cursor JSR2 BRK
|
|
||||||
|
|
||||||
@page-down
|
@page-down
|
||||||
;eof-is-visible JSR2 ,&near-eof JCN
|
;eof-is-visible JSR2 ,&near-eof JCN
|
||||||
.buffer/line-offset LDZ2
|
.term/rows LDZ2 #0002 SUB2 STH2k
|
||||||
.term/rows LDZ2 ADD2 #0003 SUB2
|
.buffer/line-offset LDZ2 ADD2
|
||||||
DUP2 ;abs-line JSR2 .buffer/offset STZ2
|
DUP2 .buffer/line-offset STZ2
|
||||||
.buffer/line-offset STZ2
|
;abs-line JSR2 .buffer/offset STZ2
|
||||||
;ensure-visible-cursor JSR2
|
.cursor/row LDZ2 STH2r ADD2 .cursor/row STZ2
|
||||||
;draw-all JSR2 BRK
|
;draw-all JSR2 BRK
|
||||||
&near-eof
|
&near-eof
|
||||||
.buffer/line-count LDZ2 #0001 SUB2 ;set-abs-row JSR2
|
.buffer/line-count LDZ2 #0001 SUB2 ;set-abs-row JSR2
|
||||||
|
@ -411,23 +418,6 @@
|
||||||
;delete JMP2
|
;delete JMP2
|
||||||
&skip BRK
|
&skip BRK
|
||||||
|
|
||||||
( @backspace ( -> )
|
|
||||||
#01 .state/modified STZ
|
|
||||||
;at-buffer-start JSR2 ,&skip JCN
|
|
||||||
;at-line-start JSR2 ,&prev-line JCN
|
|
||||||
;cur-col JSR2 #0001 SUB2 .cursor/col STZ2
|
|
||||||
,&finish JMP
|
|
||||||
&prev-line
|
|
||||||
;cur-abs-row JSR2 #0001 SUB2
|
|
||||||
;jump-to-line JSR2 ( TODO: fix weird eof behavior )
|
|
||||||
;cur-len JSR2 .cursor/col STZ2
|
|
||||||
.buffer/line-count LDZ2k #0001 SUB2 ROT STZ2
|
|
||||||
&finish
|
|
||||||
;cur-pos JSR2 ;shift-left JSR2
|
|
||||||
;draw-all JSR2 BRK
|
|
||||||
&skip
|
|
||||||
;draw-cursor JSR2 BRK )
|
|
||||||
|
|
||||||
@backspace-prompt ( -> )
|
@backspace-prompt ( -> )
|
||||||
#00 .tmp/pos LDZ2 #0001 SUB2 ( 0 pos-1 )
|
#00 .tmp/pos LDZ2 #0001 SUB2 ( 0 pos-1 )
|
||||||
STH2k STA ( data[pos-1] <- 0 )
|
STH2k STA ( data[pos-1] <- 0 )
|
||||||
|
@ -450,12 +440,11 @@
|
||||||
#01 .state/saw-esc STZ BRK
|
#01 .state/saw-esc STZ BRK
|
||||||
|
|
||||||
@goto-end ( -> )
|
@goto-end ( -> )
|
||||||
;more-than-one-screen JSR2 ,&large JCN
|
|
||||||
.buffer/line-count LDZ2 #0001 SUB2 .cursor/row STZ2
|
.buffer/line-count LDZ2 #0001 SUB2 .cursor/row STZ2
|
||||||
#0000 ,&continue JMP
|
.buffer/line-count LDZ2 .term/rows LDZ2 LTH2k ,&use-zero JCN
|
||||||
&large
|
SUB2 #0002 ADD2 ,&continue JMP
|
||||||
.term/rows LDZ2 #0001 SUB2 .cursor/row STZ2
|
&use-zero
|
||||||
.buffer/line-count LDZ2 .term/rows LDZ2 SUB2
|
POP2 POP2 #0000
|
||||||
&continue
|
&continue
|
||||||
DUP2 .buffer/line-offset STZ2
|
DUP2 .buffer/line-offset STZ2
|
||||||
;abs-line JSR2 .buffer/offset STZ2
|
;abs-line JSR2 .buffer/offset STZ2
|
||||||
|
@ -508,7 +497,7 @@
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@jump-to-line ( n* -> )
|
@jump-to-line ( n* -> )
|
||||||
.term/rows LDZ2 #0002 DIV2 LTH2k ( n rows/2 n<rows/2? ) ,&early JCN
|
.term/rows LDZ2 INC2 #0002 DIV2 LTH2k ( n rows/2 n<rows/2? ) ,&early JCN
|
||||||
OVR2 SWP2 SUB2 ( n n-rows/2 )
|
OVR2 SWP2 SUB2 ( n n-rows/2 )
|
||||||
.buffer/line-count LDZ2 ( n n-rows/2 lines )
|
.buffer/line-count LDZ2 ( n n-rows/2 lines )
|
||||||
.term/rows LDZ2 SUB2 ( n n-rows/2 lines-rows )
|
.term/rows LDZ2 SUB2 ( n n-rows/2 lines-rows )
|
||||||
|
@ -524,7 +513,8 @@
|
||||||
.buffer/line-offset STZ2 ( n o [n-o] )
|
.buffer/line-offset STZ2 ( n o [n-o] )
|
||||||
;abs-line JSR2 .buffer/offset STZ2 ( n [n-o] )
|
;abs-line JSR2 .buffer/offset STZ2 ( n [n-o] )
|
||||||
#0000 .cursor/col STZ2 ( n [n-o] )
|
#0000 .cursor/col STZ2 ( n [n-o] )
|
||||||
POP2 STH2r .cursor/row STZ2
|
( POP2 STH2r .cursor/row STZ2 )
|
||||||
|
POP2r .cursor/row STZ2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@ensure-visible-cursor
|
@ensure-visible-cursor
|
||||||
|
@ -533,9 +523,6 @@
|
||||||
;draw-all JSR2
|
;draw-all JSR2
|
||||||
&noop JMP2r
|
&noop JMP2r
|
||||||
|
|
||||||
@refresh
|
|
||||||
;draw-all JSR2 BRK
|
|
||||||
|
|
||||||
@debug
|
@debug
|
||||||
;messages/rel-line-error ;error! JMP2
|
;messages/rel-line-error ;error! JMP2
|
||||||
|
|
||||||
|
@ -697,7 +684,7 @@
|
||||||
.Console/read DEI #05 EQU ( C-e ) ;eol JCN2
|
.Console/read DEI #05 EQU ( C-e ) ;eol JCN2
|
||||||
.Console/read DEI #06 EQU ( C-f ) ;forward JCN2
|
.Console/read DEI #06 EQU ( C-f ) ;forward JCN2
|
||||||
.Console/read DEI #09 EQU ( \t ) ;insert-tab JCN2
|
.Console/read DEI #09 EQU ( \t ) ;insert-tab JCN2
|
||||||
.Console/read DEI #0c EQU ( C-l ) ;refresh JCN2
|
.Console/read DEI #0c EQU ( C-l ) ;center-view JCN2
|
||||||
.Console/read DEI #0d EQU ( \r ) ;newline JCN2
|
.Console/read DEI #0d EQU ( \r ) ;newline JCN2
|
||||||
.Console/read DEI #0e EQU ( C-n ) ;down JCN2
|
.Console/read DEI #0e EQU ( C-n ) ;down JCN2
|
||||||
.Console/read DEI #0f EQU ( C-o ) ;save JCN2
|
.Console/read DEI #0f EQU ( C-o ) ;save JCN2
|
||||||
|
@ -962,7 +949,9 @@
|
||||||
¬-found ;messages/rel-line-error ;error! JMP2
|
¬-found ;messages/rel-line-error ;error! JMP2
|
||||||
|
|
||||||
@cur-line ( -> s* )
|
@cur-line ( -> s* )
|
||||||
;cur-rel-row JSR2 ;rel-line JMP2
|
;cur-rel-row JSR2 .term/rows LDZ2 LTH2 ,&safe JCN
|
||||||
|
.cursor/row LDZ2 ;abs-line JMP2
|
||||||
|
&safe ;cur-rel-row JSR2 ;rel-line JMP2
|
||||||
|
|
||||||
@cur-pos ( -> s* )
|
@cur-pos ( -> s* )
|
||||||
;cur-line JSR2 ;cur-col JSR2 ADD2 JMP2r
|
;cur-line JSR2 ;cur-col JSR2 ADD2 JMP2r
|
||||||
|
@ -1013,10 +1002,12 @@
|
||||||
&tabs INC2 .config/tab-width LDZ2 STH2 ADD2r ,&loop JMP
|
&tabs INC2 .config/tab-width LDZ2 STH2 ADD2r ,&loop JMP
|
||||||
|
|
||||||
@cur-rel-row ( -> row* )
|
@cur-rel-row ( -> row* )
|
||||||
.cursor/row LDZ2 JMP2r
|
( .cursor/row LDZ2 JMP2r )
|
||||||
|
.cursor/row LDZ2 .buffer/line-offset LDZ2 SUB2 JMP2r
|
||||||
|
|
||||||
@set-abs-row ( n* -> )
|
@set-abs-row ( n* -> )
|
||||||
.buffer/line-offset LDZ2 SUB2 .cursor/row STZ2 JMP2r
|
( .buffer/line-offset LDZ2 SUB2 .cursor/row STZ2 JMP2r )
|
||||||
|
.cursor/row STZ2 JMP2r
|
||||||
|
|
||||||
( @set-rel-row ( n* -> )
|
( @set-rel-row ( n* -> )
|
||||||
.cursor/row STZ2 JMP2r )
|
.cursor/row STZ2 JMP2r )
|
||||||
|
@ -1036,8 +1027,8 @@
|
||||||
@last-pos ( -> addr* )
|
@last-pos ( -> addr* )
|
||||||
.buffer/limit LDZ2 #0001 SUB2 JMP2r
|
.buffer/limit LDZ2 #0001 SUB2 JMP2r
|
||||||
|
|
||||||
@more-than-one-screen ( -> bool^ )
|
( @more-than-one-screen ( -> bool^ )
|
||||||
.buffer/line-count LDZ2 .term/rows LDZ2 GTH2 JMP2r
|
.buffer/line-count LDZ2 .term/rows LDZ2 GTH2 JMP2r )
|
||||||
|
|
||||||
( @fits-in-one-screen ( -> bool^ )
|
( @fits-in-one-screen ( -> bool^ )
|
||||||
.buffer/line-count LDZ2 .term/rows LDZ2 INC2 LTH2 JMP2r )
|
.buffer/line-count LDZ2 .term/rows LDZ2 INC2 LTH2 JMP2r )
|
||||||
|
|
Loading…
Reference in New Issue