fix a bunch of navigation bugs
This commit is contained in:
parent
46f0f162eb
commit
ad2f91f329
107
femto.tal
107
femto.tal
|
@ -195,48 +195,45 @@
|
||||||
|
|
||||||
( FIXME: handle long lines )
|
( FIXME: handle long lines )
|
||||||
@forward
|
@forward
|
||||||
;cursor/col LDA pen-col GTH ,&skip JCN
|
;cur-pos JSR2 ;last-pos JSR2 GTH2 ,&skip JCN
|
||||||
;cursor/col LDA #01 ADD ;cursor/col STA
|
;cur-col JSR2 ;cur-last JSR2 GTH ,&next-line JCN
|
||||||
;draw-statusbar JSR2
|
;cur-col JSR2 INC ;cursor/col STA
|
||||||
|
;draw-statusbar JSR2 ;draw-cursor JSR2
|
||||||
|
,&skip JMP
|
||||||
|
&next-line #00 ;cursor/col STA ( TODO: need to ensure cursor is visible )
|
||||||
|
;cursor/row LDA INC ;cursor/row STA
|
||||||
|
;ensure-visible-cursor JSR2
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
&skip BRK
|
&skip BRK
|
||||||
|
|
||||||
( FIXME: handle long lines )
|
( FIXME: handle long lines )
|
||||||
@back
|
@back
|
||||||
;cursor/col LDA #01 LTH ,&skip JCN
|
;cur-col JSR2 #01 LTH ,&skip JCN
|
||||||
;cursor/col LDA #01 SUB ;cursor/col STA
|
;cur-col JSR2 #01 SUB ;cursor/col STA
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
&skip BRK
|
&skip BRK
|
||||||
|
|
||||||
|
( TODO: integrate ensure-visible-cursor to move by half-screens )
|
||||||
@up
|
@up
|
||||||
|
;cur-line-num JSR2 #0000 EQU2 ,&done JCN
|
||||||
;cursor/row LDA #01 LTH ,&screen-up JCN
|
;cursor/row LDA #01 LTH ,&screen-up JCN
|
||||||
;cursor/row LDA #01 SUB ;cursor/row STA
|
;cursor/row LDA #01 SUB ;cursor/row STA
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
;draw-cursor JSR2 BRK
|
;draw-cursor JSR2 BRK
|
||||||
&screen-up
|
&screen-up
|
||||||
;buffer/offset LDA2 DUP2 ;buffer/data EQU2 ,&done JCN
|
;cur-line-num JSR2 #0001 SUB2
|
||||||
#0001 SUB2
|
;jump-to-line JSR2
|
||||||
&loop DUP2 ;buffer/data EQU2 ,&complete JCN
|
;draw-all JSR2
|
||||||
#0001 SUB2 LDAk #0a NEQ ,&loop JCN
|
&done BRK
|
||||||
INC2
|
|
||||||
&complete ;buffer/offset STA2
|
|
||||||
;buffer/line-offset LDA2k #0001 SUB2 SWP2 STA2
|
|
||||||
;draw-all JSR2 BRK
|
|
||||||
&done POP2 BRK
|
|
||||||
|
|
||||||
( FIXME: need to handle 'end of buffer' stuff )
|
( FIXME: need to handle 'end of buffer' stuff )
|
||||||
@down
|
@down
|
||||||
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
||||||
;cursor/row LDA pen-line GTH ,&screen-down JCN
|
|
||||||
;cursor/row LDA INC ;cursor/row STA
|
;cursor/row LDA INC ;cursor/row STA
|
||||||
|
;ensure-visible-cursor JSR2
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
;draw-cursor JSR2 BRK
|
;draw-cursor JSR2 BRK
|
||||||
&screen-down
|
|
||||||
#00 ;rel-line JSR2 ;line-len JSR2 INC2 ( add 1 for line ending )
|
|
||||||
;buffer/offset LDA2 ADD2 ;buffer/offset STA2
|
|
||||||
;buffer/line-offset LDA2k INC2 SWP2 STA2
|
|
||||||
;draw-all JSR2
|
|
||||||
&done BRK
|
&done BRK
|
||||||
|
|
||||||
@quit quit!
|
@quit quit!
|
||||||
|
@ -244,18 +241,17 @@
|
||||||
@ignore BRK
|
@ignore BRK
|
||||||
|
|
||||||
@insert ( c^ -> )
|
@insert ( c^ -> )
|
||||||
;cursor/col LDA pen-col GTH ,&skip JCN ( FIXME )
|
|
||||||
;cur-pos JSR2 ;shift-right JSR2
|
;cur-pos JSR2 ;shift-right JSR2
|
||||||
;cursor/col LDA INC ;cursor/col STA
|
;cur-col JSR2 INC ;cursor/col STA
|
||||||
;draw-all JSR2
|
;draw-all JSR2
|
||||||
&skip BRK
|
BRK
|
||||||
|
|
||||||
@overwrite ( c^ -> )
|
( @overwrite ( c^ -> )
|
||||||
;cursor/col LDA pen-col GTH ,&skip JCN ( FIXME )
|
;cursor/col LDA pen-col GTH ,&skip JCN ( FIXME )
|
||||||
;cur-pos JSR2 STA
|
;cur-pos JSR2 STA
|
||||||
;cursor/col LDA #01 ADD ;cursor/col STA
|
;cursor/col LDA #01 ADD ;cursor/col STA
|
||||||
;draw-all JSR2
|
;draw-all JSR2
|
||||||
&skip BRK
|
&skip BRK )
|
||||||
|
|
||||||
( TODO: handle last line )
|
( TODO: handle last line )
|
||||||
@newline ( c^ -> )
|
@newline ( c^ -> )
|
||||||
|
@ -276,8 +272,7 @@
|
||||||
@backspace ( -> )
|
@backspace ( -> )
|
||||||
;at-buffer-start JSR2 ,&skip JCN
|
;at-buffer-start JSR2 ,&skip JCN
|
||||||
;at-line-start JSR2 ,&prev-line JCN
|
;at-line-start JSR2 ,&prev-line JCN
|
||||||
;get-col JSR2 #01 SUB ;cursor/col STA
|
;cur-col JSR2 #01 SUB ;cursor/col STA
|
||||||
( ;cursor/col LDA #01 SUB ;cursor/col STA )
|
|
||||||
,&finish JMP
|
,&finish JMP
|
||||||
&prev-line ( TODO: what if row=0 but offset>0 ? )
|
&prev-line ( TODO: what if row=0 but offset>0 ? )
|
||||||
;cursor/row LDA #01 SUB ;cursor/row STA
|
;cursor/row LDA #01 SUB ;cursor/row STA
|
||||||
|
@ -323,7 +318,7 @@
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@goto-line ( -> )
|
@goto-line ( -> )
|
||||||
#0060 ;jump-to-line JSR2
|
#0016 ;jump-to-line JSR2
|
||||||
;draw-all JSR2 BRK
|
;draw-all JSR2 BRK
|
||||||
|
|
||||||
@jump-to-line ( n* -> )
|
@jump-to-line ( n* -> )
|
||||||
|
@ -335,17 +330,23 @@
|
||||||
,&late JCN ( n n-rows/2 lines-rows )
|
,&late JCN ( n n-rows/2 lines-rows )
|
||||||
POP2 ,&finish JMP
|
POP2 ,&finish JMP
|
||||||
&early ( n rows/2 )
|
&early ( n rows/2 )
|
||||||
POP2 ,&finish JCN
|
POP2 #0000 ,&finish JMP ( n 0000 )
|
||||||
&late ( n n-rows/2 lines-rows )
|
&late ( n n-rows/2 lines-rows )
|
||||||
NIP2 ,&finish JCN
|
NIP2
|
||||||
&finish ( n o )
|
&finish ( n o )
|
||||||
SUB2k STH2 DUP2
|
SUB2k STH2 DUP2 ( n o o [n-o] )
|
||||||
;buffer/line-offset STA2
|
;buffer/line-offset STA2 ( n o [n-o] )
|
||||||
;abs-line JSR2 ;buffer/offset STA2
|
;abs-line JSR2 ;buffer/offset STA2 ( n [n-o] )
|
||||||
#00 ;cursor/col STA
|
#00 ;cursor/col STA ( n [n-o] )
|
||||||
POP2 STH2r NIP ;cursor/row STA
|
POP2 STH2r NIP ;cursor/row STA ( )
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
@ensure-visible-cursor
|
||||||
|
;cursor/row LDA height LTH ,&noop JCN
|
||||||
|
;cur-line-num JSR2 ;jump-to-line JSR2
|
||||||
|
;draw-all JSR2
|
||||||
|
&noop JMP2r
|
||||||
|
|
||||||
@refresh
|
@refresh
|
||||||
;draw-all JSR2 BRK
|
;draw-all JSR2 BRK
|
||||||
|
|
||||||
|
@ -404,7 +405,7 @@
|
||||||
ansi LIT '2 emit LIT 'J emit JMP2r
|
ansi LIT '2 emit LIT 'J emit JMP2r
|
||||||
|
|
||||||
@draw-cursor
|
@draw-cursor
|
||||||
;get-col JSR2 ;get-row JSR2
|
;cur-col JSR2 ;cur-row JSR2
|
||||||
;term-move-cursor JSR2 JMP2r
|
;term-move-cursor JSR2 JMP2r
|
||||||
|
|
||||||
@draw-statusbar
|
@draw-statusbar
|
||||||
|
@ -428,7 +429,7 @@
|
||||||
;messages/lines ;print JSR2
|
;messages/lines ;print JSR2
|
||||||
#20 emit
|
#20 emit
|
||||||
LIT '( emit
|
LIT '( emit
|
||||||
;cursor/col LDA INC ;emit-dec JSR2
|
;cur-col JSR2 INC ;emit-dec JSR2
|
||||||
LIT ', emit
|
LIT ', emit
|
||||||
;cur-abs-row JSR2 INC2 ;emit-dec2 JSR2
|
;cur-abs-row JSR2 INC2 ;emit-dec2 JSR2
|
||||||
LIT ') emit
|
LIT ') emit
|
||||||
|
@ -482,6 +483,9 @@
|
||||||
@cur-len ( -> n* )
|
@cur-len ( -> n* )
|
||||||
;cur-line JSR2 ;line-len JSR2 JMP2r
|
;cur-line JSR2 ;line-len JSR2 JMP2r
|
||||||
|
|
||||||
|
@cur-last ( -> n* )
|
||||||
|
;cur-line JSR2 ;line-len JSR2 #0001 SUB2 NIP JMP2r
|
||||||
|
|
||||||
@line-len ( s* -> n* )
|
@line-len ( s* -> n* )
|
||||||
#0000 STH2
|
#0000 STH2
|
||||||
&loop LDAk #00 EQU ,&end JCN
|
&loop LDAk #00 EQU ,&end JCN
|
||||||
|
@ -520,8 +524,11 @@
|
||||||
@cur-line ( -> s* )
|
@cur-line ( -> s* )
|
||||||
;cursor/row LDA ;rel-line JSR2 JMP2r
|
;cursor/row LDA ;rel-line JSR2 JMP2r
|
||||||
|
|
||||||
|
@cur-line-num ( -> n* )
|
||||||
|
#00 ;cursor/row LDA ;buffer/line-offset LDA2 ADD2 JMP2r
|
||||||
|
|
||||||
@cur-pos ( -> s* )
|
@cur-pos ( -> s* )
|
||||||
;cur-line JSR2 #00 ;get-col JSR2 ADD2 JMP2r
|
;cur-line JSR2 #00 ;cur-col JSR2 ADD2 JMP2r
|
||||||
|
|
||||||
@cur-abs-row ( -> n* )
|
@cur-abs-row ( -> n* )
|
||||||
;buffer/line-offset LDA2 #00 ;cursor/row LDA ADD2 JMP2r
|
;buffer/line-offset LDA2 #00 ;cursor/row LDA ADD2 JMP2r
|
||||||
|
@ -531,8 +538,7 @@
|
||||||
|
|
||||||
@shift-right ( c^ addr* -> )
|
@shift-right ( c^ addr* -> )
|
||||||
ROT STH ( addr [prev^] )
|
ROT STH ( addr [prev^] )
|
||||||
;buffer/limit LDA2 ( addr limit [prev^] )
|
;last-pos JSR2 SWP2 ( last addr [prev^] )
|
||||||
#0001 SUB2 SWP2 ( last addr [prev^] )
|
|
||||||
&loop LTH2k ,&done JCN ( last addr [prev^] )
|
&loop LTH2k ,&done JCN ( last addr [prev^] )
|
||||||
LDAk STH SWPr ( last addr [prev^ curr^] )
|
LDAk STH SWPr ( last addr [prev^ curr^] )
|
||||||
DUP2 STHr ( last addr addr prev^ [curr^] )
|
DUP2 STHr ( last addr addr prev^ [curr^] )
|
||||||
|
@ -546,8 +552,7 @@
|
||||||
|
|
||||||
( TODO: change last/addr order and GTH -> LTH to remove hack )
|
( TODO: change last/addr order and GTH -> LTH to remove hack )
|
||||||
@shift-left ( addr* -> )
|
@shift-left ( addr* -> )
|
||||||
;buffer/limit LDA2 ( addr limit )
|
;last-pos JSR2 SWP2 ( last addr )
|
||||||
#0001 SUB2 SWP2 ( last addr )
|
|
||||||
&loop GTH2k ,&next JCN ( last addr )
|
&loop GTH2k ,&next JCN ( last addr )
|
||||||
,&done JMP ( last addr )
|
,&done JMP ( last addr )
|
||||||
&next DUP2 INC2 LDAk ( last addr addr+1 c1^ )
|
&next DUP2 INC2 LDAk ( last addr addr+1 c1^ )
|
||||||
|
@ -559,13 +564,13 @@
|
||||||
#00 ;buffer/limit LDA2 STA ( ensure null termination )
|
#00 ;buffer/limit LDA2 STA ( ensure null termination )
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
( TODO: should be using get-col and get-row almost everywhere )
|
( TODO: should be using cur-col and cur-row almost everywhere )
|
||||||
( otherwise, bugs! )
|
( otherwise, bugs! )
|
||||||
|
|
||||||
@get-col
|
@cur-col
|
||||||
;cursor/col LDA ;cur-len JSR2 NIP ;min JSR2 JMP2r
|
;cursor/col LDA ;cur-len JSR2 NIP ;min JSR2 JMP2r
|
||||||
|
|
||||||
@get-row
|
@cur-row
|
||||||
;cursor/row LDA JMP2r
|
;cursor/row LDA JMP2r
|
||||||
|
|
||||||
@last-pos
|
@last-pos
|
||||||
|
@ -577,17 +582,17 @@
|
||||||
@fits-in-one-screen ( -> bool^ )
|
@fits-in-one-screen ( -> bool^ )
|
||||||
;buffer/line-count LDA2 ;term/rows LDA2 INC2 LTH2 JMP2r
|
;buffer/line-count LDA2 ;term/rows LDA2 INC2 LTH2 JMP2r
|
||||||
|
|
||||||
@doc-start ( -> s* ) ;buffer/data JMP2r
|
( @doc-start ( -> s* ) ;buffer/data JMP2r
|
||||||
@doc-limit ( -> s* ) ;buffer/limit LDA2 JMP2r
|
@doc-limit ( -> s* ) ;buffer/limit LDA2 JMP2r
|
||||||
@doc-last ( -> s* ) ;buffer/limit LDA2 #0001 SUB2 JMP2r
|
@doc-last ( -> s* ) ;buffer/limit LDA2 #0001 SUB2 JMP2r )
|
||||||
|
|
||||||
@page-start ( -> s* ) ;buffer/offset LDA2 JMP2r
|
( @page-start ( -> s* ) ;buffer/offset LDA2 JMP2r
|
||||||
@page-limit ( -> s* ) height ;rel-line JSR2 JMP2r
|
@page-limit ( -> s* ) height ;rel-line JSR2 JMP2r
|
||||||
@page-last ( -> s* ) height ;rel-line JSR2 #0001 SUB2 JMP2r
|
@page-last ( -> s* ) height ;rel-line JSR2 #0001 SUB2 JMP2r )
|
||||||
|
|
||||||
@line-start ( -> s* ) ;cursor/row LDA ;rel-line JSR2 JMP2r
|
( @line-start ( -> s* ) ;cursor/row LDA ;rel-line JSR2 JMP2r
|
||||||
@line-limit ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 JMP2r
|
@line-limit ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 JMP2r
|
||||||
@line-last ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 #0001 SUB2 JMP2r
|
@line-last ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 #0001 SUB2 JMP2r )
|
||||||
|
|
||||||
@mod-div ( x^ y^ -> x%d x/y )
|
@mod-div ( x^ y^ -> x%d x/y )
|
||||||
DIVk STHk MUL SUB STHr JMP2r
|
DIVk STHk MUL SUB STHr JMP2r
|
||||||
|
|
Loading…
Reference in New Issue