more searching tweaks

This commit is contained in:
~d6 2022-03-31 13:48:08 -04:00
parent ac49260c04
commit 6668d45bd8
1 changed files with 41 additions and 25 deletions

View File

@ -509,26 +509,37 @@
;jump-to-line JSR2 ;jump-to-line JSR2
;redraw-all JSR2 ;return JMP2 ;redraw-all JSR2 ;return JMP2
@jump-to-line ( n* -> ) @move-to-coord ( col* row* -> )
.term/rows LDZ2 INC2 #0002 DIV2 LTH2k ( n rows/2 n<rows/2? ) ,&early JCN DUP2 ;line-is-visible JSR2 ;jump-to-coord/short JCN2
OVR2 SWP2 SUB2 ( n n-rows/2 ) ;jump-to-coord JMP2
.buffer/line-count LDZ2 ( n n-rows/2 lines )
.term/rows LDZ2 SUB2 ( n n-rows/2 lines-rows ) @jump-to-coord ( x* y* -> )
GTH2k ( n n-rows/2 lines-rows n-rows/2>lines-rows? ) .term/rows LDZ2 INC2 #0002 DIV2 LTH2k ( x y rows/2 y<rows/2? ) ,&early JCN
,&late JCN ( n n-rows/2 lines-rows ) OVR2 SWP2 SUB2 ( x y y-rows/2 )
.buffer/line-count LDZ2 ( x y y-rows/2 lines )
.term/rows LDZ2 SUB2 ( x y y-rows/2 lines-rows )
GTH2k ( x y y-rows/2 lines-rows y-rows/2>lines-rows? )
,&late JCN ( x y y-rows/2 lines-rows )
POP2 ,&finish JMP POP2 ,&finish JMP
&early ( n rows/2 ) &early ( x y rows/2 )
POP2 #0000 ,&finish JMP ( n 0000 ) POP2 #0000 ,&finish JMP ( x y 0000 )
&late ( n n-rows/2 lines-rows ) &late ( x y y-rows/2 lines-rows )
NIP2 NIP2
&finish ( n o ) &finish ( x y o )
SUB2k STH2 DUP2 ( n o o [n-o] ) ;redraw-all JSR2
.buffer/line-offset STZ2 ( n o [n-o] ) SUB2k STH2 DUP2 ( x y o o [y-o] )
;abs-line JSR2 .buffer/offset STZ2 ( n [n-o] ) .buffer/line-offset STZ2 ( x y o [y-o] )
#0000 .cursor/col STZ2 ( n [n-o] ) ;abs-line JSR2 .buffer/offset STZ2 ( x y [y-o] )
POP2r .cursor/row STZ2 POP2r
&short
;redraw-statusbar-and-cursor JSR2
.cursor/row STZ2 ( x )
.cursor/col STZ2
JMP2r JMP2r
@jump-to-line ( n* -> )
#0000 SWP2 ;jump-to-coord JMP2
@ensure-visible-cursor @ensure-visible-cursor
;cur-rel-row JSR2 .term/rows LDZ2 LTH2 ,&noop JCN ;cur-rel-row JSR2 .term/rows LDZ2 LTH2 ,&noop JCN
;cur-abs-row JSR2 ;jump-to-line JSR2 ;cur-abs-row JSR2 ;jump-to-line JSR2
@ -602,6 +613,8 @@
;redraw-prompt-and-cursor JSR2 ;return JMP2 ;redraw-prompt-and-cursor JSR2 ;return JMP2
@do-search ( -> ) @do-search ( -> )
( TODO: verify the match found anything )
( if not we should display an error instead of activating searching )
#01 .searching/active STZ #01 .searching/active STZ
;move-to-next-match JMP2 ;move-to-next-match JMP2
@ -699,12 +712,10 @@
ORA ,&found JCN ORA ,&found JCN
INC2 ,&loop JMP INC2 ,&loop JMP
&found &found
NIP2 ;jump-to-pos JSR2 NIP2 ;jump-to-pos JSR2 ,&done JMP
,&done JMP
&fail &fail
POP2 POP2 POP2 POP2
&done &done
;redraw-all JSR2
;return JMP2 ;return JMP2
@move-to-prev-match @move-to-prev-match
@ -718,12 +729,10 @@
ORA ,&found JCN ORA ,&found JCN
#0001 SUB2 ,&loop JMP #0001 SUB2 ,&loop JMP
&found &found
NIP2 ;jump-to-pos JSR2 NIP2 ;jump-to-pos JSR2 ,&done JMP
,&done JMP
&fail &fail
POP2 POP2 POP2 POP2
&done &done
;redraw-all JSR2
;return JMP2 ;return JMP2
@on-key-searching @on-key-searching
@ -1088,12 +1097,19 @@
&tabs #0004 ADD2 ,&loop JMP &tabs #0004 ADD2 ,&loop JMP
&done POP2 STH2r JMP2r ) &done POP2 STH2r JMP2r )
@line-is-visible ( n* -> bool^ )
.buffer/line-offset LDZ2 LTH2k ,&no JCN
.term/rows LDZ2 ADD2 LTH2 JMP2r
&no POP2 POP2 #00 JMP2r
( TODO: leaving stuff on stack it seems ) ( TODO: leaving stuff on stack it seems )
@jump-to-pos ( s* -> ) @jump-to-pos ( s* -> )
;pos-to-row-col JSR2 ( row col ) ;pos-to-row-col JSR2 ( row col )
SWP2 ;jump-to-line JSR2 SWP2 ( DUP2 ;line-is-visible JSR2 ,&short JCN
.cursor/col STZ2 ;jump-to-line JSR2 ,&done JMP
JMP2r &short .cursor/row STZ2
&done .cursor/col STZ2 JMP2r )
;move-to-coord JMP2
@pos-to-row-col ( s* -> row* col* ) @pos-to-row-col ( s* -> row* col* )
#0000 ,&row STR2 #0000 ,&row STR2