(notepad) Reverse selection

This commit is contained in:
Devine Lu Linvega 2023-04-28 09:09:30 -07:00
parent baa9db4122
commit a31f9a6b20
1 changed files with 49 additions and 34 deletions

View File

@ -5,13 +5,12 @@
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
( TODOs:
> Up and down arrows
> Negative length selection )
> Up and down arrows )
|0000
@page $1
@selection &from $2 &to $2 &length $2
@selection &a $2 &b $2 &length $2
|0100
@ -60,8 +59,8 @@ BRK
DUP #20 NEQ ?&no-d select-down &no-d
DUP #40 NEQ ?&no-l select-left &no-l
DUP #80 NEQ ?&no-r select-right &no-r
DUP #44 NEQ ?&no-sl .selection/to LDZ2 #0001 SUB2 select-to &no-sl
DUP #84 NEQ ?&no-sr .selection/to LDZ2 INC2 select-to &no-sr
DUP #44 NEQ ?&no-sl get-to #0001 SUB2 select-to &no-sl
DUP #84 NEQ ?&no-sr get-to INC2 select-to &no-sr
POP
( key )
DUP #08 NEQ ?&no-bs erase &no-bs
@ -163,7 +162,7 @@ BRK
@insert ( char -- )
.selection/from LDZ2 scap get-page #1000 ADD2 LTH2 ?&has-space
get-from scap get-page #1000 ADD2 LTH2 ?&has-space
POP JMP2r
&has-space
@ -174,7 +173,7 @@ BRK
erase-selection
&no-block
.selection/from LDZ2 STH2k #0001 SUB2 get-eof #0001 msfr
get-from STH2k #0001 SUB2 get-eof #0001 msfr
STH2kr STA
STH2r INC2 select-from
@ -187,9 +186,9 @@ BRK
!select-reset
&no-block
.selection/from LDZ2 get-page NEQ2 [ JMP JMP2r ]
get-from get-page NEQ2 [ JMP JMP2r ]
.selection/from LDZ2 #0001 SUB2
get-from #0001 SUB2
DUP2 cut-char
select-from
@ -197,20 +196,20 @@ BRK
@erase-selection ( -- )
.selection/from LDZ2 get-eof .selection/length LDZ2 msfl
get-from get-eof .selection/length LDZ2 msfl
!file-save
@delete ( -- )
get-eof .selection/from LDZ2 SUB2 ORA #01 [ JCN JMP2r ]
get-eof get-from SUB2 ORA #01 [ JCN JMP2r ]
.selection/length LDZ2 #0000 EQU2 ?&no-block
erase-selection
!select-reset
&no-block
.selection/from LDZ2 cut-char
get-from cut-char
redraw
!file-save
@ -232,7 +231,7 @@ BRK
@select-reset ( -- )
.selection/from LDZ2
get-from
( >> )
@ -241,38 +240,38 @@ BRK
( min ) get-page GTH2k [ JMP SWP2 POP2 ]
( max ) get-eof #0001 SUB2 LTH2k [ JMP SWP2 POP2 ]
DUP2 .selection/from STZ2
.selection/to STZ2
DUP2 .selection/a STZ2
.selection/b STZ2
!select
@select-to ( addr* -- )
( min ) .selection/from LDZ2 GTH2k [ JMP SWP2 POP2 ]
( min ) get-page GTH2k [ JMP SWP2 POP2 ]
( max ) get-eof #0001 SUB2 LTH2k [ JMP SWP2 POP2 ]
.selection/to STZ2
.selection/b STZ2
!select
@select-word ( addr* -- )
DUP2
&back #0001 SUB2 LDAk #20 GTH ?&back INC2 .selection/from STZ2
&next INC2 LDAk #20 GTH ?&next .selection/to STZ2
&back #0001 SUB2 LDAk #20 GTH ?&back INC2 .selection/a STZ2
&next INC2 LDAk #20 GTH ?&next .selection/b STZ2
!select
@select-all ( -- )
get-page
DUP2 .selection/from STZ2
scap #0001 SUB2 .selection/to STZ2
DUP2 .selection/a STZ2
scap #0001 SUB2 .selection/b STZ2
( >> )
@select ( -- )
.selection/to LDZ2 .selection/from LDZ2 SUB2 .selection/length STZ2
get-to get-from SUB2 .selection/length STZ2
#00 ;on-frame/f STA
!redraw
@ -292,25 +291,41 @@ JMP2r
@select-left ( -- )
.selection/length LDZ2 #0000 EQU2 ?&no-block
.selection/from LDZ2 !select-from
get-from !select-from
&no-block
.selection/from LDZ2 #0001 SUB2
get-from #0001 SUB2
!select-from
@select-right ( -- )
.selection/length LDZ2 #0000 EQU2 ?&no-block
.selection/to LDZ2 !select-from
get-to !select-from
&no-block
.selection/from LDZ2 INC2
get-from INC2
!select-from
@get-from ( -- addr* )
.selection/a LDZ2 .selection/b LDZ2 GTH2 ?&rev
.selection/a LDZ2
JMP2r
&rev .selection/b LDZ2 JMP2r
@get-to ( -- addr* )
.selection/a LDZ2 .selection/b LDZ2 GTH2 ?&rev
.selection/b LDZ2
JMP2r
&rev .selection/a LDZ2 JMP2r
@is-selected ( addr* -- f )
DUP2 .selection/from LDZ2 LTH2 ?&false
DUP2 .selection/to LDZ2 #0001 SUB2 GTH2 ?&false
DUP2 get-from LTH2 ?&false
DUP2 get-to #0001 SUB2 GTH2 ?&false
POP2 #01
JMP2r
@ -377,10 +392,10 @@ JMP2r
.selection/length LDZ2 #0000 EQU2 ?&no-selection
erase-selection
&no-selection
( push right ) .selection/from LDZ2 #0001 SUB2
( push right ) get-from #0001 SUB2
get-eof STH2kr msfr
.selection/from LDZ2 .File/read DEO2
.selection/from LDZ2 STH2r ADD2
get-from .File/read DEO2
get-from STH2r ADD2
!select-from
@ -399,7 +414,7 @@ JMP2r
;snarf-txt .File/name DEO2
.selection/length LDZ2 .File/length DEO2
.selection/from LDZ2 .File/write DEO2
get-from .File/write DEO2
JMP2r
@ -590,8 +605,8 @@ JMP2r
DUP2 is-selected STH #0701 STHr [ JMP SWP POP ] .Screen/sprite DEOk DEO
.Screen/x DEI2k #0010 SUB2 ROT DEO2
( draw selector )
.selection/from LDZ2 .selection/to LDZ2 NEQ2 ?&block
DUP2 .selection/from LDZ2 NEQ2 ?&block
get-from get-to NEQ2 ?&block
DUP2 get-from NEQ2 ?&block
;on-frame/last LDA #01 AND ?&block
;blink-icn .Screen/addr DEO2
[ LIT2 05 -Screen/sprite ] DEO