cleanup
This commit is contained in:
parent
ade8cf1d0b
commit
cf9e72d8e4
83
femto.tal
83
femto.tal
|
@ -113,7 +113,7 @@
|
||||||
&quitting $1 ( are we in the process of quitting? )
|
&quitting $1 ( are we in the process of quitting? )
|
||||||
]
|
]
|
||||||
|
|
||||||
( prompt uses .tmp/pos and .tmp/data to track user input )
|
( prompt uses .tmp/pos and .tmp to track user input )
|
||||||
@prompt [
|
@prompt [
|
||||||
&active $1 ( is prompt currently active? )
|
&active $1 ( is prompt currently active? )
|
||||||
&vector $2 ( what code to run when user responds )
|
&vector $2 ( what code to run when user responds )
|
||||||
|
@ -122,11 +122,11 @@
|
||||||
|
|
||||||
( temporary input buffer used for a variety of things )
|
( temporary input buffer used for a variety of things )
|
||||||
@tmp [
|
@tmp [
|
||||||
|
$80 ( small scratch pad when reading data )
|
||||||
&pos $2 ( temporary pointer to address when reading data )
|
&pos $2 ( temporary pointer to address when reading data )
|
||||||
&data $80 ( small scratch pad when reading data )
|
|
||||||
]
|
]
|
||||||
|
|
||||||
( search uses .tmp/pos and .tmp/data to track query string )
|
( search uses .tmp/pos and .tmp to track query string )
|
||||||
@searching [
|
@searching [
|
||||||
&active $1 ( are we displaying search results? )
|
&active $1 ( are we displaying search results? )
|
||||||
&orig-row $2 ( row we began the search at )
|
&orig-row $2 ( row we began the search at )
|
||||||
|
@ -144,9 +144,9 @@
|
||||||
#0004 .config/tab-width STZ2
|
#0004 .config/tab-width STZ2
|
||||||
#0003 .config/tab-adjust STZ2
|
#0003 .config/tab-adjust STZ2
|
||||||
#00 .config/insert-tabs STZ
|
#00 .config/insert-tabs STZ
|
||||||
( #3333 .config/color STZ2 )
|
( #3033 .config/color STZ2 )
|
||||||
|
#3333 .config/color STZ2
|
||||||
( #3133 .config/red STZ2 )
|
( #3133 .config/red STZ2 )
|
||||||
#3033 .config/color STZ2
|
|
||||||
#3033 .config/red STZ2
|
#3033 .config/red STZ2
|
||||||
;data .buffer/offset STZ2
|
;data .buffer/offset STZ2
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
@setup-terminal-size ( -> )
|
@setup-terminal-size ( -> )
|
||||||
#03e7 DUP2 term-move-cursor
|
#03e7 DUP2 term-move-cursor
|
||||||
term-get-cursor-position
|
term-get-cursor-position
|
||||||
;tmp/data .tmp/pos STZ2
|
;tmp .tmp/pos STZ2
|
||||||
;receive-terminal-size .Console/vector DEO2
|
;receive-terminal-size .Console/vector DEO2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
@ -212,17 +212,17 @@
|
||||||
( called by ;receive-terminal-size after complete message received )
|
( called by ;receive-terminal-size after complete message received )
|
||||||
@parse-terminal-size ( -> )
|
@parse-terminal-size ( -> )
|
||||||
#0000 ,&acc STR2
|
#0000 ,&acc STR2
|
||||||
.tmp/data LDZk #1b NEQ ?&parse-error ( i ) INC
|
.tmp LDZk #1b NEQ ?&parse-error ( i ) INC
|
||||||
LDZk LIT "[ NEQ ?&parse-error ( i ) INC
|
LDZk LIT "[ NEQ ?&parse-error ( i ) INC
|
||||||
&loop
|
&loop
|
||||||
LDZk LIT "; EQU ?&parse-col
|
LDZk LIT "; EQU ?&parse-col
|
||||||
LIT2r :&loop !&read
|
LIT2r =&loop !&read
|
||||||
&parse-col
|
&parse-col
|
||||||
INC ,&acc LDR2 #0002 SUB2 .term/rows STZ2
|
INC ,&acc LDR2 #0002 SUB2 .term/rows STZ2
|
||||||
#0000 ,&acc STR2
|
#0000 ,&acc STR2
|
||||||
&loop2
|
&loop2
|
||||||
LDZk LIT "R EQU ?&done
|
LDZk LIT "R EQU ?&done
|
||||||
LIT2r :&loop2 !&read
|
LIT2r =&loop2 !&read
|
||||||
&read
|
&read
|
||||||
LDZk LIT "0 SUB #00 SWP
|
LDZk LIT "0 SUB #00 SWP
|
||||||
,&acc LDR2 #000a MUL2 ADD2 ,&acc STR2
|
,&acc LDR2 #000a MUL2 ADD2 ,&acc STR2
|
||||||
|
@ -233,17 +233,16 @@
|
||||||
draw-all
|
draw-all
|
||||||
BRK
|
BRK
|
||||||
[ &acc $2 ]
|
[ &acc $2 ]
|
||||||
&parse-error POP .tmp/data LDZ2
|
&parse-error POP .tmp LDZ2
|
||||||
;messages/term-size-parse-error !errorq
|
;messages/term-size-parse-error !errorq
|
||||||
|
|
||||||
@count-c ( c^ -> n* )
|
@count-c ( c^ -> n* )
|
||||||
#0000 ,&count STR2
|
STH #0000 ;data ( 0* data* [c^] )
|
||||||
STH ;data
|
&loop LDAk #00 EQU ?&done ( n* data* [c^] )
|
||||||
&loop LDAk #00 EQU ?&done
|
LDAk STHkr NEQ ?&next ( n* data* [c^] )
|
||||||
LDAk STHkr NEQ ?&next
|
SWP2 INC2 SWP2 ( n+1* data* [c^] )
|
||||||
,&count LDR2 INC2 ,&count STR2
|
&next INC2 !&loop ( n+1* data+1* [c^] )
|
||||||
&next INC2 !&loop
|
&done POP2 POPr JMP2r ( n* )
|
||||||
&done POP2 POPr ,&count LDR2 JMP2r [ &count $2 ]
|
|
||||||
|
|
||||||
( save count of number of lines in input file )
|
( save count of number of lines in input file )
|
||||||
( )
|
( )
|
||||||
|
@ -440,7 +439,7 @@
|
||||||
|
|
||||||
( display two strings on the message line )
|
( display two strings on the message line )
|
||||||
( )
|
( )
|
||||||
( often this involves a static messages + an argument like ;tmp/data. )
|
( often this involves a static messages + an argument like ;tmp. )
|
||||||
( )
|
( )
|
||||||
( use messages/null for the second string if only one is needed. )
|
( use messages/null for the second string if only one is needed. )
|
||||||
@send-message ( s1* s2* -> )
|
@send-message ( s1* s2* -> )
|
||||||
|
@ -450,10 +449,10 @@
|
||||||
|
|
||||||
( callback executed in response to the quit prompt. )
|
( callback executed in response to the quit prompt. )
|
||||||
@do-quit
|
@do-quit
|
||||||
.tmp/data LDZ LIT "n EQU ?quit-now
|
.tmp LDZ LIT "n EQU ?quit-now
|
||||||
.tmp/data LDZ LIT "y EQU ?save
|
.tmp LDZ LIT "y EQU ?save
|
||||||
#00 .state/quitting STZ
|
#00 .state/quitting STZ
|
||||||
;messages/unknown-input ;tmp/data send-message
|
;messages/unknown-input ;tmp send-message
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
( label that calls quit! )
|
( label that calls quit! )
|
||||||
|
@ -516,7 +515,7 @@
|
||||||
|
|
||||||
( delete the last character in the prompt )
|
( delete the last character in the prompt )
|
||||||
@backspace-prompt ( -> )
|
@backspace-prompt ( -> )
|
||||||
.tmp/pos LDZ2 ;tmp/data EQU2 ?&skip ( ?return )
|
.tmp/pos LDZ2 ;tmp EQU2 ?&skip ( ?return )
|
||||||
#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 )
|
||||||
STH2r .tmp/pos STZ2 ( pos <- pos-1 )
|
STH2r .tmp/pos STZ2 ( pos <- pos-1 )
|
||||||
|
@ -589,9 +588,9 @@
|
||||||
( )
|
( )
|
||||||
( this is used as a callback from the goto-line prompt )
|
( this is used as a callback from the goto-line prompt )
|
||||||
@do-goto-line ( n* -> )
|
@do-goto-line ( n* -> )
|
||||||
;tmp/data parse-decimal-number
|
;tmp parse-decimal-number
|
||||||
?&ok
|
?&ok
|
||||||
;messages/unknown-input ;tmp/data send-message
|
;messages/unknown-input ;tmp send-message
|
||||||
!return
|
!return
|
||||||
&ok
|
&ok
|
||||||
#0001 SUB2 ( convert 1-indexing to 0-indexing )
|
#0001 SUB2 ( convert 1-indexing to 0-indexing )
|
||||||
|
@ -675,8 +674,8 @@
|
||||||
.prompt/active LDZ ?&is-active
|
.prompt/active LDZ ?&is-active
|
||||||
#01 .prompt/active STZ ( prompt/active <- 1 )
|
#01 .prompt/active STZ ( prompt/active <- 1 )
|
||||||
.prompt/vector STZ2 ( prompt/vector <- vector )
|
.prompt/vector STZ2 ( prompt/vector <- vector )
|
||||||
;tmp/data str-copy ( tmp/data <- default )
|
;tmp str-copy ( tmp <- default )
|
||||||
;tmp/data ADD2 .tmp/pos STZ2 ( tmp/pos <- len(default)+data )
|
;tmp ADD2 .tmp/pos STZ2 ( tmp/pos <- len(default)+data )
|
||||||
.prompt/string STZ2 ( prompt/string <- prompt )
|
.prompt/string STZ2 ( prompt/string <- prompt )
|
||||||
JMP2r
|
JMP2r
|
||||||
&is-active
|
&is-active
|
||||||
|
@ -705,10 +704,10 @@
|
||||||
redraw-prompt-and-cursor
|
redraw-prompt-and-cursor
|
||||||
!return
|
!return
|
||||||
|
|
||||||
( save the file with the filename found in tmp/data )
|
( save the file with the filename found in tmp )
|
||||||
@do-save ( -> )
|
@do-save ( -> )
|
||||||
.buffer/limit LDZ2 ;data SUB2 STH2 ( [size] )
|
.buffer/limit LDZ2 ;data SUB2 STH2 ( [size] )
|
||||||
;tmp/data .File/name DEO2
|
;tmp .File/name DEO2
|
||||||
STH2kr .File/length DEO2
|
STH2kr .File/length DEO2
|
||||||
;data .File/write DEO2
|
;data .File/write DEO2
|
||||||
|
|
||||||
|
@ -716,10 +715,10 @@
|
||||||
;messages/save-failed !&finish
|
;messages/save-failed !&finish
|
||||||
&ok
|
&ok
|
||||||
#00 .state/modified STZ
|
#00 .state/modified STZ
|
||||||
;tmp/data ;filename str-copy POP2
|
;tmp ;filename str-copy POP2
|
||||||
;messages/save-ok
|
;messages/save-ok
|
||||||
&finish
|
&finish
|
||||||
;tmp/data send-message
|
;tmp send-message
|
||||||
.state/quitting LDZ ?quit-now
|
.state/quitting LDZ ?quit-now
|
||||||
#03 .state/redraw STZ ( FIXME: why do we have to do this? )
|
#03 .state/redraw STZ ( FIXME: why do we have to do this? )
|
||||||
!return
|
!return
|
||||||
|
@ -737,7 +736,7 @@
|
||||||
#0000 .searching/regex STZ2
|
#0000 .searching/regex STZ2
|
||||||
move-to-next-match ?&found
|
move-to-next-match ?&found
|
||||||
move-to-prev-match ?&found
|
move-to-prev-match ?&found
|
||||||
;messages/no-matches-found ;tmp/data send-message BRK
|
;messages/no-matches-found ;tmp send-message BRK
|
||||||
&found
|
&found
|
||||||
#01 .searching/active STZ
|
#01 .searching/active STZ
|
||||||
redraw-matches
|
redraw-matches
|
||||||
|
@ -755,10 +754,10 @@
|
||||||
cur-pos DUP2 .searching/start STZ2 .searching/end STZ2
|
cur-pos DUP2 .searching/start STZ2 .searching/end STZ2
|
||||||
.cursor/row LDZ2 .searching/orig-row STZ2
|
.cursor/row LDZ2 .searching/orig-row STZ2
|
||||||
.cursor/col LDZ2 .searching/orig-col STZ2
|
.cursor/col LDZ2 .searching/orig-col STZ2
|
||||||
;tmp/data compile .searching/regex STZ2
|
;tmp compile .searching/regex STZ2
|
||||||
move-to-next-regex-match ?&found
|
move-to-next-regex-match ?&found
|
||||||
move-to-prev-regex-match ?&found
|
move-to-prev-regex-match ?&found
|
||||||
;messages/no-matches-found ;tmp/data send-message BRK
|
;messages/no-matches-found ;tmp send-message BRK
|
||||||
&found
|
&found
|
||||||
#01 .searching/active STZ
|
#01 .searching/active STZ
|
||||||
redraw-matches
|
redraw-matches
|
||||||
|
@ -1183,7 +1182,7 @@
|
||||||
emit-color-bold
|
emit-color-bold
|
||||||
.prompt/string LDZ2 print
|
.prompt/string LDZ2 print
|
||||||
emit-reset
|
emit-reset
|
||||||
;tmp/data print
|
;tmp print
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@draw-linenum ( n* -> )
|
@draw-linenum ( n* -> )
|
||||||
|
@ -1193,7 +1192,7 @@
|
||||||
!emit-reset
|
!emit-reset
|
||||||
|
|
||||||
@matches-at ( s* -> limit* )
|
@matches-at ( s* -> limit* )
|
||||||
LIT2r :tmp/data
|
LIT2r =tmp
|
||||||
&loop LDAkr STHr #00 EQU ?&done
|
&loop LDAkr STHr #00 EQU ?&done
|
||||||
LDAk LDAkr STHr NEQ ?&fail
|
LDAk LDAkr STHr NEQ ?&fail
|
||||||
INC2 INC2r !&loop
|
INC2 INC2r !&loop
|
||||||
|
@ -1431,9 +1430,7 @@
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@print ( s* -> )
|
@print ( s* -> )
|
||||||
&loop LDAk #00 EQU ?&eof
|
LDAk ?{ POP2 JMP2r } LDAk #18 DEO INC2 !print
|
||||||
LDAk #18 DEO INC2 !&loop
|
|
||||||
&eof POP2 JMP2r
|
|
||||||
|
|
||||||
@cur-len ( -> n* )
|
@cur-len ( -> n* )
|
||||||
cur-line !line-len
|
cur-line !line-len
|
||||||
|
@ -1638,7 +1635,7 @@
|
||||||
( perform the undo action )
|
( perform the undo action )
|
||||||
@undo ( -> )
|
@undo ( -> )
|
||||||
#01 .state/in-undo STZ
|
#01 .state/in-undo STZ
|
||||||
;undo-stack/pos LDA2 ;undo-stack/data EQU2 ?&noop
|
;undo-stack/pos LDA2 ;undo-stack EQU2 ?&noop
|
||||||
;undo-stack/pos LDA2 #0003 SUB2
|
;undo-stack/pos LDA2 #0003 SUB2
|
||||||
DUP2 ;undo-stack/pos STA2
|
DUP2 ;undo-stack/pos STA2
|
||||||
LDA2k STH2 ( pos [addr] )
|
LDA2k STH2 ( pos [addr] )
|
||||||
|
@ -1655,7 +1652,7 @@
|
||||||
|
|
||||||
( free up space in the undo stack by evicting the oldest entry )
|
( free up space in the undo stack by evicting the oldest entry )
|
||||||
@u-free ( -> )
|
@u-free ( -> )
|
||||||
;undo-stack/data STH2k #0003 ADD2 ( st+3 [st] )
|
;undo-stack STH2k #0003 ADD2 ( st+3 [st] )
|
||||||
&loop LDAk STH2kr STA
|
&loop LDAk STH2kr STA
|
||||||
INC2 INC2r
|
INC2 INC2r
|
||||||
DUP2 ;undo-stack/pos LDA2 LTH2 ?&loop
|
DUP2 ;undo-stack/pos LDA2 LTH2 ?&loop
|
||||||
|
@ -1688,8 +1685,8 @@
|
||||||
( when pos points to data the stack is empty. )
|
( when pos points to data the stack is empty. )
|
||||||
( when pos points to pos the stack is full. )
|
( when pos points to pos the stack is full. )
|
||||||
@undo-stack [
|
@undo-stack [
|
||||||
&data $180 ( 128 steps )
|
$180 ( 128 steps )
|
||||||
&pos :undo-stack/data
|
&pos =undo-stack
|
||||||
]
|
]
|
||||||
|
|
||||||
( actual file data to be edited )
|
( actual file data to be edited )
|
||||||
|
|
Loading…
Reference in New Issue