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