diff --git a/gui/notepad/notepad.tal b/gui/notepad/notepad.tal index 6f35dfb..a187365 100644 --- a/gui/notepad/notepad.tal +++ b/gui/notepad/notepad.tal @@ -5,6 +5,14 @@ |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 |a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 +( TODOs: + > Select all + > Copy/Paste + > Clamp selection + > Mouse2 select word + > Page memory mapping + > Fix issue with multi-line selection ) + |0000 @page $1 @@ -109,7 +117,7 @@ BRK get-position select-to &no-drag DUP2 #0100 NEQ2 ?&no-up - #03 phex/b #0a18 DEO + ( nothing ) &no-up ,&last STR POP @@ -182,7 +190,7 @@ BRK .selection/length LDZ2 #0001 LTH2 ?&no-block erase-selection - !reset-selection + !select-reset &no-block .selection/from LDZ2 ;mem NEQ2 [ JMP JMP2r ] @@ -198,7 +206,7 @@ BRK .selection/length LDZ2 #0001 EQU2 ?&no-block erase-selection - !reset-selection + !select-reset &no-block .selection/from LDZ2 cut-char @@ -225,13 +233,44 @@ JMP2r JMP2r -@reset-selection ( -- ) +@select-reset ( -- ) .selection/from LDZ2 select-from redraw JMP2r +@select-from ( addr* -- ) + + ( min ) ;mem GTH2k JMP SWP2 POP2 + ( max ) get-eof #0001 SUB2 LTH2k JMP SWP2 POP2 + + DUP2 .selection/from STZ2 + .selection/to STZ2 + + .selection/to LDZ2 .selection/from LDZ2 SUB2 .selection/length STZ2 + +!redraw + +@select-to ( addr* -- ) + + ( min ) .selection/from LDZ2 GTH2k JMP SWP2 POP2 + ( max ) get-eof #0001 SUB2 LTH2k JMP SWP2 POP2 + + .selection/to STZ2 + .selection/to LDZ2 .selection/from LDZ2 SUB2 .selection/length STZ2 + +!redraw + +@is-selected ( addr* -- f ) + + DUP2 .selection/from LDZ2 LTH2 ?&false + DUP2 .selection/to LDZ2 #0001 SUB2 GTH2 ?&false + POP2 #01 + +JMP2r + &false POP2 #00 JMP2r + ( @|core ) @@ -263,22 +302,6 @@ JMP2r JMP2r -@update-cursor ( color addr* -- ) - - [ LIT2 15 -Screen/auto ] DEO - #40 draw-cursor - .Mouse/x DEI2 ,draw-cursor/x STR2 - .Mouse/y DEI2 ,draw-cursor/y STR2 - .Screen/addr DEO2 - -@draw-cursor ( color -- ) - - [ LIT2 &x $2 ] .Screen/x DEO2 - [ LIT2 &y $2 ] .Screen/y DEO2 - .Screen/sprite DEO - -JMP2r - @walk-on ( -- f ) .Screen/x DEI2 .Mouse/x DEI2 LTH2 @@ -315,21 +338,14 @@ JMP2r JMP2r -@select-from ( addr* -- ) +@word-length ( str* -- length* ) - DUP2 .selection/from STZ2 - .selection/to STZ2 - .selection/to LDZ2 .selection/from LDZ2 SUB2 .selection/length STZ2 - - redraw - -JMP2r - -@select-to ( addr* -- ) - - .selection/to STZ2 - .selection/to LDZ2 .selection/from LDZ2 SUB2 .selection/length STZ2 - redraw + [ LIT2r 0000 ] + &while + LDAk #20 SUB #00 SWP ;font ADD2 LDA #00 SWP STH2 ADD2r + INC2 LDAk #20 GTH ?&while + POP2 + STH2r JMP2r @@ -465,32 +481,29 @@ JMP2r JMP2r -@is-selected ( addr* -- f ) +@update-cursor ( color addr* -- ) - DUP2 .selection/from LDZ2 LTH2 ?&false - DUP2 .selection/to LDZ2 #0001 SUB2 GTH2 ?&false - POP2 #01 + [ LIT2 15 -Screen/auto ] DEO + #40 draw-cursor + .Mouse/x DEI2 ,draw-cursor/x STR2 + .Mouse/y DEI2 ,draw-cursor/y STR2 + .Screen/addr DEO2 + +@draw-cursor ( color -- ) + + [ LIT2 &x $2 ] .Screen/x DEO2 + [ LIT2 &y $2 ] .Screen/y DEO2 + .Screen/sprite DEO JMP2r - &false POP2 #00 JMP2r -@word-length ( str* -- length* ) - - [ LIT2r 0000 ] - &while - LDAk #20 SUB #00 SWP ;font ADD2 LDA #00 SWP STH2 ADD2r - INC2 LDAk #20 GTH ?&while - POP2 - STH2r - -JMP2r +( +@|stdlib ) @msfl ( b* a* len* -- ) STH2 SWP2 EQU2k ?&e &l DUP2k STH2kr ADD2 LDA ROT ROT STA INC2 GTH2k ?&l POP2 POP2 &e POP2r JMP2r @msfr ( b* a* len* -- ) STH2 EQU2k ?&e &l DUP2 LDAk ROT ROT STH2kr ADD2 STA #0001 SUB2 LTH2k ?&l POP2 POP2 &e POP2r JMP2r - @scap ( str* -- end* ) LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r @sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r - @phex ( short* -- ) SWP phex/b &b ( byte -- ) DUP #04 SFT phex/c &c ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r (