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