From 7cefdc4be8c8767add49181646ea513dc9a7639f Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 26 Apr 2023 21:34:36 -0700 Subject: [PATCH] Added copy/paste --- gui/notepad/notepad.tal | 57 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/gui/notepad/notepad.tal b/gui/notepad/notepad.tal index 94c2b4f..ddedeb3 100644 --- a/gui/notepad/notepad.tal +++ b/gui/notepad/notepad.tal @@ -6,9 +6,6 @@ |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 > Show blinker on last character > Mouse2 select word > Page memory mapping ) @@ -278,17 +275,67 @@ JMP2r JMP2r &false POP2 #00 JMP2r -@edit-cut ( -- ) +@file-size ( path* -- size* ) + + .File/name DEO2 + #0001 .File/length DEO2 + [ LIT2r 0000 ] + &s + ;&b .File/read DEO2 + .File/success DEI2 #0000 EQU2 ?&eof + INC2r !&s &eof + STH2r JMP2r + &b $1 + +@file-inject ( name* -- ) + + DUP2 file-size + ORAk ?&exists + POP2 POP2 JMP2r + &exists + STH2 + .File/name DEO2 + STH2kr .File/length DEO2 + ( erase when selection length ) + .selection/length LDZ2 #0001 EQU2 ?&no-selection + erase-selection + &no-selection + ( push right ) .selection/from LDZ2 #0001 SUB2 + get-eof STH2kr msfr + STH2kr mod-length + .selection/from LDZ2 .File/read DEO2 + .selection/from LDZ2 STH2r ADD2 + +!select-from + +@edit-cut ( -- ) + + .selection/length LDZ2 #0001 GTH2 [ JMP JMP2r ] + + edit-copy + erase-selection + +!select-reset @edit-copy ( -- ) + .selection/length LDZ2 #0001 GTH2 [ JMP JMP2r ] + + ;snarf-txt .File/name DEO2 + .selection/length LDZ2 .File/length DEO2 + .selection/from LDZ2 .File/write DEO2 + JMP2r @edit-paste ( -- ) -JMP2r + ;snarf-txt + +!file-inject + +@snarf-txt ".snarf $1 ( @|core )