diff --git a/gui/notepad/notepad.tal b/gui/notepad/notepad.tal index a187365..eb13797 100644 --- a/gui/notepad/notepad.tal +++ b/gui/notepad/notepad.tal @@ -310,31 +310,46 @@ JMP2r JMP2r +@pos-to-line ( y* -- line ) + + #0018 SUB2 #04 SFT2 NIP + +JMP2r + @get-position ( -- addr* ) #0008 .Screen/x DEO2 #0018 .Screen/y DEO2 + ( walk to line ) + .Mouse/y DEI2 pos-to-line ,&line STR ;mem &while - ( wrap ) - LDAk #20 GTH ?&no-wrap - DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap - draw-linebreak - 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 - ( tab ) - LDAk #09 NEQ ?&no-tab - draw-tab - INC2 LDAk walk-on AND ?&while JMP2r - &no-tab - ( linebreak ) - LDAk #0a NEQ ?&no-lb - draw-linebreak - INC2 LDAk walk-on AND ?&while JMP2r - &no-lb - INC2 LDAk walk-on AND ?&while + .Screen/y DEI2 pos-to-line [ LIT &line $1 ] EQU ?&end + walk-char + INC2 LDAk ?&while + &end + ( walk to char ) + +JMP2r + +@walk-char ( addr* -- addr* ) + + ( wrap ) + LDAk #20 GTH ?&no-wrap + DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap + !draw-linebreak + &no-wrap + ( char ) + LDAk #20 SUB #00 SWP ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2 + .Screen/x DEO2 + ( tab ) + LDAk #09 NEQ ?&no-tab + !draw-tab + &no-tab + ( linebreak ) + LDAk #0a NEQ ?&no-lb + !draw-linebreak + &no-lb JMP2r