| ... | ... |
@@ -9,7 +9,6 @@ |
| 9 | 9 |
- Scrollbar |
| 10 | 10 |
- Don't scroll past oef |
| 11 | 11 |
- Hor scroll |
| 12 |
- - Follow cursor when moving out of the screen |
|
| 13 | 12 |
- Real scrolling distance |
| 14 | 13 |
) |
| 15 | 14 |
|
| ... | ... |
@@ -31,7 +30,7 @@ |
| 31 | 30 |
&Touch2d { x1 2 y1 2 x2 2 y2 2 state 1 }
|
| 32 | 31 |
|
| 33 | 32 |
;lock 1 |
| 34 |
-;i 2 ;j 2 ;addr 2 |
|
| 33 |
+;i 2 ;j 2 ;k 1 ;l 1 ;addr 2 |
|
| 35 | 34 |
|
| 36 | 35 |
;selection Range2d ;position Point2d ;scroll Point2d |
| 37 | 36 |
|
| ... | ... |
@@ -63,21 +62,21 @@ BRK |
| 63 | 62 |
,find-lineoffset JSR2 =position.x |
| 64 | 63 |
~position.y #0001 SUB2 =position.y |
| 65 | 64 |
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to |
| 66 |
- ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 65 |
+ ,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 67 | 66 |
@no-ctrl-up |
| 68 | 67 |
,no-ctrl-down ~CTRL #20 NEQ JMP2? POP2 |
| 69 | 68 |
,find-lineoffset JSR2 =position.x ~position.y #0001 ADD2 =position.y |
| 70 | 69 |
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to |
| 71 |
- ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 70 |
+ ,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 72 | 71 |
@no-ctrl-down |
| 73 | 72 |
,no-ctrl-left ~CTRL #40 NEQ JMP2? POP2 |
| 74 | 73 |
( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? POP2 |
| 75 | 74 |
~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to |
| 76 |
- ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 75 |
+ ,clamp-selection JSR2,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 77 | 76 |
@no-ctrl-left |
| 78 | 77 |
,no-ctrl-right ~CTRL #80 NEQ JMP2? POP2 |
| 79 | 78 |
~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to |
| 80 |
- ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 79 |
+ ,clamp-selection JSR2,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
|
| 81 | 80 |
@no-ctrl-right |
| 82 | 81 |
( alt ) |
| 83 | 82 |
,no-alt ~CTRL #0f AND #02 NEQ JMP2? POP2 |
| ... | ... |
@@ -101,11 +100,11 @@ BRK |
| 101 | 100 |
( ctrl ) |
| 102 | 101 |
,no-ctrl ~CTRL #0f AND #01 NEQ JMP2? POP2 |
| 103 | 102 |
,no-cup ~CTRL #04 ROR #01 NEQ JMP2? POP2 |
| 104 |
- ~scroll.y #0004 SUB2 =scroll.y |
|
| 103 |
+ #0004 ,scroll-up JSR2 |
|
| 105 | 104 |
,redraw JSR2 ,ctrl-end JMP2 |
| 106 | 105 |
@no-cup |
| 107 | 106 |
,no-cdown ~CTRL #04 ROR #02 NEQ JMP2? POP2 |
| 108 |
- ~scroll.y #0004 ADD2 =scroll.y |
|
| 107 |
+ #0004 ,scroll-down JSR2 |
|
| 109 | 108 |
,redraw JSR2 ,ctrl-end JMP2 |
| 110 | 109 |
@no-cdown |
| 111 | 110 |
,no-cleft ~CTRL #04 ROR #04 NEQ JMP2? POP2 |
| ... | ... |
@@ -240,6 +239,22 @@ RTS |
| 240 | 239 |
|
| 241 | 240 |
RTS |
| 242 | 241 |
|
| 242 |
+@scroll-up ( length ) |
|
| 243 |
+ |
|
| 244 |
+ DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2? POP2 |
|
| 245 |
+ #0000 =scroll.y POP2 RTS |
|
| 246 |
+ $clamp |
|
| 247 |
+ ~scroll.y SWP2 SUB2 =scroll.y |
|
| 248 |
+ |
|
| 249 |
+RTS |
|
| 250 |
+ |
|
| 251 |
+@scroll-down ( length ) |
|
| 252 |
+ |
|
| 253 |
+ ( TODO: Clamp ) |
|
| 254 |
+ ~scroll.y SWP2 ADD2 =scroll.y |
|
| 255 |
+ |
|
| 256 |
+RTS |
|
| 257 |
+ |
|
| 243 | 258 |
@shift-left ( length ) |
| 244 | 259 |
|
| 245 | 260 |
=i |
| ... | ... |
@@ -256,14 +271,25 @@ RTS |
| 256 | 271 |
|
| 257 | 272 |
=i |
| 258 | 273 |
~document.eof =j ( end -> start ) |
| 259 |
- @shift-right-loop NOP |
|
| 274 |
+ $loop NOP |
|
| 260 | 275 |
( move ) ~j ~i SUB2 LDR ~j STR |
| 261 | 276 |
( decr ) ~j #0001 SUB2 =j |
| 262 |
- ~j ~selection.from GTH2 ^shift-right-loop MUL JMPS |
|
| 277 |
+ ~j ~selection.from GTH2 ^$loop MUL JMPS |
|
| 263 | 278 |
~document.eof ~i ADD2 =document.eof |
| 264 | 279 |
|
| 265 | 280 |
RTS |
| 266 | 281 |
|
| 282 |
+@follow-selection |
|
| 283 |
+ |
|
| 284 |
+ ,$no-up ~position.y ~scroll.y GTH2 JMP2? POP2 |
|
| 285 |
+ ~position.y =scroll.y RTS |
|
| 286 |
+ $no-up |
|
| 287 |
+ ,$no-down ~position.y ~SCRN.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? POP2 |
|
| 288 |
+ ~position.y ~SCRN.height #0010 SUB2 #0008 DIV2 SUB2 =scroll.y RTS |
|
| 289 |
+ $no-down |
|
| 290 |
+ |
|
| 291 |
+RTS |
|
| 292 |
+ |
|
| 267 | 293 |
@clamp-selection |
| 268 | 294 |
|
| 269 | 295 |
~selection.from ~selection.to LTH2 RTS? |
| ... | ... |
@@ -380,10 +406,10 @@ RTS |
| 380 | 406 |
#0000 =i ( start ) |
| 381 | 407 |
~selection.to ~selection.from SUB2 =j ( end ) |
| 382 | 408 |
~j =clip.len |
| 383 |
- $loop |
|
| 409 |
+ $loop NOP |
|
| 384 | 410 |
~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR |
| 385 | 411 |
( incr ) ~i #0001 ADD2 =i |
| 386 |
- ,$loop ~i ~j LTH2 JMP2? POP2 |
|
| 412 |
+ ~i ~j LTH2 ^$loop MUL JMPS |
|
| 387 | 413 |
|
| 388 | 414 |
RTS |
| 389 | 415 |
|
| ... | ... |
@@ -392,10 +418,10 @@ RTS |
| 392 | 418 |
~clip.len ,shift-right JSR2 |
| 393 | 419 |
#0000 =i ( start ) |
| 394 | 420 |
~clip.len =j ( end ) |
| 395 |
- $loop |
|
| 421 |
+ $loop NOP |
|
| 396 | 422 |
,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR |
| 397 | 423 |
( incr ) ~i #0001 ADD2 =i |
| 398 |
- ,$loop ~i ~j LTH2 JMP2? POP2 |
|
| 424 |
+ ~i ~j LTH2 ^$loop MUL JMPS |
|
| 399 | 425 |
|
| 400 | 426 |
RTS |
| 401 | 427 |
|
| ... | ... |
@@ -421,43 +447,21 @@ RTS |
| 421 | 447 |
|
| 422 | 448 |
@redraw |
| 423 | 449 |
|
| 424 |
- ,draw-lines JSR2 |
|
| 425 | 450 |
,draw-textarea JSR2 |
| 426 | 451 |
,draw-scrollbar JSR2 |
| 427 | 452 |
,draw-titlebar JSR2 |
| 428 | 453 |
|
| 429 | 454 |
( save/load icons ) |
| 430 |
- |
|
| 431 | 455 |
~SCRN.height #0008 SUB2 =SPRT.y |
| 432 |
- |
|
| 433 | 456 |
~SCRN.width #0018 SUB2 =SPRT.x |
| 434 | 457 |
,load_icn =SPRT.addr |
| 435 | 458 |
#02 =SPRT.color |
| 436 |
- |
|
| 437 | 459 |
~SCRN.width #0010 SUB2 =SPRT.x |
| 438 | 460 |
,save_icn =SPRT.addr |
| 439 | 461 |
#02 =SPRT.color |
| 440 | 462 |
|
| 441 | 463 |
RTS |
| 442 | 464 |
|
| 443 |
-@draw-lines |
|
| 444 |
- |
|
| 445 |
- #0000 =j |
|
| 446 |
- #0000 =SPRT.x #0000 =SPRT.y |
|
| 447 |
- $loop |
|
| 448 |
- ~scroll.y ~j ADD2 =addr |
|
| 449 |
- #0000 =SPRT.x |
|
| 450 |
- ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr |
|
| 451 |
- ( draw ) #02 ~addr ~position.y EQU2 #0c MUL ADD =SPRT.color |
|
| 452 |
- #0008 =SPRT.x |
|
| 453 |
- ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr |
|
| 454 |
- ( draw ) #02 ~addr ~position.y EQU2 #0c MUL ADD =SPRT.color |
|
| 455 |
- ( incr ) ~j #0001 ADD2 =j |
|
| 456 |
- ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y |
|
| 457 |
- ,$loop ~j ~SCRN.height #0008 SUB2 #0008 DIV2 NEQ2 JMP2? POP2 |
|
| 458 |
- |
|
| 459 |
-RTS |
|
| 460 |
- |
|
| 461 | 465 |
@draw-short ( short ) |
| 462 | 466 |
|
| 463 | 467 |
=addr |
| ... | ... |
@@ -506,39 +510,36 @@ RTS |
| 506 | 510 |
|
| 507 | 511 |
( scroll to position ) |
| 508 | 512 |
#0000 =j ( j is linebreaks ) |
| 509 |
- @find-scroll-offset NOP |
|
| 510 |
- ,find-scroll-offset-end ~scroll.y ~j EQU2 JMP2? POP2 |
|
| 511 |
- ,no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? POP2 |
|
| 513 |
+ $find-offset NOP |
|
| 514 |
+ ,$find-offset-end ~scroll.y ~j EQU2 JMP2? POP2 |
|
| 515 |
+ ,$no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? POP2 |
|
| 512 | 516 |
( incr ) ~j #0001 ADD2 =j |
| 513 |
- @no-break |
|
| 517 |
+ $no-break |
|
| 514 | 518 |
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr |
| 515 |
- ~textarea.addr LDR #00 NEQ ^find-scroll-offset MUL JMPS |
|
| 516 |
- @find-scroll-offset-end |
|
| 517 |
- |
|
| 518 |
- ~textarea.addr #0000 ADD2 =textarea.addr |
|
| 519 |
- #0000 =SPRT.y |
|
| 520 |
- ~textarea.addr =j |
|
| 519 |
+ ~textarea.addr LDR #00 NEQ ^$find-offset MUL JMPS |
|
| 520 |
+ $find-offset-end |
|
| 521 | 521 |
|
| 522 |
- #0018 =SPRT.x |
|
| 522 |
+ #0018 =SPRT.x #0000 =SPRT.y |
|
| 523 |
+ ~textarea.addr =i |
|
| 523 | 524 |
|
| 524 | 525 |
$loop |
| 525 | 526 |
|
| 526 | 527 |
,$end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2 |
| 527 | 528 |
|
| 528 | 529 |
( get character ) |
| 529 |
- ,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr |
|
| 530 |
+ ,font #00 ~i LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr |
|
| 530 | 531 |
|
| 531 | 532 |
( draw ) #01 |
| 532 |
- ~j ~selection.from #0001 SUB2 GTH2 |
|
| 533 |
- ~j ~selection.to LTH2 #0101 EQU2 |
|
| 533 |
+ ~i ~selection.from #0001 SUB2 GTH2 |
|
| 534 |
+ ~i ~selection.to LTH2 #0101 EQU2 |
|
| 534 | 535 |
#05 MUL ADD =SPRT.color |
| 535 | 536 |
|
| 536 |
- ,$no-linebreak ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2 |
|
| 537 |
+ ,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2? POP2 |
|
| 537 | 538 |
( draw linebreak ) |
| 538 | 539 |
,linebreak_icn =SPRT.addr |
| 539 | 540 |
( draw ) #02 |
| 540 |
- ~j ~selection.from #0001 SUB2 GTH2 |
|
| 541 |
- ~j ~selection.to LTH2 #0101 EQU2 |
|
| 541 |
+ ~i ~selection.from #0001 SUB2 GTH2 |
|
| 542 |
+ ~i ~selection.to LTH2 #0101 EQU2 |
|
| 542 | 543 |
#06 MUL ADD =SPRT.color |
| 543 | 544 |
( fill clear ) |
| 544 | 545 |
$fill-clear |
| ... | ... |
@@ -546,14 +547,26 @@ RTS |
| 546 | 547 |
,font =SPRT.addr |
| 547 | 548 |
#01 =SPRT.color |
| 548 | 549 |
,$fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2 |
| 550 |
+ |
|
| 551 |
+ ( draw line number ) |
|
| 552 |
+ |
|
| 553 |
+ #0000 =SPRT.x |
|
| 554 |
+ ~scroll.y ~SPRT.y #0008 DIV2 ADD2 DUP2 SWP POP =k |
|
| 555 |
+ ~position.y EQU2 #0c MUL =l |
|
| 556 |
+ ,font_hex #00 ~k #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr |
|
| 557 |
+ #02 ~l ADD =SPRT.color |
|
| 558 |
+ #0008 =SPRT.x |
|
| 559 |
+ ,font_hex #00 ~k #0f AND #08 MUL ADD2 =SPRT.addr |
|
| 560 |
+ #02 ~l ADD =SPRT.color |
|
| 561 |
+ |
|
| 549 | 562 |
#0010 =SPRT.x |
| 550 | 563 |
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y |
| 551 | 564 |
$no-linebreak |
| 552 | 565 |
|
| 553 |
- ( incr ) ~j #0001 ADD2 =j |
|
| 566 |
+ ( incr ) ~i #0001 ADD2 =i |
|
| 554 | 567 |
( incr ) ~SPRT.x #0007 ADD2 =SPRT.x |
| 555 | 568 |
|
| 556 |
- ,$loop ~j LDR #00 NEQ JMP2? POP2 |
|
| 569 |
+ ,$loop ~i LDR #00 NEQ JMP2? POP2 |
|
| 557 | 570 |
|
| 558 | 571 |
$end |
| 559 | 572 |
|