add pasting, start adding mouse

This commit is contained in:
~d6 2023-01-31 22:28:41 -05:00
parent d4c7ca30ca
commit 2a4b56750d
1 changed files with 59 additions and 2 deletions

View File

@ -69,6 +69,9 @@
@max-y $2 ( rows-1 ) @max-y $2 ( rows-1 )
@col-bytes $2 ( 2*cols ) @col-bytes $2 ( 2*cols )
@debug $1 ( use debug log? ) @debug $1 ( use debug log? )
@lastmouse-x $2 ( last mouse x )
@lastmouse-y $2 ( last mouse y )
@lastmouse-st $1 ( last mouse press )
( terminal settings ) ( terminal settings )
@irm $1 ( 01: insert and move right, 00: replace and overwrite ) @irm $1 ( 01: insert and move right, 00: replace and overwrite )
@ -128,6 +131,7 @@
( set up interrupts ) ( set up interrupts )
;redraw .Screen/vect DEO2 ( set up screen ) ;redraw .Screen/vect DEO2 ( set up screen )
;on-key .Controller/vect DEO2 ( set up keyboard ) ;on-key .Controller/vect DEO2 ( set up keyboard )
;on-mouse .Mouse/vect DEO2 ( set up mouse )
;on-read .Console/vect DEO2 ( set up stdin ) ;on-read .Console/vect DEO2 ( set up stdin )
( set to 01 to enable debug log ) ( set to 01 to enable debug log )
@ -236,6 +240,56 @@
#1b STHkr DEO LIT "[ STHkr DEO STHr DEO #1b STHkr DEO LIT "[ STHkr DEO STHr DEO
JMP2r JMP2r
@paste-from-buf ( size* -> )
;paste-buf SWP2 OVR2 ADD2 SWP2 ( limit* start* )
&loop ( limit* pos* )
LDAk .Console/w DEO INC2 ( limit* pos+1* )
GTH2k ?&loop POP2 POP2 JMP2r
@paste-snarf ( -> )
;&path .File2/name DEO2 ( )
#0100 .File2/len DEO2 ( )
&loop ( )
;paste-buf .File2/r DEO2 ( )
.File2/ok DEI2 ( size* )
DUP2 #0000 EQU2 ?&failed ( size* )
DUP2 paste-from-buf ( size* )
#0100 LTH2 ?&done ( )
!&loop ( )
&failed POP2
&done JMP2r [ &path ".snarf 00 ]
@on-click-down ( click^ -> )
#02 AND ?&middle-click !&done
&middle-click paste-snarf
&done JMP2r
@on-click-up ( unclick^ -> )
POP JMP2r
@on-move
.Mouse/x DEI2 .lastmouse-x LDZ2 NEQ2 ?&redraw
.Mouse/y DEI2 .lastmouse-y LDZ2 NEQ2 ?&redraw
JMP2r
&redraw
.Mouse/x DEI2 .Screen/x DEO2
.Mouse/y DEI2 .Screen/y DEO2
#02f0 ;ascii ADD2 .Screen/addr DEO2
#43 .Screen/sprite DEO
.Mouse/x DEI2 .lastmouse-x STZ2
.Mouse/y DEI2 .lastmouse-y STZ2
JMP2r
@on-mouse ( -> )
.lastmouse-st LDZ ( last )
.Mouse/state DEI ( last st )
STHk OVR EOR STHkr AND ( last (last^st)&st [st] )
on-click-down ( last [st] )
DUP STHkr EOR AND ( last&(last^st) [st] )
on-click-up ( [st] )
STHr .lastmouse-st STZ ( )
( on-move ) BRK ( )
@on-key ( -> ) @on-key ( -> )
.Controller/key DEI ?&ok !on-button .Controller/key DEI ?&ok !on-button
&ok alt ?on-alt-key &ok alt ?on-alt-key
@ -615,7 +669,7 @@
@down ( -> ) @down ( -> )
#0001 !down-n #0001 !down-n
( @insert ( c^ -> ) @insert ( c^ -> )
.attr LDZ SWP !insert-cell .attr LDZ SWP !insert-cell
@insert-cell ( cell* -> ) @insert-cell ( cell* -> )
@ -627,7 +681,7 @@
INC2 LTH2k ?&loop ( cell* last pos+1* ) INC2 LTH2k ?&loop ( cell* last pos+1* )
POP2 POP2 ( cell* ) POP2 POP2 ( cell* )
&replace ( cell* ) &replace ( cell* )
cur-addr STA2 JMP2r ( ) ) cur-addr STA2 JMP2r ( )
@forward-n-tabs ( n* -> ) @forward-n-tabs ( n* -> )
#0001 SUB2 #0008 MUL2 ( i=(n-1)8* ) #0001 SUB2 #0008 MUL2 ( i=(n-1)8* )
@ -770,6 +824,9 @@
( store up to 8 arguments for control sequences ) ( store up to 8 arguments for control sequences )
@args $10 &pos $2 @args $10 &pos $2
( paste buffer )
@paste-buf $100
( 128 1-bit 8x8 tiles for ASCII 7-bit characters ) ( 128 1-bit 8x8 tiles for ASCII 7-bit characters )
@ascii @ascii
~chr/ascii.tal ~chr/ascii.tal