| ... | ... |
@@ -282,9 +282,9 @@ domouse(Uxn *u, SDL_Event *event) |
| 282 | 282 |
break; |
| 283 | 283 |
case SDL_MOUSEBUTTONDOWN: |
| 284 | 284 |
setflag(&u->ram.dat[addr + 4], flag, 1); |
| 285 |
- if(flag == 0x01 && getflag(&u->ram.dat[addr + 4], 0x10)) |
|
| 286 |
- u->ram.dat[addr + 5] = 0x01; |
|
| 287 | 285 |
if(flag == 0x10 && getflag(&u->ram.dat[addr + 4], 0x01)) |
| 286 |
+ u->ram.dat[addr + 5] = 0x01; |
|
| 287 |
+ if(flag == 0x01 && getflag(&u->ram.dat[addr + 4], 0x10)) |
|
| 288 | 288 |
u->ram.dat[addr + 5] = 0x10; |
| 289 | 289 |
break; |
| 290 | 290 |
} |
| ... | ... |
@@ -340,8 +340,8 @@ console_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) |
| 340 | 340 |
{
|
| 341 | 341 |
switch(b0) {
|
| 342 | 342 |
case 0x08: printf("%c", b1); break;
|
| 343 |
- case 0x09: printf("%02x", b1); break;
|
|
| 344 |
- case 0x0b: printf("%04x", (m[ptr + 0x0a] << 8) + b1); break;
|
|
| 343 |
+ case 0x09: printf("0x%02x\n", b1); break;
|
|
| 344 |
+ case 0x0b: printf("0x%04x\n", (m[ptr + 0x0a] << 8) + b1); break;
|
|
| 345 | 345 |
} |
| 346 | 346 |
fflush(stdout); |
| 347 | 347 |
(void)m; |
| ... | ... |
@@ -2,7 +2,6 @@ |
| 2 | 2 |
app/left : text editor |
| 3 | 3 |
|
| 4 | 4 |
TODO |
| 5 |
- - Copy/Cut/Paste |
|
| 6 | 5 |
- Save/Load |
| 7 | 6 |
- Double-click select word |
| 8 | 7 |
- Right-click find next instance of selection |
| ... | ... |
@@ -14,7 +13,7 @@ |
| 14 | 13 |
- Real scrolling distance |
| 15 | 14 |
) |
| 16 | 15 |
|
| 17 |
-&Console { pad 8 stdio 1 }
|
|
| 16 |
+&Console { pad 8 char 1 byte 1 short 2 }
|
|
| 18 | 17 |
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
| 19 | 18 |
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
| 20 | 19 |
&Controller { buttons 1 }
|
| ... | ... |
@@ -23,6 +22,7 @@ |
| 23 | 22 |
&File { pad 8 name 2 length 2 load 2 save 2 }
|
| 24 | 23 |
|
| 25 | 24 |
&Document { eof 2 body 8000 }
|
| 25 |
+&Clip { len 2 body 256 }
|
|
| 26 | 26 |
|
| 27 | 27 |
&Range2d { from 2 to 2 }
|
| 28 | 28 |
&Point2d { x 2 y 2 }
|
| ... | ... |
@@ -162,15 +162,16 @@ BRK |
| 162 | 162 |
|
| 163 | 163 |
@touch-scrollbar |
| 164 | 164 |
|
| 165 |
- ,no-click-scroll-up ~MOUS.y #0008 GTH2 JMP2? POP2 |
|
| 165 |
+ ,$no-up ~MOUS.y #0008 GTH2 JMP2? POP2 |
|
| 166 | 166 |
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y |
| 167 |
- ,redraw JSR2 ,touch-end JMP2 |
|
| 168 |
- @no-click-scroll-up |
|
| 169 |
- ,no-click-scroll-down ~MOUS.y ~SCRN.height #0008 SUB2 LTH2 JMP2? POP2 |
|
| 167 |
+ ^$end JMPS |
|
| 168 |
+ $no-up |
|
| 169 |
+ ,$no-down ~MOUS.y ~SCRN.height #0008 SUB2 LTH2 JMP2? POP2 |
|
| 170 | 170 |
( incr ) ~scroll.y #0001 ADD2 =scroll.y |
| 171 |
- ,redraw JSR2 ,touch-end JMP2 |
|
| 172 |
- @no-click-scroll-down |
|
| 171 |
+ ^$end JMPS |
|
| 172 |
+ $no-down |
|
| 173 | 173 |
~MOUS.y #0008 SUB2 =scroll.y |
| 174 |
+ $end |
|
| 174 | 175 |
,redraw JSR2 |
| 175 | 176 |
,touch-end JMP2 |
| 176 | 177 |
|
| ... | ... |
@@ -186,29 +187,40 @@ RTS |
| 186 | 187 |
RTS |
| 187 | 188 |
|
| 188 | 189 |
@touch-body |
| 189 |
- |
|
| 190 |
+ |
|
| 190 | 191 |
~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y |
| 191 | 192 |
~MOUS.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x |
| 192 | 193 |
|
| 193 |
- ,touch-when ~MOUS.state ~touch.state NEQ ~CTRL #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 |
|
| 194 |
+ ,$no-chord-cut ~MOUS.chord #01 NEQ JMP2? POP2 |
|
| 195 |
+ ,cut JSR2 |
|
| 196 |
+ ( release ) #00 DUP =MOUS.state =MOUS.chord |
|
| 197 |
+ ^$end JMPS |
|
| 198 |
+ $no-chord-cut |
|
| 199 |
+ ,$no-chord-paste ~MOUS.chord #10 NEQ JMP2? POP2 |
|
| 200 |
+ ,paste JSR2 |
|
| 201 |
+ ( release ) #00 DUP =MOUS.state =MOUS.chord |
|
| 202 |
+ ^$end JMPS |
|
| 203 |
+ $no-chord-paste |
|
| 204 |
+ |
|
| 205 |
+ ,$end ~MOUS.state #11 EQU JMP2? POP2 |
|
| 206 |
+ |
|
| 207 |
+ ,$no-drag ~MOUS.state ~touch.state NEQ ~CTRL #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 |
|
| 194 | 208 |
( on drag ) |
| 195 | 209 |
,find-selection JSR2 #0001 ADD2 =selection.to |
| 196 | 210 |
,clamp-selection JSR2 |
| 197 |
- ,redraw JSR2 |
|
| 198 |
- ,touch-end JMP2 |
|
| 199 |
- |
|
| 200 |
- @touch-when |
|
| 211 |
+ ^$end JMPS |
|
| 212 |
+ $no-drag |
|
| 201 | 213 |
( on click ) |
| 202 | 214 |
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to |
| 203 |
- ,redraw JSR2 |
|
| 204 |
- ,touch-end JMP2 |
|
| 215 |
+ $end |
|
| 216 |
+ ,redraw JSR2 |
|
| 217 |
+ ,touch-end JMP2 |
|
| 205 | 218 |
|
| 206 | 219 |
RTS |
| 207 | 220 |
|
| 208 | 221 |
@load-file ( path ) |
| 209 | 222 |
|
| 210 | 223 |
=FILE.name #8000 =FILE.length ,document.body =FILE.load |
| 211 |
- |
|
| 212 | 224 |
( get file length ) |
| 213 | 225 |
,document.body =document.eof |
| 214 | 226 |
$loop NOP |
| ... | ... |
@@ -333,9 +345,7 @@ RTS |
| 333 | 345 |
@find-selection ( position -> addr ) |
| 334 | 346 |
|
| 335 | 347 |
,find-line JSR2 ( find line ) |
| 336 |
- |
|
| 337 | 348 |
#0000 =pt.x |
| 338 |
- |
|
| 339 | 349 |
$loop NOP |
| 340 | 350 |
,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2? POP2 |
| 341 | 351 |
,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2? POP2 |
| ... | ... |
@@ -346,10 +356,41 @@ RTS |
| 346 | 356 |
|
| 347 | 357 |
RTS |
| 348 | 358 |
|
| 359 |
+@cut |
|
| 360 |
+ |
|
| 361 |
+ ,copy JSR2 |
|
| 362 |
+ ~selection.to ~selection.from SUB2 ,shift-left JSR2 |
|
| 363 |
+ ~selection.from #0001 ADD2 =selection.to |
|
| 364 |
+ |
|
| 365 |
+RTS |
|
| 366 |
+ |
|
| 367 |
+@copy ( selection ) |
|
| 368 |
+ |
|
| 369 |
+ #0000 =i ( start ) |
|
| 370 |
+ ~selection.to ~selection.from SUB2 =j ( end ) |
|
| 371 |
+ ~j =clip.len |
|
| 372 |
+ $loop |
|
| 373 |
+ ~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR |
|
| 374 |
+ ( incr ) ~i #0001 ADD2 =i |
|
| 375 |
+ ,$loop ~i ~j LTH2 JMP2? POP2 |
|
| 376 |
+ |
|
| 377 |
+RTS |
|
| 378 |
+ |
|
| 379 |
+@paste |
|
| 380 |
+ |
|
| 381 |
+ ~clip.len ,shift-right JSR2 |
|
| 382 |
+ #0000 =i ( start ) |
|
| 383 |
+ ~clip.len =j ( end ) |
|
| 384 |
+ $loop |
|
| 385 |
+ ,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR |
|
| 386 |
+ ( incr ) ~i #0001 ADD2 =i |
|
| 387 |
+ ,$loop ~i ~j LTH2 JMP2? POP2 |
|
| 388 |
+ |
|
| 389 |
+RTS |
|
| 390 |
+ |
|
| 349 | 391 |
@select ( position -> selection ) |
| 350 | 392 |
|
| 351 | 393 |
,document.body =selection.from #0000 =pt.x #0000 =pt.y |
| 352 |
- |
|
| 353 | 394 |
$loop |
| 354 | 395 |
,$no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2? POP2 |
| 355 | 396 |
( incr ) ~pt.y #0001 ADD2 =pt.y |
| ... | ... |
@@ -623,14 +664,15 @@ RTS |
| 623 | 664 |
@arrowdown_icn [ 0010 1010 fe7c 3810 ] |
| 624 | 665 |
@load_icn [ feaa d6aa d4aa f400 ] |
| 625 | 666 |
@save_icn [ fe82 8282 848a f400 ] |
| 626 |
-@filepath [ projects/examples/gui.hover.usm 00 ] |
|
| 627 |
-@filepath1 [ projects/software/left.usm 00 ] |
|
| 667 |
+@filepath1 [ projects/examples/gui.hover.usm 00 ] |
|
| 668 |
+@filepath [ projects/software/left.usm 00 ] |
|
| 628 | 669 |
|
| 629 |
-|4000 ;document Document |
|
| 670 |
+|3000 ;document Document |
|
| 671 |
+|c000 ;clip Clip |
|
| 630 | 672 |
|
| 631 | 673 |
|d000 @ERROR BRK |
| 632 | 674 |
|
| 633 |
-|FF00 ;dev/console Console |
|
| 675 |
+|FF00 ;CNSL Console |
|
| 634 | 676 |
|FF10 ;SCRN Screen |
| 635 | 677 |
|FF20 ;SPRT Sprite |
| 636 | 678 |
|FF30 ;CTRL Controller |