Browse code

Improved selection

neauoire authored on 09/03/2021 03:50:12
Showing 1 changed files
... ...
@@ -9,12 +9,13 @@
9 9
 		- Select blank lines
10 10
 		- Real scrolling distance
11 11
 		- page up/down move with ctrl+arrow
12
-		- Select line by clicking line number
12
+		- Select entire line by clicking line number
13 13
 		- Syntax highlight?
14 14
 		- Double-click select word
15 15
 		- Right-click find next instance of selection
16 16
 		- Mouse block selection
17 17
 		- Copy/Cut/Paste
18
+		- x scroll
18 19
 )
19 20
 
20 21
 &Console    { pad 8 stdio 1 }
... ...
@@ -55,28 +56,37 @@ BRK
55 56
 		
56 57
 	( ctrl )
57 58
 
58
-	,no-ctrl ~dev/ctrl #00 EQU JMP? POP2
59
+	,ctrl-end ~dev/ctrl #00 EQU JMP? POP2
59 60
 
60 61
 		,no-ctrl-down ~dev/ctrl #04 ROR #01 NEQ JMP? POP2
61 62
 			~position.y #0001 SUB2 =position.y
62
-			,select JSR ,redraw JSR ,no-ctrl JMP
63
+			,select JSR	,ctrl-end JMP
63 64
 		@no-ctrl-down
64 65
 		,no-ctrl-up ~dev/ctrl #04 ROR #02 NEQ JMP? POP2
65 66
 			~position.y #0001 ADD2 =position.y
66
-			,select JSR ,redraw JSR ,no-ctrl JMP
67
+			,select JSR	,ctrl-end JMP
67 68
 		@no-ctrl-up
68
-		,no-ctrl-left ~dev/ctrl #04 ROR #04 NEQ JMP? POP2
69
-			~selection.from #0001 SUB2 =selection.from
70
-			~selection.from #0001 ADD2 =selection.to
71
-			,redraw JSR ,no-ctrl JMP
69
+		,no-ctrl-left ~dev/ctrl #40 NEQ JMP? POP2
70
+			~selection.from #0001 SUB2 DUP2 =selection.from =selection.to
71
+			,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
72 72
 		@no-ctrl-left
73
-		,no-ctrl-right ~dev/ctrl #04 ROR #08 NEQ JMP? POP2
74
-			~selection.from #0001 ADD2 =selection.from
75
-			~selection.from #0001 ADD2 =selection.to
76
-			,redraw JSR ,no-ctrl JMP
73
+		,no-ctrl-right ~dev/ctrl #80 NEQ JMP? POP2
74
+			~selection.from #0001 ADD2 DUP2 =selection.from =selection.to
75
+			,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
77 76
 		@no-ctrl-right
78
-
79
-	@no-ctrl
77
+		( alt )
78
+		,no-alt ~dev/ctrl #0f AND #02 NEQ JMP? POP2
79
+			,no-aleft ~dev/ctrl #04 ROR #04 NEQ JMP? POP2
80
+				~selection.to #0001 SUB2 =selection.to
81
+				,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
82
+			@no-aleft
83
+			,no-aright ~dev/ctrl #04 ROR #08 NEQ JMP? POP2
84
+				~selection.to #0001 ADD2 =selection.to
85
+				,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
86
+			@no-aright
87
+		@no-alt
88
+
89
+	@ctrl-end
80 90
 
81 91
 	( keys )
82 92
 
... ...
@@ -84,7 +94,8 @@ BRK
84 94
 
85 95
 		,no-backspace ~dev/key #08 NEQ JMP? POP2
86 96
 			( erase )
87
-			~position.x #0001 SUB2 =position.x ,select JSR
97
+			~selection.from #0001 SUB2 =selection.from
98
+			~selection.from #0001 ADD2 =selection.to
88 99
 			~document.eof #0001 SUB2 =document.eof
89 100
 			~selection.from =j ( start -> end )
90 101
 			@erase-loop
... ...
@@ -160,6 +171,13 @@ BRK
160 171
 
161 172
 RTS
162 173
 
174
+@clamp-selection
175
+
176
+	~selection.from ~selection.to LTH2 RTS?
177
+	~selection.from #0001 ADD2 =selection.to
178
+
179
+RTS
180
+
163 181
 @scroll-up
164 182
 	
165 183
 	( clamp ) ~scroll.y #0000 EQU2 RTS?
... ...
@@ -207,10 +225,11 @@ RTS
207 225
 
208 226
 @redraw
209 227
 
228
+	,draw-lines JSR
229
+
210 230
 	,draw-textarea JSR
211 231
 	,draw-scrollbar JSR
212 232
 	,draw-titlebar JSR
213
-	,draw-lines JSR
214 233
 
215 234
 	( save/load icons )
216 235