0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-18 12:05:09 +00:00
uxn/projects/software/left.usm

730 lines
17 KiB
Text
Raw Normal View History

2021-03-06 19:44:18 +00:00
(
app/left : text editor
2021-03-09 00:41:31 +00:00
TODO
2021-03-31 03:36:41 +00:00
- Rename icon in titlebar
2021-03-09 00:41:31 +00:00
- Save/Load
- Double-click select word
- Right-click find next instance of selection
2021-03-10 04:26:33 +00:00
- Draw tab characters
2021-03-13 18:31:29 +00:00
- Don't redraw if nothing has changed
- Input on selection should erase selection range
- Erase on selection should erase selection range
2021-03-11 03:41:46 +00:00
- Scrollbar
- Don't scroll past oef
- Hor scroll
- Real scrolling distance
2021-03-14 04:51:43 +00:00
)
2021-03-16 04:29:44 +00:00
%RTN { JMP2r }
2021-03-26 18:19:19 +00:00
%RTN? { #00 EQU #02 JNZ STH2r JMP2 }
2021-03-16 04:29:44 +00:00
2021-03-16 18:25:26 +00:00
%++ { #0001 ADD2 } %-- { #0001 SUB2 }
2021-03-20 04:13:09 +00:00
%8/ { #0003 SFT2 } %8* { #0030 SFT2 }
2021-03-16 18:25:26 +00:00
%8- { #0008 SUB2 } %8+ { #0008 ADD2 }
2021-03-21 20:58:32 +00:00
( variables )
2021-03-14 04:51:43 +00:00
;lock { byte 1 }
;k { byte 1 }
;l { byte 1 }
;i { short 2 }
;j { short 2 }
;addr { short 2 }
;selection { from 2 to 2 }
;position { x 2 y 2 }
;scroll { x 2 y 2 }
;pt { x 2 y 2 }
;mouse { x 2 y 2 }
;touch { x1 2 y1 2 x2 2 y2 2 state 1 }
;textarea { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 }
;label { x 2 y 2 color 1 addr 2 } ( remove )
2021-03-10 01:29:56 +00:00
2021-03-21 20:58:32 +00:00
( devices )
2021-04-05 18:39:08 +00:00
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { buttons 1 }
|0150 ;Keys { key 1 }
|0160 ;Mouse { x 2 y 2 state 1 chord 1 }
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
2021-03-28 17:19:06 +00:00
2021-03-21 20:58:32 +00:00
( program )
2021-04-05 18:39:08 +00:00
|0200 @RESET
2021-03-08 05:09:15 +00:00
( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b
2021-04-05 18:39:08 +00:00
( vectors ) ,FRAME =Screen.vector
2021-03-28 18:02:11 +00:00
2021-03-08 05:09:15 +00:00
( load file )
2021-03-11 03:41:46 +00:00
,filepath ,load-file JSR2
2021-03-31 17:00:32 +00:00
2021-03-08 05:09:15 +00:00
( place textarea )
2021-03-16 18:25:26 +00:00
#0018 =textarea.x1 ~Screen.height 8- =textarea.y2
2021-03-07 05:30:16 +00:00
2021-03-11 03:41:46 +00:00
,select JSR2
,redraw JSR2
2021-03-01 19:18:11 +00:00
2021-03-06 19:44:18 +00:00
BRK
2021-03-01 19:18:11 +00:00
2021-03-08 18:30:13 +00:00
@FRAME
2021-03-10 01:29:56 +00:00
2021-03-07 05:30:16 +00:00
( ctrl )
~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 ,$ctrl-end JNZ2
2021-03-10 19:00:21 +00:00
( lock ) #04 =lock
2021-03-31 17:00:32 +00:00
( alt + arrow )
~Controller #0f AND #02 NEQ ^$no-alt JNZ
~Controller #04 SFT
DUP #01 NEQ ^$no-aup JNZ
( sel word ) ,find-wordstart JSR2 =selection.to $no-aup
DUP #02 NEQ ^$no-adown JNZ
( sel word ) ,find-wordend JSR2 =selection.to $no-adown
DUP #04 NEQ ^$no-aleft JNZ
( sel decr ) ~selection.to -- =selection.to $no-aleft
DUP #08 NEQ ^$no-aright JNZ
( sel incr ) ~selection.to ++ =selection.to $no-aright
POP
,clamp-selection JSR2
,redraw JSR2
,$ctrl-end JMP2
2021-03-31 17:00:32 +00:00
$no-alt
( ctrl + arrow )
~Controller #0f AND #01 NEQ ^$no-ctrl JNZ
~Controller #04 SFT
DUP #01 NEQ ^$no-cup JNZ
( jump scroll ) #0004 ,scroll-up JSR2 $no-cup
DUP #02 NEQ ^$no-cdown JNZ
( jump scroll ) #0004 ,scroll-down JSR2 $no-cdown
DUP #04 NEQ ^$no-cleft JNZ
( jump line ) ,goto-linestart JSR2 $no-cleft
DUP #08 NEQ ^$no-cright JNZ
( jump line ) ,goto-lineend JSR2 $no-cright
POP
,redraw JSR2
,$ctrl-end JMP2
2021-03-31 17:00:32 +00:00
$no-ctrl
( arrow )
~Controller #f0 AND #00 EQU ,$no-arrow JNZ2
~Controller #f0 AND
DUP #10 NEQ ^$no-arrowup JNZ
( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ
,find-lineoffset JSR2 =position.x ~position.y -- =position.y
,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowup
DUP #20 NEQ ^$no-arrowdown JNZ
( clamp:TODO )
,find-lineoffset JSR2 =position.x ~position.y ++ =position.y
,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowdown
DUP #40 NEQ ^$no-arrowleft JNZ
( clamp ) ~selection.from ,document.body EQU2 ^$no-arrowleft JNZ
~selection.from -- DUP2 =selection.from ++ =selection.to $no-arrowleft
DUP #80 NEQ ^$no-arrowright JNZ
( clamp:TODO )
#aa =Console.byte
~selection.from ++ DUP2 =selection.from ++ =selection.to $no-arrowright
POP
,clamp-selection JSR2
,follow-selection JSR2
,redraw JSR2
$no-arrow
2021-03-09 03:50:12 +00:00
$ctrl-end
2021-03-07 05:30:16 +00:00
2021-03-08 18:30:13 +00:00
( keys )
~Keys #00 EQU ,$no-keys JNZ2
2021-03-08 20:35:30 +00:00
2021-03-27 02:55:18 +00:00
~Keys #08 NEQ ^$no-backspace JNZ
2021-03-08 20:35:30 +00:00
( erase )
2021-03-27 02:55:18 +00:00
~selection.to ~selection.from SUB2 #0001 NEQ2 ^$erase-multiple JNZ
2021-03-13 18:31:29 +00:00
~selection.to ~selection.from SUB2 ,shift-left JSR2
,$erase-end JMP2
$erase-multiple
2021-03-16 18:25:26 +00:00
~selection.from ++ =selection.from
~selection.to ~selection.from SUB2 ++ ,shift-left JSR2
2021-03-13 18:31:29 +00:00
$erase-end
2021-03-16 18:25:26 +00:00
~selection.from -- =selection.from
^$keys-end JMP
2021-03-13 18:31:29 +00:00
$no-backspace
2021-03-08 18:30:13 +00:00
2021-03-08 18:55:57 +00:00
( insert )
2021-03-11 03:41:46 +00:00
~selection.to ~selection.from SUB2 ,shift-right JSR2
2021-03-24 16:39:19 +00:00
~Keys ~selection.from POK2
2021-03-16 18:25:26 +00:00
~selection.from ++ =selection.from
2021-03-08 18:30:13 +00:00
2021-03-13 18:31:29 +00:00
$keys-end
~selection.from ++ =selection.to
( release ) #00 =Keys
,redraw JSR2
2021-03-13 18:31:29 +00:00
$no-keys
2021-03-08 18:30:13 +00:00
2021-03-07 05:30:16 +00:00
( mouse )
~Mouse.state #00 EQU ^$touch-end JNZ
2021-03-26 18:19:19 +00:00
~Mouse.x #0010 LTH2 ,touch-linebar JNZ2
~Mouse.x ~Screen.width 8- LTH2 ,touch-body JNZ2
2021-03-11 03:41:46 +00:00
,touch-scrollbar JMP2
$touch-end
2021-03-07 05:30:16 +00:00
2021-03-14 21:26:17 +00:00
~Mouse.state =touch.state
2021-03-07 05:30:16 +00:00
2021-03-26 18:19:19 +00:00
( unlock ) ~lock #00 EQU ,skip-unlock JNZ2 ~lock #01 SUB =lock @skip-unlock
2021-03-10 01:29:56 +00:00
2021-03-11 03:41:46 +00:00
,draw-cursor JSR2
2021-03-07 05:30:16 +00:00
BRK
@touch-linebar ( -- )
#0000 =position.x
~Mouse.y 8/ ~scroll.y ADD2 =position.y
2021-03-16 18:25:26 +00:00
,find-selection JSR2 DUP2 =selection.from ++ =selection.to
,goto-linestart JSR2
2021-03-11 03:41:46 +00:00
,redraw JSR2
,draw-cursor JSR2
2021-03-10 17:29:08 +00:00
BRK
2021-03-10 17:29:08 +00:00
@touch-body ( -- )
2021-03-12 19:37:45 +00:00
2021-03-16 18:25:26 +00:00
~Mouse.y 8/ ~scroll.y ADD2 =position.y
2021-03-14 21:26:17 +00:00
~Mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x
( chords )
~Mouse.chord #00 EQU ^$no-chords JNZ
~Mouse.chord
DUP #01 NEQ ^$no-chord-cut JNZ
,cut JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord $no-chord-cut
DUP #10 NEQ ^$no-chord-paste JNZ
,paste JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord $no-chord-paste
POP
,redraw JSR2
BRK
$no-chords
( drag )
2021-03-27 02:55:18 +00:00
~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ
2021-03-10 17:29:08 +00:00
( on drag )
2021-03-16 18:25:26 +00:00
,find-selection JSR2 ++ =selection.to
2021-03-11 03:41:46 +00:00
,clamp-selection JSR2
2021-03-16 01:08:41 +00:00
^$end JMP
2021-03-12 19:37:45 +00:00
$no-drag
( on click )
,find-selection JSR2 DUP2 =selection.from ++ =selection.to
2021-03-12 19:37:45 +00:00
$end
~Mouse.state =touch.state
,draw-cursor JSR2
2021-03-12 19:37:45 +00:00
,redraw JSR2
2021-03-10 17:29:08 +00:00
BRK
@touch-scrollbar ( -- )
~Mouse.y #0008 GTH2 ^$no-up JNZ
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
^$end JMP
$no-up
~Mouse.y ~Screen.height 8- LTH2 ^$no-down JNZ
( incr ) ~scroll.y ++ =scroll.y
^$end JMP
$no-down
~Mouse.y 8- =scroll.y
$end
~Mouse.state =touch.state
,draw-cursor JSR2
,redraw JSR2
BRK
2021-03-10 17:29:08 +00:00
2021-03-08 18:30:13 +00:00
@load-file ( path )
2021-03-14 21:26:17 +00:00
=File.name #8000 =File.length ,document.body =File.load
2021-03-08 18:30:13 +00:00
( get file length )
,document.body =document.eof
2021-03-27 02:55:18 +00:00
$loop
2021-03-16 18:25:26 +00:00
( incr ) ~document.eof ++ =document.eof
2021-03-27 02:55:18 +00:00
~document.eof PEK2 #00 NEQ ^$loop JNZ
2021-03-08 18:30:13 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-08 18:30:13 +00:00
2021-03-31 17:00:32 +00:00
@scroll-up ( length -- )
2021-03-13 04:22:28 +00:00
2021-03-27 02:55:18 +00:00
DUP2 ~scroll.y LTH2 ^$clamp JNZ
2021-03-14 21:26:17 +00:00
#0000 =scroll.y POP2 RTN
2021-03-13 04:22:28 +00:00
$clamp
~scroll.y SWP2 SUB2 =scroll.y
2021-03-14 21:26:17 +00:00
RTN
2021-03-13 04:22:28 +00:00
2021-03-31 17:00:32 +00:00
@scroll-down ( length -- )
2021-03-13 04:22:28 +00:00
( TODO: Clamp )
~scroll.y SWP2 ADD2 =scroll.y
2021-03-14 21:26:17 +00:00
RTN
2021-03-13 04:22:28 +00:00
@shift-left ( length -- )
2021-03-10 19:00:21 +00:00
=i
2021-03-16 18:25:26 +00:00
~selection.from -- =j ( start -> end )
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
( move ) ~j ~i ADD2 PEK2 ~j POK2
2021-03-16 18:25:26 +00:00
( incr ) ~j ++ =j
2021-03-27 02:55:18 +00:00
~j ~document.eof LTH2 ^$loop JNZ
2021-03-10 19:00:21 +00:00
~document.eof ~i SUB2 =document.eof
2021-03-14 21:26:17 +00:00
RTN
2021-03-10 19:00:21 +00:00
@shift-right ( length -- )
2021-03-10 19:00:21 +00:00
=i
~document.eof =j ( end -> start )
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
( move ) ~j ~i SUB2 PEK2 ~j POK2
2021-03-16 18:25:26 +00:00
( decr ) ~j -- =j
2021-03-27 02:55:18 +00:00
~j ~selection.from GTH2 ^$loop JNZ
2021-03-10 19:00:21 +00:00
~document.eof ~i ADD2 =document.eof
2021-03-14 21:26:17 +00:00
RTN
2021-03-10 19:00:21 +00:00
@follow-selection ( -- )
2021-03-13 04:22:28 +00:00
2021-03-27 02:55:18 +00:00
~position.y ~scroll.y GTH2 ^$no-up JNZ
2021-03-14 21:26:17 +00:00
~position.y =scroll.y RTN
2021-03-13 04:22:28 +00:00
$no-up
2021-03-27 02:55:18 +00:00
~position.y ~Screen.height #0010 SUB2 8/ ~scroll.y ADD2 LTH2 ^$no-down JNZ
2021-03-16 18:25:26 +00:00
~position.y ~Screen.height #0010 SUB2 8/ SUB2 =scroll.y RTN
2021-03-13 04:22:28 +00:00
$no-down
2021-03-14 21:26:17 +00:00
RTN
2021-03-13 04:22:28 +00:00
@clamp-selection ( -- )
2021-03-09 03:50:12 +00:00
2021-03-14 21:26:17 +00:00
~selection.from ~selection.to LTH2 RTN?
2021-03-16 18:25:26 +00:00
~selection.from ++ =selection.to
2021-03-09 03:50:12 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-09 03:50:12 +00:00
@goto-linestart ( -- )
2021-03-07 20:32:19 +00:00
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
~selection.from -- PEK2 #0a EQU RTN?
~selection.from -- PEK2 #0d EQU RTN?
2021-03-16 18:25:26 +00:00
( decr ) ~selection.from DUP2 =selection.to -- =selection.from
2021-03-27 02:55:18 +00:00
~selection.from PEK2 #00 NEQ ^$loop JNZ
2021-03-10 01:29:56 +00:00
( clamp at document body )
2021-03-14 21:26:17 +00:00
~selection.from ,document.body GTH2 RTN?
2021-03-16 18:25:26 +00:00
,document.body DUP2 =selection.from ++ =selection.to
2021-03-07 20:32:19 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-09 19:33:31 +00:00
@goto-lineend ( -- )
2021-03-10 01:29:56 +00:00
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
~selection.from PEK2 #0a EQU RTN?
~selection.from PEK2 #0d EQU RTN?
2021-03-16 18:25:26 +00:00
( incr ) ~selection.from ++ DUP2 ++ =selection.to =selection.from
2021-03-27 02:55:18 +00:00
~selection.from PEK2 #00 NEQ ^$loop JNZ
2021-03-10 01:29:56 +00:00
( clamp at document body )
2021-03-14 21:26:17 +00:00
~selection.from ,document.eof LTH2 RTN?
2021-03-16 18:25:26 +00:00
,document.eof -- DUP2 =selection.from ++ =selection.to
2021-03-09 19:33:31 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-09 19:33:31 +00:00
@find-wordstart ( -- )
2021-03-09 19:33:31 +00:00
2021-03-10 01:29:56 +00:00
~selection.to =j
2021-03-27 02:55:18 +00:00
$loop
2021-03-16 18:25:26 +00:00
( decr ) ~j -- =j
2021-03-27 02:55:18 +00:00
~j PEK2 #20 EQU ^$end JNZ
~j PEK2 #0a EQU ^$end JNZ
~j PEK2 #0d EQU ^$end JNZ
~j ,document.body GTH2 ^$loop JNZ
2021-03-12 04:41:35 +00:00
$end
2021-03-16 18:25:26 +00:00
( return ) ~j --
2021-03-09 19:33:31 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-09 19:33:31 +00:00
@find-wordend ( -- )
2021-03-07 05:30:16 +00:00
2021-03-10 01:29:56 +00:00
~selection.to =j
2021-03-27 02:55:18 +00:00
$loop
2021-03-16 18:25:26 +00:00
( incr ) ~j ++ =j
2021-03-27 02:55:18 +00:00
~j PEK2 #20 EQU ^$end JNZ
~j PEK2 #0a EQU ^$end JNZ
~j PEK2 #0d EQU ^$end JNZ
~j ,document.body GTH2 ^$loop JNZ
2021-03-12 04:41:35 +00:00
$end
2021-03-16 18:25:26 +00:00
( return ) ~j ++
2021-03-07 05:30:16 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-07 05:30:16 +00:00
2021-03-10 17:29:08 +00:00
@find-lineoffset ( return character offset from linestart )
#0000 =j
2021-03-27 02:55:18 +00:00
$loop
2021-03-16 18:25:26 +00:00
( incr ) ~j ++ =j
2021-03-27 02:55:18 +00:00
~selection.from ~j SUB2 PEK2 #0a EQU ^$end JNZ
~selection.from ~j SUB2 PEK2 #0d EQU ^$end JNZ
~selection.from ~j SUB2 ,document.body GTH2 ^$loop JNZ
2021-03-12 04:41:35 +00:00
$end
2021-03-10 17:29:08 +00:00
( return ) ~j
2021-03-14 21:26:17 +00:00
RTN
2021-03-10 17:29:08 +00:00
2021-03-10 04:26:33 +00:00
@find-line ( position -> addr )
2021-03-08 18:30:13 +00:00
2021-03-10 04:26:33 +00:00
,document.body =j #0000 =pt.y
2021-03-27 02:55:18 +00:00
$loop
~pt.y ~position.y -- GTH2 ^$end JNZ
~j PEK2 #0a NEQ ~j PEK2 #0d NEQ #0101 EQU2 ^$no-space JNZ
2021-03-16 18:25:26 +00:00
( incr ) ~pt.y ++ =pt.y
2021-03-12 04:41:35 +00:00
$no-space
2021-03-16 18:25:26 +00:00
( incr ) ~j ++ =j
2021-03-27 02:55:18 +00:00
~j PEK2 #00 NEQ ^$loop JNZ
2021-03-12 04:41:35 +00:00
$end
2021-03-10 04:26:33 +00:00
( return ) ~j
2021-03-08 18:30:13 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-09 19:33:31 +00:00
2021-03-10 04:26:33 +00:00
@find-selection ( position -> addr )
2021-03-07 05:30:16 +00:00
2021-03-11 03:41:46 +00:00
,find-line JSR2 ( find line )
2021-03-10 04:26:33 +00:00
#0000 =pt.x
2021-03-27 02:55:18 +00:00
$loop
~j ~pt.x ADD2 PEK2 #0a EQU ^$end JNZ
~j ~pt.x ADD2 PEK2 #0d EQU ^$end JNZ
2021-03-16 18:25:26 +00:00
( incr ) ~pt.x ++ =pt.x
2021-03-27 02:55:18 +00:00
~pt.x ~position.x -- LTH2 ^$loop JNZ
2021-03-12 04:41:35 +00:00
$end
2021-03-10 04:26:33 +00:00
( return ) ~pt.x ADD2
2021-03-09 19:33:31 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-09 19:33:31 +00:00
@cut ( -- )
2021-03-12 19:37:45 +00:00
,copy JSR2
~selection.to ~selection.from SUB2 ,shift-left JSR2
2021-03-16 18:25:26 +00:00
~selection.from ++ =selection.to
2021-03-12 19:37:45 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-12 19:37:45 +00:00
@copy ( -- )
2021-03-12 19:37:45 +00:00
#0000 =i ( start )
~selection.to ~selection.from SUB2 =j ( end )
~j =clip.len
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
~selection.from ~i ADD2 PEK2 ,clip.body ~i ADD2 POK2
2021-03-16 18:25:26 +00:00
( incr ) ~i ++ =i
2021-03-27 02:55:18 +00:00
~i ~j LTH2 ^$loop JNZ
2021-03-12 19:37:45 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-12 19:37:45 +00:00
@paste ( -- )
2021-03-12 19:37:45 +00:00
~clip.len ,shift-right JSR2
#0000 =i ( start )
~clip.len =j ( end )
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
,clip.body ~i ADD2 PEK2 ~selection.from ~i ADD2 POK2
2021-03-16 18:25:26 +00:00
( incr ) ~i ++ =i
2021-03-27 02:55:18 +00:00
~i ~j LTH2 ^$loop JNZ
2021-03-12 19:37:45 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-12 19:37:45 +00:00
2021-03-09 19:33:31 +00:00
@select ( position -> selection )
,document.body =selection.from #0000 =pt.x #0000 =pt.y
2021-03-12 04:41:35 +00:00
$loop
2021-03-27 02:55:18 +00:00
~selection.from PEK2 #0a NEQ ~selection.from PEK2 #0d NEQ #0101 EQU2 ^$no-space JNZ
2021-03-16 18:25:26 +00:00
( incr ) ~pt.y ++ =pt.y
2021-03-07 05:30:16 +00:00
#0000 =pt.x
2021-03-12 04:41:35 +00:00
$no-space
2021-03-27 02:55:18 +00:00
~pt.y ~position.y -- GTH2 ~pt.x ~position.x -- GTH2 #0101 NEQ2 ^$no-reached JNZ
2021-03-16 18:25:26 +00:00
~selection.from ++ =selection.to
2021-03-14 21:26:17 +00:00
RTN
2021-03-12 04:41:35 +00:00
$no-reached
2021-03-16 18:25:26 +00:00
( incr ) ~pt.x ++ =pt.x
( incr ) ~selection.from ++ =selection.from
2021-03-27 02:55:18 +00:00
~selection.from PEK2 #00 NEQ ^$loop JNZ
2021-03-07 05:30:16 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-07 05:30:16 +00:00
2021-03-10 04:26:33 +00:00
( drawing functions )
2021-03-07 05:30:16 +00:00
@redraw
2021-03-11 03:41:46 +00:00
,draw-textarea JSR2
,draw-scrollbar JSR2
,draw-titlebar JSR2
2021-03-07 05:30:16 +00:00
2021-03-08 05:09:15 +00:00
( save/load icons )
2021-03-16 18:25:26 +00:00
~Screen.height 8- =Sprite.y
~Screen.width #0030 SUB2 =Sprite.x
,eye_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0028 SUB2 =Sprite.x
,name_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0020 SUB2 =Sprite.x
2021-03-14 21:26:17 +00:00
,load_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0018 SUB2 =Sprite.x
2021-03-14 21:26:17 +00:00
,save_icn =Sprite.addr
#02 =Sprite.color
2021-03-07 20:32:19 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-07 05:30:16 +00:00
@draw-short ( short )
=addr
2021-03-24 16:39:19 +00:00
,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
2021-03-14 21:26:17 +00:00
( draw ) #0e =Sprite.color
2021-03-16 18:25:26 +00:00
~Sprite.x 8+ =Sprite.x
2021-03-24 16:39:19 +00:00
,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
2021-03-14 21:26:17 +00:00
( draw ) #0e =Sprite.color
2021-03-16 18:25:26 +00:00
~Sprite.x 8+ =Sprite.x
2021-03-24 16:39:19 +00:00
,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
2021-03-14 21:26:17 +00:00
( draw ) #0e =Sprite.color
2021-03-16 18:25:26 +00:00
~Sprite.x 8+ =Sprite.x
2021-03-24 16:39:19 +00:00
,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
2021-03-14 21:26:17 +00:00
( draw ) #0e =Sprite.color
RTN
2021-03-07 05:30:16 +00:00
@draw-cursor
2021-03-27 11:30:23 +00:00
~mouse.x ~Mouse.x NEQ2
~mouse.y ~Mouse.y NEQ2
2021-03-14 21:26:17 +00:00
#0000 EQU2 RTN? ( Return if unchanged )
2021-03-07 05:30:16 +00:00
( clear last cursor )
2021-03-14 21:26:17 +00:00
~mouse.x =Sprite.x
~mouse.y =Sprite.y
,blank_icn =Sprite.addr
#10 =Sprite.color
2021-03-07 05:30:16 +00:00
( record mouse positions )
2021-03-14 21:26:17 +00:00
~Mouse.x =mouse.x
~Mouse.y =mouse.y
2021-03-07 05:30:16 +00:00
( draw new cursor )
2021-03-14 21:26:17 +00:00
~mouse.x =Sprite.x
~mouse.y =Sprite.y
,cursor_icn =Sprite.addr
#1f ~Mouse.state #01 EQU #0a MUL SUB =Sprite.color
2021-03-07 05:30:16 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-01 19:18:11 +00:00
2021-03-06 19:44:18 +00:00
@draw-textarea ( x y color addr )
2021-03-01 19:18:11 +00:00
2021-03-08 18:30:13 +00:00
,document.body =textarea.addr
2021-03-07 20:32:19 +00:00
( scroll to position )
2021-03-08 18:30:13 +00:00
#0000 =j ( j is linebreaks )
2021-03-27 02:55:18 +00:00
$find-offset
~scroll.y ~j EQU2 ^$find-offset-end JNZ
~textarea.addr PEK2 #0a NEQ ~textarea.addr PEK2 #0d NEQ #0101 EQU2 ^$no-break JNZ
( incr ) ~j ++ =j $no-break
2021-03-16 18:25:26 +00:00
( incr ) ~textarea.addr ++ =textarea.addr
2021-03-27 02:55:18 +00:00
~textarea.addr PEK2 #00 NEQ ^$find-offset JNZ
2021-03-13 04:22:28 +00:00
$find-offset-end
2021-03-07 05:30:16 +00:00
2021-03-14 21:26:17 +00:00
#0018 =Sprite.x #0000 =Sprite.y
2021-03-13 04:22:28 +00:00
~textarea.addr =i
2021-03-08 02:51:29 +00:00
2021-03-12 04:41:35 +00:00
$loop
2021-03-07 05:30:16 +00:00
2021-03-26 18:19:19 +00:00
~Sprite.y ~Screen.height #0010 SUB2 GTH2 ,$end JNZ2
2021-03-10 04:26:33 +00:00
2021-03-26 18:19:19 +00:00
~i PEK2 #0a NEQ ~i PEK2 #0d NEQ #0101 EQU2 ,$no-linebreak JNZ2
2021-03-09 19:33:31 +00:00
( draw linebreak )
2021-03-14 21:26:17 +00:00
,linebreak_icn =Sprite.addr
2021-03-12 04:41:35 +00:00
( draw ) #02
2021-03-16 18:25:26 +00:00
~i ~selection.from -- GTH2
2021-03-13 04:22:28 +00:00
~i ~selection.to LTH2 #0101 EQU2
2021-03-14 21:26:17 +00:00
#06 MUL ADD =Sprite.color
2021-03-08 02:51:29 +00:00
( fill clear )
2021-03-12 04:41:35 +00:00
$fill-clear
2021-03-16 18:25:26 +00:00
( incr ) ~Sprite.x 8+ =Sprite.x
2021-03-14 21:26:17 +00:00
,font =Sprite.addr
#01 =Sprite.color
2021-03-27 02:55:18 +00:00
~Sprite.x ~Screen.width 8- LTH2 ^$fill-clear JNZ
2021-03-13 04:22:28 +00:00
( draw line number )
2021-03-14 21:26:17 +00:00
#0000 =Sprite.x
2021-03-16 18:25:26 +00:00
~scroll.y ~Sprite.y 8/ ADD2 DUP2 SWP POP =k
~position.y EQU2 #05 MUL =l
2021-03-20 03:41:45 +00:00
,font_hex #00 ~k #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
#04 ~l ADD =Sprite.color
2021-03-14 21:26:17 +00:00
#0008 =Sprite.x
,font_hex #00 ~k #0f AND #08 MUL ADD2 =Sprite.addr
#04 ~l ADD =Sprite.color
2021-03-14 21:26:17 +00:00
#0010 =Sprite.x
2021-03-16 18:25:26 +00:00
( incr ) ~Sprite.y 8+ =Sprite.y
2021-03-12 04:41:35 +00:00
$no-linebreak
2021-03-06 19:44:18 +00:00
2021-03-31 03:36:41 +00:00
( get character )
,font #00 ~i PEK2 #20 SUB 8* ADD2 =Sprite.addr
( is a special character )
~i PEK2 #20 GTH ^$no-tab JNZ ,font =Sprite.addr $no-tab
( draw ) #01
~i ~selection.from -- GTH2
~i ~selection.to LTH2 #0101 EQU2
#05 MUL ADD =Sprite.color
2021-03-16 18:25:26 +00:00
( incr ) ~i ++ =i
2021-03-14 21:26:17 +00:00
( incr ) ~Sprite.x #0007 ADD2 =Sprite.x
2021-03-08 18:30:13 +00:00
2021-03-26 18:19:19 +00:00
~i PEK2 #00 NEQ ,$loop JNZ2
2021-03-08 02:51:29 +00:00
2021-03-12 04:41:35 +00:00
$end
2021-03-07 20:32:19 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-01 19:18:11 +00:00
@draw-scrollbar ( -- )
,scrollbar_icn ( keeping a copy on stack )
2021-03-07 05:30:16 +00:00
~Screen.width 8- =Sprite.x
#0008 =Sprite.y
DUP2 =Sprite.addr
2021-03-07 05:30:16 +00:00
#0008 ~Screen.height 8-
$loop
( draw ) #01 =Sprite.color
( incr ) SWP2 8+ DUP2 =Sprite.y SWP2
OVR2 OVR2 LTH2 ^$loop JNZ
POP2 POP2
2021-03-07 20:32:19 +00:00
2021-03-16 18:25:26 +00:00
~scroll.y 8+ =Sprite.y
DUP2 #0008 ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
#0000 =Sprite.y
DUP2 #0010 ADD2 =Sprite.addr
( draw ) #04 =Sprite.color
2021-03-07 20:32:19 +00:00
2021-03-16 18:25:26 +00:00
~Screen.height 8- =Sprite.y
#0018 ADD2 =Sprite.addr
( draw ) #04 =Sprite.color
2021-03-07 05:30:16 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-07 05:30:16 +00:00
@draw-titlebar
2021-03-16 18:25:26 +00:00
#0018 ~Screen.height 8- #09 ,filepath
2021-03-14 21:26:17 +00:00
( load ) =label.addr =label.color =Sprite.y =Sprite.x
2021-03-07 05:30:16 +00:00
~label.addr
2021-03-27 02:55:18 +00:00
$loop
2021-03-24 16:39:19 +00:00
( draw ) DUP2 PEK2 #00 SWP #20 SUB 8* ,font ADD2 =Sprite.addr ~label.color =Sprite.color
2021-03-16 18:25:26 +00:00
( incr ) ++
( incr ) ~Sprite.x 8+ =Sprite.x
2021-03-27 02:55:18 +00:00
DUP2 PEK2 #00 NEQ ^$loop JNZ
2021-03-07 05:30:16 +00:00
POP2
2021-03-08 18:30:13 +00:00
( selection )
2021-03-11 03:41:46 +00:00
~selection.from ,document.body SUB2 ,draw-short JSR2
2021-03-08 18:30:13 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-07 05:30:16 +00:00
2021-03-07 20:32:19 +00:00
@font_hex ( 0-F TODO: should pull from @font instead.. )
2021-03-01 19:18:11 +00:00
[
2021-03-07 20:32:19 +00:00
003c 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00
007e 4078 4040 7e00 007e 4078 4040 4000
2021-03-07 05:30:16 +00:00
]
@font ( specter8-frag font )
[
0000 0000 0000 0000 0008 0808 0800 0800
0014 1400 0000 0000 0024 7e24 247e 2400
0008 1e28 1c0a 3c08 0000 2204 0810 2200
0030 4832 4c44 3a00 0008 1000 0000 0000
0004 0808 0808 0400 0020 1010 1010 2000
0000 2214 0814 2200 0000 0808 3e08 0800
0000 0000 0000 0810 0000 0000 3e00 0000
0000 0000 0000 0800 0000 0204 0810 2000
003c 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00
0000 0010 0000 1000 0000 1000 0010 1020
0000 0810 2010 0800 0000 003e 003e 0000
0000 1008 0408 1000 003c 420c 1000 1000
003c 4232 4a42 3c00 003c 4242 7e42 4200
007c 427c 4242 7c00 003c 4240 4042 3c00
007c 4242 4242 7c00 007e 4078 4040 7e00
007e 4078 4040 4000 003c 4240 4642 3c00
0042 427e 4242 4200 001c 0808 0808 1c00
007e 0202 0242 3c00 0042 4478 4442 4200
0040 4040 4040 7e00 0042 665a 4242 4200
0042 6252 4a46 4200 003c 4242 4242 3c00
007c 4242 7c40 4000 003c 4242 4244 3a00
007c 4242 7c44 4200 003e 403c 0242 3c00
007e 0808 0808 1000 0042 4242 4244 3a00
0042 4242 4224 1800 0042 4242 5a66 4200
0042 423c 4242 4200 0042 423e 0242 3c00
007e 020c 3040 7e00 000c 0808 0808 0c00
0040 2010 0804 0200 0030 1010 1010 3000
0008 1400 0000 0000 0000 0000 0000 7e00
0008 0400 0000 0000 0000 3c02 3e42 3a00
0040 407c 4242 7c00 0000 3c42 4042 3c00
0002 023e 4242 3e00 0000 3c42 7e40 3e00
0000 3e40 7840 4000 0000 3c42 3e02 3c00
0040 405c 6242 4200 0008 0018 0808 0400
0008 0018 0808 4830 0040 4244 7844 4200
0010 1010 1010 0c00 0000 6c52 5252 5200
0000 5c62 4242 4200 0000 3c42 4242 3c00
0000 7c42 427c 4040 0000 3e42 423e 0202
0000 5c62 4040 4000 0000 3e40 3c02 7c00
0008 7e08 0808 1000 0000 4242 4244 3a00
0000 4242 4224 1800 0000 5252 5252 2e00
0000 4224 1824 4200 0000 4242 3e02 7c00
0000 7e02 3c40 7e00 000c 0810 1008 0c00
0008 0808 0808 0800 0030 1008 0810 3000
0000 0032 4c00 0000 3c42 99a1 a199 423c
2021-03-01 19:18:11 +00:00
]
( interface )
@eye_icn
[ 0038 4492 2810 0000 ] ( open )
[ 0000 0082 4438 0000 ] ( closed )
@scrollbar_icn
[ aa55 aa55 aa55 aa55 ] ( bg )
[ ffff ffff ffff ffff ] ( fg )
[ 0010 387c fe10 1010 ] ( up )
[ 0010 1010 fe7c 3810 ] ( down )
@name_icn [ 1054 28c6 2854 1000 ]
@load_icn [ feaa d6aa d4aa f400 ]
@save_icn [ fe82 8282 848a f400 ]
2021-03-09 19:33:31 +00:00
@linebreak_icn [ 003e 7474 3414 1400 ]
2021-03-07 05:30:16 +00:00
@blank_icn [ 0000 0000 0000 0000 ]
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
2021-03-12 19:37:45 +00:00
@filepath1 [ projects/examples/gui.hover.usm 00 ]
@filepath [ projects/examples/dev.time.usm 00 ]
2021-03-06 19:44:18 +00:00
2021-03-28 18:06:36 +00:00
;clip { len 2 body 256 }
;document { eof 2 body 2 }