diff --git a/gui/notepad/src/notepad.tal b/gui/notepad/src/notepad.tal index 2758527..b6de9ea 100644 --- a/gui/notepad/src/notepad.tal +++ b/gui/notepad/src/notepad.tal @@ -1,3 +1,5 @@ +( A port of the macintosh classic notepad ) + |00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |80 @Controller &vector $2 &button $1 &key $1 @@ -10,19 +12,19 @@ @collapsed $1 @selection &a $2 &b $2 &length $2 -|100 +|100 @on-reset ( -> ) - ( meta ) + ( | meta ) ;meta #06 DEO2 - ( theme ) + ( | theme ) #f00f .System/r DEO2 #f00f .System/g DEO2 #f00f .System/b DEO2 load-theme - ( size ) + ( | size ) #00e0 .Screen/width DEO2 #00f8 .Screen/height DEO2 - ( unlock ) + ( | unlock ) ;on-mouse-body .Mouse/vector DEO2 ;on-frame .Screen/vector DEO2 ;on-control .Controller/vector DEO2 @@ -37,7 +39,7 @@ BRK ( name ) "Note 20 "Pad 0a ( details ) "Original 20 "by 20 "Donn 20 "Denman 0a ( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a - ( date ) "May 20 "27, 20 "2024 00 + ( date ) "May 20 "28, 20 "2024 00 01 ( icon ) 83 =appicon @@ -48,27 +50,27 @@ BRK .Controller/key DEI .Controller/button DEI ( shortcuts ) - DUP2 [ LIT2 "a 01 ] NEQ2 ?&no-ca POP2 select-all BRK &no-ca - DUP2 [ LIT2 "x 01 ] NEQ2 ?&no-cx POP2 edit-cut BRK &no-cx - DUP2 [ LIT2 "c 01 ] NEQ2 ?&no-cc POP2 edit-copy BRK &no-cc - DUP2 [ LIT2 "v 01 ] NEQ2 ?&no-cv POP2 edit-paste BRK &no-cv + DUP2 [ LIT2 "a 01 ] NEQ2 ?{ POP2 select-all BRK } + DUP2 [ LIT2 "x 01 ] NEQ2 ?{ POP2 edit-cut BRK } + DUP2 [ LIT2 "c 01 ] NEQ2 ?{ POP2 edit-copy BRK } + DUP2 [ LIT2 "v 01 ] NEQ2 ?{ POP2 edit-paste BRK } ( mask shift key ) #fb AND ( arrows ) - DUP #10 NEQ ?&no-u get-to #0001 SUB2 find-line-start select-variable &no-u - DUP #20 NEQ ?&no-d get-to INC2 find-line-end select-variable &no-d - DUP #40 NEQ ?&no-l select-left &no-l - DUP #80 NEQ ?&no-r select-right &no-r - DUP #42 NEQ ?&no-sbl .selection/b LDZ2 #0001 SUB2 find-word-start select-variable &no-sbl - DUP #82 NEQ ?&no-sbr .selection/b LDZ2 INC2 find-word-end select-variable &no-sbr + DUP #10 NEQ ?{ get-to #0001 SUB2 find-line-start select-variable } + DUP #20 NEQ ?{ get-to INC2 find-line-end select-variable } + DUP #40 NEQ ?{ select-left } + DUP #80 NEQ ?{ select-right } + DUP #42 NEQ ?{ .selection/b LDZ2 #0001 SUB2 find-word-start select-variable } + DUP #82 NEQ ?{ .selection/b LDZ2 INC2 find-word-end select-variable } ( pagination ) DUP #21 NEQ OVR #81 NEQ AND ?{ next-page } DUP #11 NEQ OVR #41 NEQ AND ?{ prev-page } POP ( key ) - DUP #08 NEQ ?&no-bs erase &no-bs - DUP #7f NEQ ?&no-del delete &no-del - DUP #09 LTH ?&no-ascii DUP insert &no-ascii + DUP #08 NEQ ?{ erase } + DUP #7f NEQ ?{ delete } + DUP #09 LTH ?{ DUP insert } POP #00 ;on-frame/f STA @@ -114,15 +116,9 @@ BRK trap-mouse [ LIT &last $1 ] .Mouse/state DEI - DUP #02 LTH ?&no-mouse2 - get-position select-word - &no-mouse2 - DUP2 #0001 NEQ2 ?&no-down - get-position select-variable - &no-down - DUP2 #0101 NEQ2 ?&no-drag - get-position select-to - &no-drag + DUP #02 LTH ?{ get-position select-word } + DUP2 #0001 NEQ2 ?{ get-position select-variable } + DUP2 #0101 NEQ2 ?{ get-position select-to } ,&last STR POP BRK @@ -170,9 +166,7 @@ BRK ( convert linebreaks ) DUP #0d EQU #03 MUL SUB - .selection/length LDZ2 #0000 EQU2 ?&no-block - erase-selection - &no-block + .selection/length LDZ2 #0000 EQU2 ?{ erase-selection } get-from STH2k #0001 SUB2 get-eof #0001 msfr STH2kr STA @@ -182,10 +176,9 @@ BRK @erase ( -- ) - .selection/length LDZ2 #0000 EQU2 ?&no-block + .selection/length LDZ2 #0000 EQU2 ?{ erase-selection - !select-reset - &no-block + !select-reset } get-from get-page NEQ2 [ JMP JMP2r ] @@ -205,10 +198,9 @@ BRK get-eof get-from SUB2 ORA #01 [ JCN JMP2r ] - .selection/length LDZ2 #0000 EQU2 ?&no-block + .selection/length LDZ2 #0000 EQU2 ?{ erase-selection - !select-reset - &no-block + !select-reset } get-from cut-char redraw @@ -284,9 +276,9 @@ BRK .selection/length LDZ2 #0000 EQU2 [ LIT2 04 -Controller/button ] DEI AND #00 NEQ - ORA ?&no-block + ORA ?{ get-from !select-from - &no-block + } .selection/b LDZ2 #0001 SUB2 !select-variable @@ -295,9 +287,9 @@ BRK .selection/length LDZ2 #0000 EQU2 [ LIT2 04 -Controller/button ] DEI AND #00 NEQ - ORA ?&no-block + ORA ?{ get-to !select-from - &no-block + } .selection/b LDZ2 INC2 !select-variable @@ -388,9 +380,9 @@ JMP2r .File/name DEO2 STH2kr .File/length DEO2 ( erase when selection length ) - .selection/length LDZ2 #0000 EQU2 ?&no-selection + .selection/length LDZ2 #0000 EQU2 ?{ get-from get-eof .selection/length LDZ2 msfl - &no-selection + } ( push right ) get-from #0001 SUB2 get-eof STH2kr msfr get-from .File/read DEO2 @@ -431,12 +423,12 @@ JMP2r @trap-mouse ( -- ) .Mouse/y DEI2 - DUP2 #0018 GTH2 ?&no-head + DUP2 #0018 GTH2 ?{ POP2 ;on-mouse-head .Mouse/vector DEO2 JMP2r - &no-head - DUP2 #00d6 LTH2 ?&no-foot + } + DUP2 #00d6 LTH2 ?{ POP2 ;on-mouse-foot .Mouse/vector DEO2 JMP2r - &no-foot + } POP2 ;on-mouse-body .Mouse/vector DEO2 @@ -507,13 +499,13 @@ JMP2r LDAk char-width .Screen/x DEI2 ADD2 .Screen/x DEO2 ( tab ) - LDAk #09 NEQ ?&no-tab + LDAk #09 NEQ ?{ #00 !draw-tab - &no-tab + } ( linebreak ) - LDAk #0a NEQ ?&no-lb + LDAk #0a NEQ ?{ #01 #0008 !draw-linebreak - &no-lb + } #00 JMP2r