wip search is kind of working
This commit is contained in:
parent
4e6e685a92
commit
0412b20153
116
femto.tal
116
femto.tal
|
@ -47,7 +47,6 @@
|
||||||
( - search )
|
( - search )
|
||||||
( - search&replace )
|
( - search&replace )
|
||||||
( - windows line-ending support (CRLF) )
|
( - windows line-ending support (CRLF) )
|
||||||
( - consider using abssolute cursor positions )
|
|
||||||
|
|
||||||
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|
||||||
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|
||||||
|
@ -134,6 +133,13 @@
|
||||||
&data $40 ( small scratch pad when reading data )
|
&data $40 ( small scratch pad when reading data )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
( search uses .tmp/pos and .tmp/data to track query string )
|
||||||
|
@searching [
|
||||||
|
&active $1
|
||||||
|
&orig-row $2
|
||||||
|
&orig-col $2
|
||||||
|
]
|
||||||
|
|
||||||
( startup )
|
( startup )
|
||||||
|0100
|
|0100
|
||||||
;init-zero-page JSR2
|
;init-zero-page JSR2
|
||||||
|
@ -588,6 +594,17 @@
|
||||||
.state/quitting LDZ ;quit-now JCN2
|
.state/quitting LDZ ;quit-now JCN2
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@search ( -> )
|
||||||
|
;messages/search-prompt ;messages/null ;do-search ;start-prompt JSR2
|
||||||
|
;draw-prompt-and-cursor JSR2
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@do-search ( -> )
|
||||||
|
#01 .searching/active STZ
|
||||||
|
;draw-all JSR2
|
||||||
|
( ;move-to-next-match JMP2 )
|
||||||
|
BRK
|
||||||
|
|
||||||
@toggle-color ( -> )
|
@toggle-color ( -> )
|
||||||
.config/color LDZ2 #3733 EQU2 ,&wrap-around JCN
|
.config/color LDZ2 #3733 EQU2 ,&wrap-around JCN
|
||||||
.config/color LDZ2 #0100 ADD2 .config/color STZ2 ,&done JMP
|
.config/color LDZ2 #0100 ADD2 .config/color STZ2 ,&done JMP
|
||||||
|
@ -660,6 +677,26 @@
|
||||||
;clear-line JSR2
|
;clear-line JSR2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
@cancel-search
|
||||||
|
#00 .searching/active STZ
|
||||||
|
;draw-all JSR2
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@finish-search
|
||||||
|
#00 .searching/active STZ
|
||||||
|
;draw-all JSR2
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@move-to-next-match BRK
|
||||||
|
@move-to-prev-match BRK
|
||||||
|
|
||||||
|
@on-key-searching
|
||||||
|
.Console/read DEI #07 EQU ( C-g ) ;cancel-search JCN2
|
||||||
|
.Console/read DEI #0d EQU ( \r ) ;finish-search JCN2
|
||||||
|
.Console/read DEI #6e EQU ( n ) ;move-to-next-match JCN2
|
||||||
|
.Console/read DEI #70 EQU ( p ) ;move-to-prev-match JCN2
|
||||||
|
;ignore JMP2
|
||||||
|
|
||||||
@on-key-prompt
|
@on-key-prompt
|
||||||
.Console/read DEI #07 EQU ( C-g ) ;cancel-prompt JCN2
|
.Console/read DEI #07 EQU ( C-g ) ;cancel-prompt JCN2
|
||||||
.Console/read DEI #0d EQU ( \r ) ;finish-prompt JCN2
|
.Console/read DEI #0d EQU ( \r ) ;finish-prompt JCN2
|
||||||
|
@ -674,6 +711,7 @@
|
||||||
( TODO: tab input? )
|
( TODO: tab input? )
|
||||||
@on-key
|
@on-key
|
||||||
;clear-message-line JSR2
|
;clear-message-line JSR2
|
||||||
|
.searching/active LDZ ;on-key-searching JCN2
|
||||||
.prompt/active LDZ ;on-key-prompt JCN2
|
.prompt/active LDZ ;on-key-prompt JCN2
|
||||||
.state/saw-vt LDZ ;on-key-vt JCN2
|
.state/saw-vt LDZ ;on-key-vt JCN2
|
||||||
.state/saw-xterm LDZ ;on-key-xterm JCN2
|
.state/saw-xterm LDZ ;on-key-xterm JCN2
|
||||||
|
@ -689,6 +727,7 @@
|
||||||
.Console/read DEI #0e EQU ( C-n ) ;down JCN2
|
.Console/read DEI #0e EQU ( C-n ) ;down JCN2
|
||||||
.Console/read DEI #0f EQU ( C-o ) ;save JCN2
|
.Console/read DEI #0f EQU ( C-o ) ;save JCN2
|
||||||
.Console/read DEI #10 EQU ( C-p ) ;up JCN2
|
.Console/read DEI #10 EQU ( C-p ) ;up JCN2
|
||||||
|
.Console/read DEI #13 EQU ( C-s ) ;search JCN2
|
||||||
.Console/read DEI #16 EQU ( C-v ) ;page-down JCN2
|
.Console/read DEI #16 EQU ( C-v ) ;page-down JCN2
|
||||||
.Console/read DEI #18 EQU ( C-x ) ;quit JCN2
|
.Console/read DEI #18 EQU ( C-x ) ;quit JCN2
|
||||||
.Console/read DEI #1a EQU ( C-z ) ;debug JCN2
|
.Console/read DEI #1a EQU ( C-z ) ;debug JCN2
|
||||||
|
@ -805,6 +844,79 @@
|
||||||
;emit-dec2-pad JSR2
|
;emit-dec2-pad JSR2
|
||||||
ansi ( LIT2 'm '0 emit emit ) emit-0 emit-m JMP2r
|
ansi ( LIT2 'm '0 emit emit ) emit-0 emit-m JMP2r
|
||||||
|
|
||||||
|
@matches-at ( s* -> limit* )
|
||||||
|
LIT2r :tmp/data
|
||||||
|
&loop
|
||||||
|
LDAkr STHr ,&non-zero JCN ,&done JMP
|
||||||
|
&non-zero
|
||||||
|
LDAk LDAkr STHr NEQ ,&fail JCN
|
||||||
|
INC2 INC2r ,&loop JMP
|
||||||
|
&done
|
||||||
|
POP2r JMP2r
|
||||||
|
&fail
|
||||||
|
POP2r POP2 #0000 JMP2r
|
||||||
|
|
||||||
|
@draw-region ( offset* limit* col* row* -> )
|
||||||
|
OVR2 ( offset limit col row col )
|
||||||
|
.term/cols LDZ2 SWP2 SUB2 STH2 ( offset limit col row [cols-col] )
|
||||||
|
;term-move-cursor JSR2 ( offset limit [cols-col] )
|
||||||
|
OVR2 STH2r ADD2 ( offset limit offset+cols-col )
|
||||||
|
;min2 JSR2 STH2 ( offset [cutoff] )
|
||||||
|
&loop ( i [cutoff] )
|
||||||
|
DUP2 STH2kr LTH2 ,&continue JCN ,&done JMP
|
||||||
|
&continue ( i [cutoff] )
|
||||||
|
LDAk #00 EQU ,&done JCN
|
||||||
|
LDAk #18 DEO INC2 ,&loop JMP
|
||||||
|
&done
|
||||||
|
POP2 POP2r JMP2r
|
||||||
|
|
||||||
|
@screen-limit ( -> sc-limit* )
|
||||||
|
.term/rows LDZ2 .buffer/line-offset LDZ2 ADD2 ( row0+rows )
|
||||||
|
DUP2 .buffer/line-count LDZ2 LTH2 ,¬-end JCN
|
||||||
|
POP2 .buffer/limit LDZ2 JMP2r
|
||||||
|
¬-end
|
||||||
|
;abs-line JMP2
|
||||||
|
|
||||||
|
@draw-matches ( -> )
|
||||||
|
( return if not searching )
|
||||||
|
.searching/active LDZ #00 EQU ,&return JCN ( )
|
||||||
|
;emit-color-reverse JSR2
|
||||||
|
|
||||||
|
.term/lmargin LDZ2 ( #0000 ) ,&x STR2 #0000 ,&y STR2 ( x <- 0, y <- 0 )
|
||||||
|
|
||||||
|
.buffer/offset LDZ2 DUP2
|
||||||
|
;screen-limit JSR2 SUB2 STH2 ( offset [-count] )
|
||||||
|
|
||||||
|
&loop ( offset [-count] )
|
||||||
|
STH2kr #0000 EQU2 ,&done JCN
|
||||||
|
DUP2 ;matches-at JSR2 ( offset mlim [-count] )
|
||||||
|
DUP2 ORA ,&found JCN
|
||||||
|
POP2 ( offset [-count] )
|
||||||
|
LDAk #0a EQU ,&newline JCN
|
||||||
|
#0001 ,&next JMP ( offset n [-count] )
|
||||||
|
&found ( offset mlim [-count] )
|
||||||
|
STH2k ( offset mlim [mlim -count] )
|
||||||
|
OVR2 SWP2 ,&x LDR2 ,&y LDR2 ( offset offset mlim x y [mlim -count] )
|
||||||
|
;draw-region JSR2 ( offset [mlim -count] ) ( POP2 POP2 POP2 POP2 ( FIXME ) )
|
||||||
|
STH2r ( offset mlim [-count] )
|
||||||
|
OVR2 SUB2 ( offset mlim-offset [-count] )
|
||||||
|
&next ( offset n [-count] )
|
||||||
|
DUP2 ,&x LDR2 ADD2 ,&x STR2 ( offset n [-count )
|
||||||
|
STH2k ( offset n [n -count] )
|
||||||
|
ADD2 ADD2r ( offset+n [n-count] )
|
||||||
|
,&loop JMP
|
||||||
|
&newline ( offset [-count] )
|
||||||
|
.term/lmargin LDZ2 ( #0000 ) ,&x STR2
|
||||||
|
,&y LDR2 INC2 ,&y STR2
|
||||||
|
INC2 INC2r
|
||||||
|
,&loop JMP
|
||||||
|
&done
|
||||||
|
POP2 POP2r
|
||||||
|
;emit-reset JSR2
|
||||||
|
&return
|
||||||
|
JMP2r
|
||||||
|
[ &x $2 &y $2 ]
|
||||||
|
|
||||||
@emit-tab ( -> )
|
@emit-tab ( -> )
|
||||||
#0000 .config/tab-width LDZ2 SUB2
|
#0000 .config/tab-width LDZ2 SUB2
|
||||||
LIT2r 2018
|
LIT2r 2018
|
||||||
|
@ -868,6 +980,7 @@
|
||||||
,&eof-loop JMP
|
,&eof-loop JMP
|
||||||
&done POP2 POP2r POP2r
|
&done POP2 POP2r POP2r
|
||||||
;emit-reset JSR2
|
;emit-reset JSR2
|
||||||
|
;draw-matches JSR2
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
;draw-prompt-and-cursor JSR2
|
;draw-prompt-and-cursor JSR2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
@ -1094,6 +1207,7 @@
|
||||||
&lines 20 "lines] 00
|
&lines 20 "lines] 00
|
||||||
&goto-line "Go 20 "to 20 "line: 20 00
|
&goto-line "Go 20 "to 20 "line: 20 00
|
||||||
&save-prompt "File 20 "Name 20 "to 20 "Write: 20 00
|
&save-prompt "File 20 "Name 20 "to 20 "Write: 20 00
|
||||||
|
&search-prompt "Text 20 "to 20 "Search 20 "for: 20 00
|
||||||
&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
|
||||||
|
|
Loading…
Reference in New Issue