Select line on reselection of word

This commit is contained in:
Devine Lu Linvega 2024-05-28 20:44:18 -07:00
parent 564e6de863
commit 12e156ebec
1 changed files with 24 additions and 6 deletions

View File

@ -96,7 +96,9 @@
@on-mouse-body ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;caret-icn <update-cursor>
<trap-mouse>
[ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{ get-position <select-word> }
[ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{
get-position <select-word>
[ LIT2 00 -Mouse/state ] DEO }
DUP2 #0001 NEQ2 ?{ get-position <select-variable> }
DUP2 #0101 NEQ2 ?{ get-position <select-to> }
,&last STR
@ -177,10 +179,22 @@
!select
@<select-word> ( addr* -- )
DUP2 &back #0001 SUB2 LDAk #20 GTH ?&back
INC2 .selection/a STZ2
&next INC2 LDAk #20 GTH ?&next
.selection/b STZ2
DUP2
&>back ( -- )
#0001 SUB2 LDAk #20 GTH ?&>back
INC2 SWP2
&>next ( -- )
INC2 LDAk #20 GTH ?&>next
OVR2 OVR2 is-selection ?{
.selection/b STZ2
.selection/a STZ2
!select }
POP2
( >> )
@<select-line> ( addr* -- )
DUP2 find-line-start .selection/a STZ2
find-line-end .selection/b STZ2
!select
@<select-all> ( -- )
@ -217,6 +231,10 @@
#01 JMP2r
&false #00 JMP2r
@is-selection ( a* b* -- f )
.selection/b LDZ2 EQU2 STH
.selection/a LDZ2 EQU2 STHr AND JMP2r
(
@|file )
@ -370,7 +388,7 @@
POP2 STH2r JMP2r
@find-line-start ( addr* -- addr* )
;mem SWP2
;mem #0001 SUB2 SWP2
&>l ( -- )
#0001 SUB2 LDAk DUP #0a EQU SWP #00 EQU ORA ?&end
LTH2k ?&>l