fix more bugs, tab toggling

This commit is contained in:
~d6 2022-03-25 00:12:09 -04:00
parent ef80d8844b
commit d490644bac
1 changed files with 41 additions and 35 deletions

View File

@ -124,7 +124,7 @@
#0006 .term/lmargin STZ2
#0004 .config/tab-width STZ2
#01 .config/insert-tabs STZ
#00 .config/insert-tabs STZ
#3333 .config/color STZ2
;data .buffer/offset STZ2
@ -147,10 +147,6 @@
&done POP2 nl
dbg BRK
( error messages )
@term-size-parse-error "error 20 "parsing 20 "term 20 "size 00
@rel-line-error "invalid 20 "relative 20 "line 20 "number 00
@open-file ( filename* -> )
.File/name DEO2
#f000 .File/length DEO2
@ -165,7 +161,6 @@
JMP2r
@setup-terminal-size ( -> )
( ;setup-80x24 JMP2 )
#03e7 #03e7 ;term-move-cursor JSR2
;term-get-cursor-position JSR2
;tmp/data .tmp/pos STZ2
@ -200,25 +195,19 @@
;draw-all JSR2
BRK
&parse-error POP .tmp/data LDZ2
;term-size-parse-error ;error! JMP2
;messages/term-size-parse-error ;error! JMP2
@setup-linecount ( -> )
;data LIT2r 0001
&loop DUP2 .buffer/limit LDZ2 EQU2 ,&done JCN
LDAk #00 EQU ,&done JCN
LDAk #0a NEQ JMP INC2r
LDAk #09 NEQ ,&next JCN #01 .config/insert-tabs STZ
&next LDAk #0a NEQ JMP INC2r
INC2 ,&loop JMP
&done POP2
STH2r .buffer/line-count STZ2
JMP2r
@setup-80x24 ( -> )
#0050 .term/cols STZ2
#0014 .term/rows STZ2
;on-key .Console/vector DEO2
;draw-all JSR2
JMP2r
@read-filename ( -> )
#12 DEI #0a EQU ,&execute JCN ( did we read \n ? )
#12 DEI .tmp/pos LDZ2 STA ( no, so save in buffer )
@ -234,21 +223,19 @@
@bol ( -> )
#0000 .cursor/col STZ2
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
;draw-statusbar-and-cursor JSR2 BRK
( FIXME: handle long lines )
@eol ( -> )
;cur-line JSR2 ;line-len JSR2 .cursor/col STZ2
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
;draw-statusbar-and-cursor JSR2 BRK
( FIXME: handle long lines )
@forward ( -> )
;cur-pos JSR2 ;last-pos JSR2 GTH2 ,&skip JCN
;cur-col JSR2 ;cur-last JSR2 GTH2 ,&next-line JCN
;cur-col JSR2 INC2 .cursor/col STZ2
;draw-statusbar JSR2 ;draw-cursor JSR2
;draw-statusbar-and-cursor JSR2
,&skip JMP
&next-line #0000 .cursor/col STZ2
;inc-row JSR2
@ -260,8 +247,7 @@
@back ( -> )
;cur-col JSR2 #01 LTH ,&skip JCN
;cur-col JSR2 #0001 SUB2 .cursor/col STZ2
;draw-statusbar JSR2
;draw-cursor JSR2
;draw-statusbar-and-cursor JSR2
&skip BRK
@up ( -> )
@ -513,11 +499,10 @@
&noop JMP2r
@refresh
;rel-line-error ;error! JMP2 ( FIXME )
;draw-all JSR2 BRK
@debug
;rel-line-error ;error! JMP2
;messages/rel-line-error ;error! JMP2
@move-to-message-line ( -> )
#0000 .term/rows LDZ2 #0002 ADD2 ;term-move-cursor JMP2
@ -587,6 +572,10 @@
&wrap-around #3033 .config/color STZ2
&done ;draw-all JSR2 BRK
@toggle-tabs ( -> )
.config/insert-tabs LDZk #01 EOR SWP STZ
;draw-statusbar-and-cursor JSR2 BRK
@tmp-file-name "file.tmp 00
( TODO: M-f and M-b for next/previous word )
@ -596,8 +585,9 @@
#00 .state/saw-esc STZ
.Console/read DEI LIT '< EQU ( M-< ) ;goto-start JCN2
.Console/read DEI LIT '> EQU ( M-> ) ;goto-end JCN2
.Console/read DEI LIT 'c EQU ( M-< ) ;toggle-color JCN2
.Console/read DEI LIT 'c EQU ( M-c ) ;toggle-color JCN2
.Console/read DEI LIT 'g EQU ( M-g ) ;goto-line JCN2
.Console/read DEI LIT 't EQU ( M-t ) ;toggle-tabs JCN2
.Console/read DEI LIT 'v EQU ( M-v ) ;page-up JCN2
.Console/read DEI LIT '[ EQU ( M-[ ) ;xterm JCN2
BRK
@ -735,6 +725,11 @@
;messages/saved JMP2r
&is-modified ;messages/unsaved JMP2r
@get-tab-status
.config/insert-tabs LDZ ,&tabs JCN
;messages/st-spaces JMP2r
&tabs ;messages/st-tabs JMP2r
@draw-statusbar ( -> )
#0000 .term/rows LDZ2 ;term-move-cursor JSR2
;emit-color-reverse JSR2
@ -760,10 +755,16 @@
LIT ', emit
;cur-abs-row JSR2 INC2 ;emit-dec2 JSR2
LIT ') emit
#20 emit
;get-tab-status JSR2 ;print JSR2
;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
@ -874,11 +875,11 @@
@cur-last ( -> n* )
;cur-line JSR2 ;line-len JSR2 #0001 SUB2 JMP2r
@cur-width ( -> n* )
;cur-line JSR2 ;line-width JMP2
( @cur-width ( -> n* )
;cur-line JSR2 ;line-width JMP2 )
@cur-w-last ( -> n* )
;cur-line JSR2 ;line-width JSR2 #0001 SUB2 JMP2r
( @cur-w-last ( -> n* )
;cur-line JSR2 ;line-width JSR2 #0001 SUB2 JMP2r )
@line-len ( s* -> n* )
#0000 STH2
@ -922,7 +923,7 @@
INC2 ,&loop JMP ( addr+1 [-y] )
&found INC2 INC2r ( addr+1 [-y+1] ) ,&newline JMP
&done POP2r JMP2r
&not-found ;rel-line-error ;error! JMP2
&not-found ;messages/rel-line-error ;error! JMP2
@cur-line ( -> s* )
;cur-rel-row JSR2 ;rel-line JMP2
@ -981,8 +982,8 @@
@set-abs-row ( n* -> )
.buffer/line-offset LDZ2 SUB2 .cursor/row STZ2 JMP2r
@set-rel-row ( n* -> )
.cursor/row STZ2 JMP2r
( @set-rel-row ( n* -> )
.cursor/row STZ2 JMP2r )
@zero-row ( -> )
;data .buffer/offset STZ2
@ -1002,8 +1003,8 @@
@more-than-one-screen ( -> bool^ )
.buffer/line-count LDZ2 .term/rows LDZ2 GTH2 JMP2r
@fits-in-one-screen ( -> bool^ )
.buffer/line-count LDZ2 .term/rows LDZ2 INC2 LTH2 JMP2r
( @fits-in-one-screen ( -> bool^ )
.buffer/line-count LDZ2 .term/rows LDZ2 INC2 LTH2 JMP2r )
@mod-div ( x^ y^ -> x%d x/y )
DIVk STHk MUL SUB STHr JMP2r
@ -1069,7 +1070,12 @@
&quit-prompt "Save 20 "modified 20 "file 20 "(y/n)? 20 00
&unknown-input "Unknown 20 "input: 20 00
&saved "-- 20 00
&unsaved "** 20 00 ]
&unsaved "** 20 00
&term-size-parse-error "error 20 "parsing 20 "term 20 "size 00
&rel-line-error "invalid 20 "relative 20 "line 20 "number 00
&st-tabs "[t] 00
&st-spaces "[s] 00
]
@filename $80 ( path to file being edited )