(notepad) Text selection

This commit is contained in:
Devine Lu Linvega 2023-04-26 11:56:11 -07:00
parent fd47eb548a
commit 02d7c99d3f
1 changed files with 78 additions and 25 deletions

View File

@ -8,6 +8,7 @@
|0000
@page $1
@selection &from $2 &to $2
|0100
@ -32,6 +33,7 @@ BRK
@on-control ( -> )
.Controller/key DEI ;mem sput
#00 ;on-frame/f STA
redraw
BRK
@ -63,13 +65,17 @@ BRK
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;caret-icn update-cursor
trap-mouse
.Mouse/state DEI ?&on-mouse-down
BRK
&on-mouse-down ( -> )
[ LIT &last $1 ] .Mouse/state DEI
DUP2 #0001 NEQ2 ?&no-down
get-position select-from
&no-down
DUP2 #0101 NEQ2 ?&no-drag
get-position select-to
&no-drag
DUP2 #0100 NEQ2 ?&no-up
#03 phex/b #0a18 DEO
&no-up
,&last STR POP
BRK
@ -153,6 +159,48 @@ JMP2r
JMP2r
@walk-on ( -- f )
.Screen/x DEI2 .Mouse/x DEI2 LTH2
.Screen/y DEI2 .Mouse/y DEI2 #0008 SUB2 LTH2 ORA #00 NEQ
#ff MUL
JMP2r
@get-position ( -- addr* )
#0008 .Screen/x DEO2
#0018 .Screen/y DEO2
;mem
&while
( wrap )
LDAk #20 NEQ ?&no-wrap
DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap
#0008 .Screen/x DEO2
.Screen/y DEI2k #0010 ADD2 ROT DEO2
INC2 LDAk walk-on AND ?&while JMP2r
&no-wrap
LDAk #20 SUB #00 SWP ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
.Screen/x DEO2
INC2 LDAk walk-on AND ?&while
JMP2r
@select-from ( addr* -- )
DUP2 .selection/from STZ2
.selection/to STZ2
redraw
JMP2r
@select-to ( addr* -- )
.selection/to STZ2
redraw
JMP2r
(
@|drawing )
@ -208,7 +256,24 @@ JMP2r
#0008 .Screen/x DEO2
#0018 .Screen/y DEO2
;mem #00 .page LDZ #2000 MUL2 ADD2 draw-uf2
;mem #00 .page LDZ #2000 MUL2 ADD2
#15 .Screen/auto DEO
&while
( wrap )
LDAk #20 NEQ ?&no-wrap
DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap
#0008 .Screen/x DEO2
.Screen/y DEI2k #0010 ADD2 ROT DEO2
INC2 LDAk ?&while
&no-wrap
LDAk #20 SUB #00 SWP
DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
OVR2 is-selected STH #0701 STHr JMP SWP POP .Screen/sprite DEOk DEO
.Screen/x DEO2
INC2 LDAk ?&while
POP2
( draw cursor )
;blink-icn .Screen/addr DEO2
@ -239,26 +304,14 @@ JMP2r
JMP2r
@draw-uf2 ( text* -- )
@is-selected ( addr* -- f )
#15 .Screen/auto DEO
&while
( wrap )
LDAk #20 NEQ ?&no-wrap
DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap
#0008 .Screen/x DEO2
.Screen/y DEI2k #0010 ADD2 ROT DEO2
INC2 LDAk ?&while
&no-wrap
LDAk #20 SUB #00 SWP
DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
#01 .Screen/sprite DEOk DEO
.Screen/x DEO2
INC2 LDAk ?&while
POP2
DUP2 .selection/from LDZ2 LTH2 ?&false
DUP2 .selection/to LDZ2 GTH2 ?&false
POP2 #01
JMP2r
&false POP2 #00 JMP2r
@word-length ( str* -- length* )