display line counts and cursor position

This commit is contained in:
~d6 2022-02-12 02:10:27 -05:00
parent 28704a9bfc
commit 652dac7830
1 changed files with 30 additions and 8 deletions

View File

@ -168,17 +168,20 @@
@bol
#00 ;cursor/col STA
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
( FIXME: handle long lines )
@eol
;cur-line JSR2 ;line-len JSR2 NIP ;cursor/col STA
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
( FIXME: handle long lines )
@forward
;cursor/col LDA pen-col GTH ,&skip JCN
;cursor/col LDA #01 ADD ;cursor/col STA
;draw-statusbar JSR2
;draw-cursor JSR2
&skip BRK
@ -186,12 +189,14 @@
@back
;cursor/col LDA #01 LTH ,&skip JCN
;cursor/col LDA #01 SUB ;cursor/col STA
;draw-statusbar JSR2
;draw-cursor JSR2
&skip BRK
@up
;cursor/row LDA #01 LTH ,&screen-up JCN
;cursor/row LDA #01 SUB ;cursor/row STA
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
&screen-up
;buffer/offset LDA2 DUP2 ;buffer/data EQU2 ,&done JCN
@ -199,18 +204,21 @@
&loop DUP2 ;buffer/data EQU2 ,&complete JCN
#0001 SUB2 LDAk #0a NEQ ,&loop JCN
INC2
&complete ;buffer/offset STA2 ;draw-all JSR2 BRK
&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 )
@down
;cursor/row LDA pen-line GTH ,&screen-down JCN
;cursor/row LDA #01 ADD ;cursor/row STA
;cursor/row LDA INC ;cursor/row STA
;draw-statusbar JSR2
;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/offset LDA2 ADD2 ;buffer/offset STA2
;buffer/line-offset LDA2k INC2 SWP2 STA2
;draw-all JSR2
BRK
@ -234,6 +242,7 @@
;draw-all JSR2
&skip BRK
( TODO: handle last line )
@newline ( c^ -> )
#0a ;cur-pos JSR2 ;shift-right JSR2
#00 ;cursor/col STA
@ -242,6 +251,7 @@
;draw-all JSR2
BRK
( TODO: handle first line )
@backspace ( -> )
;cur-pos JSR2 ;buffer/data EQU2 ,&skip JCN
;cursor/col LDA #00 EQU ,&prev-line JCN
@ -273,6 +283,7 @@
@goto-end ( FIXME )
@goto-start ( -> )
;buffer/data ;buffer/offset STA2
#0000 ;buffer/line-offset STA2
#00 ;cursor/col STA
#00 ;cursor/row STA
;draw-all JSR2
@ -295,7 +306,8 @@
&late ( n n-rows/2 lines-rows )
NIP2 ,&finish JCN
&finish ( n o )
SUB2k STH2
SUB2k STH2 DUP2
;buffer/line-offset STA2
;abs-line JSR2 ;buffer/offset STA2
#00 ;cursor/col STA
POP2 STH2r NIP ;cursor/row STA
@ -366,11 +378,18 @@
;messages/saved ;print JSR2
;filename ;print JSR2
#20 emit
LIT '[ emit
;buffer/limit LDA2 ;buffer/data SUB2 ;emit-dec2 JSR2
;messages/bytes ;print JSR2
#20 emit
;buffer/line-count LDA2 ;emit-dec2 JSR2
;messages/lines ;print JSR2
#20 emit
LIT '( emit
;cursor/col LDA ;emit-dec JSR2
LIT ', emit
;cur-abs-row JSR2 ;emit-dec2 JSR2
LIT ') emit
ansi LIT '0 emit LIT 'm emit
JMP2r
@ -383,7 +402,6 @@
@draw-all
;term-erase-all JSR2
;draw-statusbar JSR2
#00 #00 ;term-move-cursor JSR2
#00 STH
;buffer/offset LDA2
@ -394,6 +412,7 @@
&eol INCr STHkr last-line ( #17 ) GTH ,&eof JCN
cr nl INC2 ,&loop JMP
&eof POP2 POPr
;draw-statusbar JSR2
;draw-cursor JSR2
JMP2r
@ -453,6 +472,9 @@
@cur-pos ( -> s* )
;cur-line JSR2 #00 ;get-col JSR2 ADD2 JMP2r
@cur-abs-row ( -> n* )
;buffer/line-offset LDA2 #00 ;cursor/row LDA ADD2 JMP2r
@shift-right ( c^ addr* -> )
ROT STH ( addr [prev^] )
;buffer/limit LDA2 ( addr limit [prev^] )
@ -539,8 +561,8 @@
&do1 NIP ;emit-digit JSR2 JMP2r
@messages [ &input-error "input 20 "error 00
&bytes 20 "bytes 00
&lines 20 "lines 00
&bytes 20 "bytes, 00
&lines 20 "lines] 00
&saved "-- 20 00
&unsaved "** 20 00 ]