Browse code

Rewrote ctrl parser for left

neauoire authored on 31/03/2021 17:00:32
Showing 2 changed files
... ...
@@ -63,6 +63,7 @@
63 63
 
64 64
 	( load file )
65 65
 	,filepath ,load-file JSR2
66
+
66 67
 	( place textarea )
67 68
 	#0018 =textarea.x1 ~Screen.height 8- =textarea.y2
68 69
 
... ...
@@ -77,63 +78,63 @@ BRK
77 78
 
78 79
 	~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 ,ctrl-end JNZ2
79 80
 		( lock ) #04 =lock
80
-		~Controller #10 NEQ ,no-ctrl-up JNZ2
81
-			( clamp ) ~position.y #0000 EQU2 ,no-ctrl-up JNZ2
82
-			,find-lineoffset JSR2 =position.x 
83
-			~position.y -- =position.y 
84
-			,find-selection JSR2 DUP2 =selection.from ++ =selection.to
85
-			,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
86
-		@no-ctrl-up
87
-		~Controller #20 NEQ ,no-ctrl-down JNZ2
88
-			,find-lineoffset JSR2 =position.x ~position.y ++ =position.y 
89
-			,find-selection JSR2 DUP2 =selection.from ++ =selection.to
90
-			,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
91
-		@no-ctrl-down
92
-		~Controller #40 NEQ ,no-ctrl-left JNZ2
93
-			( clamp ) ~selection.from ,document.body EQU2 ,no-ctrl-left JNZ2
94
-			~selection.from -- DUP2 =selection.from ++ =selection.to
95
-			,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
96
-		@no-ctrl-left
97
-		~Controller #80 NEQ ,no-ctrl-right JNZ2
98
-			~selection.from ++ DUP2 =selection.from ++ =selection.to
99
-			,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
100
-		@no-ctrl-right
101
-		( alt )
102
-		~Controller #0f AND #02 NEQ ,no-alt JNZ2
103
-			~Controller #04 SFT #01 NEQ ,no-aup JNZ2
104
-				,find-wordstart JSR2 =selection.to
105
-				,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
106
-			@no-aup
107
-			~Controller #04 SFT #02 NEQ ,no-adown JNZ2
108
-				,find-wordend JSR2 =selection.to
109
-				,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
110
-			@no-adown
111
-			~Controller #04 SFT #04 NEQ ,no-aleft JNZ2
112
-				~selection.to -- =selection.to
113
-				,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
114
-			@no-aleft
115
-			~Controller #04 SFT #08 NEQ ,no-aright JNZ2
116
-				~selection.to ++ =selection.to
117
-				,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
118
-			@no-aright
119
-		@no-alt
120
-		( ctrl )
121
-		~Controller #0f AND #01 NEQ ,no-ctrl JNZ2
122
-			~Controller #04 SFT #01 NEQ ,no-cup JNZ2
123
-				#0004 ,scroll-up JSR2
124
-				,redraw JSR2 ,ctrl-end JMP2
125
-			@no-cup
126
-			~Controller #04 SFT #02 NEQ ,no-cdown JNZ2
127
-				#0004 ,scroll-down JSR2
128
-				,redraw JSR2 ,ctrl-end JMP2
129
-			@no-cdown
130
-			~Controller #04 SFT #04 NEQ ,no-cleft JNZ2
131
-				,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2
132
-			@no-cleft
133
-			~Controller #04 SFT #08 NEQ ,no-cright JNZ2
134
-				,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2
135
-			@no-cright
136
-		@no-ctrl
81
+
82
+		( alt + arrow )
83
+		~Controller #0f AND #02 NEQ ^$no-alt JNZ
84
+			~Controller #04 SFT 
85
+			DUP #01 NEQ ^$no-aup JNZ
86
+				( sel word ) ,find-wordstart JSR2 =selection.to $no-aup
87
+			DUP #02 NEQ ^$no-adown JNZ
88
+				( sel word ) ,find-wordend JSR2 =selection.to $no-adown
89
+			DUP #04 NEQ ^$no-aleft JNZ
90
+				( sel decr ) ~selection.to -- =selection.to $no-aleft
91
+			DUP #08 NEQ ^$no-aright JNZ
92
+				( sel incr ) ~selection.to ++ =selection.to $no-aright
93
+			POP
94
+			,clamp-selection JSR2 
95
+			,redraw JSR2
96
+			,ctrl-end JMP2
97
+		$no-alt
98
+
99
+		( ctrl + arrow )
100
+		~Controller #0f AND #01 NEQ ^$no-ctrl JNZ
101
+			~Controller #04 SFT 
102
+			DUP #01 NEQ ^$no-cup JNZ
103
+				( jump scroll ) #0004 ,scroll-up JSR2 $no-cup
104
+			DUP #02 NEQ ^$no-cdown JNZ
105
+				( jump scroll ) #0004 ,scroll-down JSR2 $no-cdown
106
+			DUP #04 NEQ ^$no-cleft JNZ
107
+				( jump line ) ,goto-linestart JSR2 $no-cleft
108
+			DUP #08 NEQ ^$no-cright JNZ
109
+				( jump line ) ,goto-lineend JSR2 $no-cright
110
+			POP
111
+			,redraw JSR2
112
+			,ctrl-end JMP2
113
+		$no-ctrl
114
+
115
+		( arrow )
116
+		~Controller #f0 AND #00 EQU ,$no-arrow JNZ2
117
+			~Controller #f0 AND
118
+			DUP #10 NEQ ^$no-arrowup JNZ
119
+				( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ
120
+				,find-lineoffset JSR2 =position.x ~position.y -- =position.y 
121
+				,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowup
122
+			DUP #20 NEQ ^$no-arrowdown JNZ
123
+				( clamp:TODO )
124
+				,find-lineoffset JSR2 =position.x ~position.y ++ =position.y 
125
+				,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowdown
126
+			DUP #40 NEQ ^$no-arrowleft JNZ
127
+				( clamp ) ~selection.from ,document.body EQU2 ^$no-arrowleft JNZ
128
+				~selection.from -- DUP2 =selection.from ++ =selection.to $no-arrowleft
129
+			DUP #80 NEQ ^$no-arrowright JNZ
130
+				( clamp:TODO )
131
+				#aa =Console.byte
132
+				~selection.from ++ DUP2 =selection.from ++ =selection.to $no-arrowright
133
+			POP
134
+			,clamp-selection JSR2 
135
+			,follow-selection JSR2 
136
+			,redraw JSR2 
137
+		$no-arrow
137 138
 
138 139
 	@ctrl-end
139 140
 
... ...
@@ -168,15 +169,6 @@ BRK
168 169
 
169 170
 	( mouse )
170 171
 
171
-	~Mouse.state ~touch.state EQU ^no-change JNZ
172
-		#0000 =Sprite.x ~Screen.height 8- =Sprite.y
173
-		,mouse00icn =Sprite.addr
174
-		~Mouse.state #01 NEQ ^$nobutton1 JNZ ,mouse01icn =Sprite.addr $nobutton1
175
-		~Mouse.state #10 NEQ ^$nobutton2 JNZ ,mouse10icn =Sprite.addr $nobutton2
176
-		~Mouse.state #11 NEQ ^$nobutton3 JNZ ,mouse11icn =Sprite.addr $nobutton3
177
-		#01 =Sprite.color
178
-	@no-change
179
-
180 172
 	~Mouse.state #00 EQU ,touch-end JNZ2
181 173
 		~Mouse.x #0010 LTH2 ,touch-linebar JNZ2
182 174
 		~Mouse.x ~Screen.width 8- LTH2 ,touch-body JNZ2
... ...
@@ -259,7 +251,7 @@ RTN
259 251
 
260 252
 RTN
261 253
 
262
-@scroll-up ( length )
254
+@scroll-up ( length -- )
263 255
 	
264 256
 	DUP2 ~scroll.y LTH2 ^$clamp JNZ
265 257
 		#0000 =scroll.y POP2 RTN
... ...
@@ -268,7 +260,7 @@ RTN
268 260
 
269 261
 RTN
270 262
 
271
-@scroll-down ( length )
263
+@scroll-down ( length -- )
272 264
 
273 265
 	( TODO: Clamp )
274 266
 	~scroll.y SWP2 ADD2 =scroll.y
... ...
@@ -700,11 +692,6 @@ RTN
700 692
 	0000 0032 4c00 0000 3c42 99a1 a199 423c
701 693
 ]
702 694
 
703
-@mouse00icn  [ 0000 0000 0000 0000 ]
704
-@mouse01icn  [ 0078 7878 7878 7800 ]
705
-@mouse10icn  [ 001e 1e1e 1e1e 1e00 ]
706
-@mouse11icn  [ 007e 7e7e 7e7e 7e00 ]
707
-
708 695
 @linebreak_icn [ 003e 7474 3414 1400 ]
709 696
 @blank_icn     [ 0000 0000 0000 0000 ]
710 697
 @cursor_icn    [ 80c0 e0f0 f8e0 1000 ]
... ...
@@ -15,7 +15,7 @@ WITH REGARD TO THIS SOFTWARE.
15 15
 
16 16
 #include "uxn.h"
17 17
 
18
-#define HOR 48
18
+#define HOR 64
19 19
 #define VER 32
20 20
 #define PAD 2
21 21
 #define RES (HOR * VER * 16)