Browse code

Completed shift left/right

neauoire authored on 10/03/2021 19:00:21
Showing 1 changed files
... ...
@@ -31,15 +31,14 @@
31 31
 &Textarea2d { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 }
32 32
 &Touch2d    { x1 2 y1 2 x2 2 y2 2 state 1 }
33 33
 
34
-;touch Touch2d
35
-
36 34
 ;lock 1
37
-;selection Range2d
38
-;pt Point2d ;mouse Point2d ;position Point2d ;scroll Point2d
39
-;textarea Textarea2d
40
-;label Label2d
41
-;j 2 ;addr 2
35
+;i 2 ;j 2 ;addr 2
42 36
 
37
+;selection Range2d ;position Point2d ;scroll Point2d
38
+
39
+;pt Point2d ;mouse Point2d ;touch Touch2d
40
+;textarea Textarea2d
41
+;label Label2d ( remove )
43 42
 
44 43
 |0100 @RESET
45 44
 	
... ...
@@ -59,9 +58,7 @@ BRK
59 58
 	( ctrl )
60 59
 
61 60
 	,ctrl-end ~dev/ctrl #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP? POP2
62
-
63
-		( lock ) #03 =lock
64
-
61
+		( lock ) #04 =lock
65 62
 		,no-ctrl-up ~dev/ctrl #10 NEQ JMP? POP2
66 63
 			( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP? POP2
67 64
 			,find-lineoffset JSR =position.x 
... ...
@@ -128,26 +125,16 @@ BRK
128 125
 
129 126
 		,no-backspace ~dev/key #08 NEQ JMP? POP2
130 127
 			( erase )
128
+			~selection.to ~selection.from SUB2 ,shift-left JSR
131 129
 			~selection.from #0001 SUB2 =selection.from
132 130
 			~selection.from #0001 ADD2 =selection.to
133
-			~document.eof #0001 SUB2 =document.eof
134
-			~selection.from =j ( start -> end )
135
-			@erase-loop
136
-				~j #0001 ADD2 LDR ~j STR
137
-				( incr ) ~j #0001 ADD2 =j
138
-				,erase-loop ~j ~document.eof LTH2 JMP? POP2
139 131
 			( release ) #00 =dev/key
140 132
 			,redraw JSR
141 133
 			,keys-end JMP
142 134
 		@no-backspace
143 135
 
144 136
 		( insert )
145
-		~document.eof #0001 ADD2 =document.eof
146
-		~document.eof =j ( end -> start )
147
-		@insert-loop
148
-			~j #0001 SUB2 LDR ~j STR
149
-			( decr ) ~j #0001 SUB2 =j
150
-			,insert-loop ~j ~selection.from GTH2 JMP? POP2
137
+		~selection.to ~selection.from SUB2 ,shift-right JSR
151 138
 		~dev/key ~selection.from STR
152 139
 		~selection.from #0001 ADD2 =selection.from
153 140
 		~selection.from #0001 ADD2 =selection.to
... ...
@@ -231,6 +218,30 @@ RTS
231 218
 
232 219
 RTS
233 220
 
221
+@shift-left ( length )
222
+
223
+	=i
224
+	~selection.from #0001 SUB2 =j ( start -> end )
225
+	@shift-left-loop
226
+		( move ) ~j ~i ADD2 LDR ~j STR
227
+		( incr ) ~j #0001 ADD2 =j
228
+		,shift-left-loop ~j ~document.eof LTH2 JMP? POP2
229
+	~document.eof ~i SUB2 =document.eof
230
+
231
+RTS
232
+
233
+@shift-right ( length )
234
+
235
+	=i
236
+	~document.eof =j ( end -> start )
237
+	@shift-right-loop
238
+		( move ) ~j ~i SUB2 LDR ~j STR
239
+		( decr ) ~j #0001 SUB2 =j
240
+		,shift-right-loop ~j ~selection.from GTH2 JMP? POP2
241
+	~document.eof ~i ADD2 =document.eof
242
+
243
+RTS
244
+
234 245
 @clamp-selection
235 246
 
236 247
 	~selection.from ~selection.to LTH2 RTS?
... ...
@@ -618,8 +629,8 @@ RTS
618 629
 @arrowdown_icn [ 0010 1010 fe7c 3810 ]
619 630
 @load_icn      [ feaa d6aa d4aa f400 ]
620 631
 @save_icn      [ fe82 8282 848a f400 ]
621
-@filepath1     [ test.txt 00 ]
622
-@filepath      [ projects/software/left.usm 00 ]
632
+@filepath      [ test.txt 00 ]
633
+@filepath1     [ projects/software/left.usm 00 ]
623 634
 
624 635
 |4000 ;document Document
625 636