Improved jump controls

This commit is contained in:
neauoire 2021-03-09 17:29:56 -08:00
parent 7d2a48a0a0
commit 3cfd2d8828
1 changed files with 92 additions and 68 deletions

View File

@ -3,19 +3,17 @@
TODO TODO
- Follow cursor when moving out of the screen - Follow cursor when moving out of the screen
- Moving should using selection instead of position
- Slowdown ctrl keys
- Save/Load - Save/Load
- Select blank lines - Select blank lines
- Real scrolling distance - Real scrolling distance
- page up/down move with ctrl+arrow - page up/down move with ctrl+arrow
- Select entire line by clicking line number
- Syntax highlight?
- Double-click select word - Double-click select word
- Right-click find next instance of selection - Right-click find next instance of selection
- Mouse block selection - Mouse down selection
- Copy/Cut/Paste - Copy/Cut/Paste
- x scroll - x scroll
- Don't scroll past oef
- Don't draw past eof
) )
&Console { pad 8 stdio 1 } &Console { pad 8 stdio 1 }
@ -33,12 +31,14 @@
&Label2d { x 2 y 2 color 1 addr 2 } &Label2d { x 2 y 2 color 1 addr 2 }
&Textarea2d { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 } &Textarea2d { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 }
;ctrl_lock 1
;selection Range2d ;selection Range2d
;pt Point2d ;mouse Point2d ;position Point2d ;scroll Point2d ;pt Point2d ;mouse Point2d ;position Point2d ;scroll Point2d
;textarea Textarea2d ;textarea Textarea2d
;label Label2d ;label Label2d
;j 2 ;addr 2 ;j 2 ;addr 2
|0100 @RESET |0100 @RESET
( load file ) ( load file )
@ -56,26 +56,36 @@ BRK
( ctrl ) ( ctrl )
,ctrl-end ~dev/ctrl #00 EQU JMP? POP2 ,ctrl-end ~dev/ctrl #00 EQU ~ctrl_lock #00 NEQ #0000 NEQ2 JMP? POP2
,no-ctrl-down ~dev/ctrl #04 ROR #01 NEQ JMP? POP2 ( lock ) #04 =ctrl_lock
,move-up JSR
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP ,no-ctrl-up ~dev/ctrl #10 NEQ JMP? POP2
@no-ctrl-down ,find-wordstart JSR DUP2 =selection.from #0001 ADD2 =selection.to
,no-ctrl-up ~dev/ctrl #04 ROR #02 NEQ JMP? POP2 ,redraw JSR ,ctrl-end JMP
,get-position JSR ~position.y #0001 SUB2 =position.y ,select JSR
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
@no-ctrl-up @no-ctrl-up
,no-ctrl-down ~dev/ctrl #20 NEQ JMP? POP2
,find-wordend JSR DUP2 =selection.from #0001 ADD2 =selection.to
,redraw JSR ,ctrl-end JMP
@no-ctrl-down
,no-ctrl-left ~dev/ctrl #40 NEQ JMP? POP2 ,no-ctrl-left ~dev/ctrl #40 NEQ JMP? POP2
~selection.from #0001 SUB2 DUP2 =selection.from =selection.to ~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP ,redraw JSR ,ctrl-end JMP
@no-ctrl-left @no-ctrl-left
,no-ctrl-right ~dev/ctrl #80 NEQ JMP? POP2 ,no-ctrl-right ~dev/ctrl #80 NEQ JMP? POP2
~selection.from #0001 ADD2 DUP2 =selection.from =selection.to ~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP ,redraw JSR ,ctrl-end JMP
@no-ctrl-right @no-ctrl-right
( alt ) ( alt )
,no-alt ~dev/ctrl #0f AND #02 NEQ JMP? POP2 ,no-alt ~dev/ctrl #0f AND #02 NEQ JMP? POP2
,no-aup ~dev/ctrl #04 ROR #01 NEQ JMP? POP2
,find-wordstart JSR =selection.to
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
@no-aup
,no-adown ~dev/ctrl #04 ROR #02 NEQ JMP? POP2
,find-wordend JSR =selection.to
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
@no-adown
,no-aleft ~dev/ctrl #04 ROR #04 NEQ JMP? POP2 ,no-aleft ~dev/ctrl #04 ROR #04 NEQ JMP? POP2
~selection.to #0001 SUB2 =selection.to ~selection.to #0001 SUB2 =selection.to
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP ,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
@ -88,12 +98,10 @@ BRK
( ctrl ) ( ctrl )
,no-ctrl ~dev/ctrl #0f AND #01 NEQ JMP? POP2 ,no-ctrl ~dev/ctrl #0f AND #01 NEQ JMP? POP2
,no-cleft ~dev/ctrl #04 ROR #04 NEQ JMP? POP2 ,no-cleft ~dev/ctrl #04 ROR #04 NEQ JMP? POP2
,find-linestart JSR #0001 ADD2 DUP2 =selection.from =selection.to ,goto-linestart JSR ,redraw JSR ,ctrl-end JMP
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
@no-cleft @no-cleft
,no-cright ~dev/ctrl #04 ROR #08 NEQ JMP? POP2 ,no-cright ~dev/ctrl #04 ROR #08 NEQ JMP? POP2
,find-lineend JSR #0001 SUB2 DUP2 =selection.from =selection.to ,goto-lineend JSR ,redraw JSR ,ctrl-end JMP
,clamp-selection JSR ,redraw JSR ,ctrl-end JMP
@no-cright @no-cright
@no-ctrl @no-ctrl
@ -139,33 +147,37 @@ BRK
( scrollbar ) ( scrollbar )
,no-click-scroll ~dev/mouse.x ~dev/screen.width #0008 SUB2 LTH2 JMP? POP2 ,no-click-scroll ~dev/mouse.x ~dev/screen.width #0008 SUB2 LTH2 JMP? POP2
,no-click-scroll-up ~dev/mouse.y #0008 GTH2 JMP? POP2 ,no-click-scroll-up ~dev/mouse.y #0008 GTH2 JMP? POP2
,scroll-up JSR ( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
,click-end JMP ,redraw JSR ,click-end JMP
@no-click-scroll-up @no-click-scroll-up
,no-click-scroll-down ~dev/mouse.y ~dev/screen.height #0008 SUB2 LTH2 JMP? POP2 ,no-click-scroll-down ~dev/mouse.y ~dev/screen.height #0008 SUB2 LTH2 JMP? POP2
,scroll-down JSR ( incr ) ~scroll.y #0001 ADD2 =scroll.y
,click-end JMP ,redraw JSR ,click-end JMP
@no-click-scroll-down @no-click-scroll-down
( on scrollbar ) ( on scrollbar )
~dev/mouse.y #0008 SUB2 =scroll.y ~dev/mouse.y #0008 SUB2 =scroll.y
,redraw JSR ,redraw JSR ,click-end JMP
,click-end JMP
@no-click-scroll @no-click-scroll
( line number )
,no-click-line ~dev/mouse.x #0010 GTH2 JMP? POP2
~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y #0001 =position.x ,select JSR
,clamp-selection JSR ,redraw JSR ,click-end JMP
@no-click-line
( select body ) ( select body )
~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y ~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y
~dev/mouse.x ~textarea.x1 SUB2 #0008 ADD2 #0008 DIV2 =position.x ~dev/mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x
,select JSR ,select JSR
,redraw JSR ,redraw JSR
@click-end @click-end
( decr ctrl lock )
,skip-unlock ~ctrl_lock #00 EQU JMP? POP2 ~ctrl_lock #01 SUB =ctrl_lock @skip-unlock
,draw-cursor JSR ,draw-cursor JSR
BRK BRK
@ -197,43 +209,55 @@ RTS
RTS RTS
@scroll-down @goto-linestart
( incr ) ~scroll.y #0001 ADD2 =scroll.y
,redraw JSR
RTS
@find-linestart
~selection.from =j
@goto-linestart-loop @goto-linestart-loop
~j ~selection.from #0001 SUB2 LDR #0a EQU RTS?
~j LDR #0a EQU RTS? ~selection.from #0001 SUB2 LDR #0d EQU RTS?
~j LDR #0d EQU RTS? ( decr ) ~selection.from DUP2 =selection.to #0001 SUB2 =selection.from
POP2 ,goto-linestart-loop ~selection.from LDR #00 NEQ JMP? POP2
( decr ) ~j #0001 SUB2 =j ( clamp at document body )
,goto-linestart-loop ~j LDR #00 NEQ JMP? POP2 ~selection.from ,document.body GTH2 RTS?
,document.body DUP2 =selection.from #0001 ADD2 =selection.to
RTS RTS
@find-lineend @goto-lineend
~selection.from =j
@goto-lineend-loop @goto-lineend-loop
( incr ) ~j #0001 ADD2 =j ~selection.from LDR #0a EQU RTS?
~j ~selection.from LDR #0d EQU RTS?
~j LDR #0a EQU RTS? ( incr ) ~selection.from #0001 ADD2 DUP2 #0001 ADD2 =selection.to =selection.from
~j LDR #0d EQU RTS? ,goto-lineend-loop ~selection.from LDR #00 NEQ JMP? POP2
POP2 ( clamp at document body )
,goto-lineend-loop ~j LDR #00 NEQ JMP? POP2 ~selection.from ,document.eof LTH2 RTS?
,document.eof #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
RTS RTS
@move-up @find-wordstart
,find-linestart JSR =selection.from ~selection.to =j
,find-lineend JSR =selection.to @find-wordstart-loop
( decr ) ~j #0001 SUB2 =j
,find-wordstart-end ~j LDR #20 EQU JMP? POP2
,find-wordstart-end ~j LDR #0a EQU JMP? POP2
,find-wordstart-end ~j LDR #0d EQU JMP? POP2
,find-wordstart-loop ~j ,document.body GTH2 JMP? POP2
@find-wordstart-end ~j #0001 SUB2
RTS
@find-wordend
~selection.to =j
@find-wordend-loop
( incr ) ~j #0001 ADD2 =j
,find-wordend-end ~j LDR #20 EQU JMP? POP2
,find-wordend-end ~j LDR #0a EQU JMP? POP2
,find-wordend-end ~j LDR #0d EQU JMP? POP2
,find-wordend-loop ~j ,document.body GTH2 JMP? POP2
@find-wordend-end ~j #0001 ADD2
RTS RTS
@ -415,7 +439,7 @@ RTS
#05 MUL ADD =dev/sprite.color #05 MUL ADD =dev/sprite.color
( incr ) ~j #0001 ADD2 =j ( incr ) ~j #0001 ADD2 =j
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x ( incr ) ~dev/sprite.x #0007 ADD2 =dev/sprite.x
,draw-textarea-loop ~j LDR #00 NEQ JMP? POP2 ,draw-textarea-loop ~j LDR #00 NEQ JMP? POP2
@ -561,4 +585,4 @@ RTS
|FF60 ;dev/file File |FF60 ;dev/file File
|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 40ff c09f a09f ] ( palette ) |FFF8 [ a0fe a0f7 a0f2 ] ( palette )