term updated for uxn11 and pipes

This commit is contained in:
~d6 2024-02-27 14:48:50 -05:00
parent d758578ef3
commit 773c5abfcb
1 changed files with 111 additions and 37 deletions

148
term.tal
View File

@ -76,13 +76,32 @@
( ESC [ ? 1060 l -> unset legacy keyboard emulation )
( ESC [ ? 1061 h -> set VT220 keyboard emulation )
|00 @System [ &vect $2 &expansion $2 &title $2 &metadata $2 &r $2 &g $2 &b $2 ]
|10 @Console [ &vect $2 &r $1 &exec $2 &mode $1 &dead $1 &exit $1 &w $1 ]
|20 @Screen [ &vect $2 &w $2 &h $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &px $1 &sprite $1 ]
|80 @Controller [ &vect $2 &button $1 &key $1 &fn $1 ]
|90 @Mouse [ &vect $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 ]
|a0 @File1 [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ]
|b0 @File2 [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ]
|00 @System [
&vect $2 &expansion $2 &title $2 &metadata $2
&r $2 &g $2 &b $2 ]
|10 @Console [
&vect $2 &stdin $1 &pad1 $4 &type $1
&stdout $1 &stderr $1 &proc-put $1 &pad2 $1 &param $2 &opts $1 &host-put $1 ]
|20 @Screen [
&vect $2 &w $2 &h $2 &auto $1 &pad $1
&x $2 &y $2 &addr $2 &px $1 &sprite $1 ]
|80 @Controller [
&vect $2 &button $1 &key $1 &fn $1 ]
|90 @Mouse [
&vect $2 &x $2 &y $2 &state $1 &pad1 $1
&pad2 $2 &scrollx $2 &scrolly $2 &pad3 $2 ]
|a0 @File1 [
&vect $2 &ok $2 &stat $2 &del $1 &append $1
&name $2 &len $2 &r $2 &w $2 ]
|b0 @File2 [
&vect $2 &ok $2 &stat $2 &del $1 &append $1
&name $2 &len $2 &r $2 &w $2 ]
|0000
@tint $1 ( draw mode. 01=regular, 04=inverted )
@ -124,13 +143,17 @@
@visual-bell $1 ( flash visual bell? otherwise do nothing )
@border-pad $2 ( use border? should be 0000 or 0010 )
( subprocess )
@put-port $1
@get-type $1
|0100
( metadata )
;meta .System/metadata DEO2
;meta/name .System/title DEO2
( user configuration defaults )
#01 .debug STZ
#00 .debug STZ
#01 .show-banner STZ
( #0010 .border-pad STZ2 )
#0000 .border-pad STZ2
@ -156,23 +179,54 @@
;on-mouse .Mouse/vect DEO2 ( set up mouse callback )
;on-read .Console/vect DEO2 ( set up stdin callback )
setup-subprocess ( set up experimental subprocess support )
setup-shell ( set up experimental subprocess support )
reset-terminal ( initialize terminal state and settings )
setup-debugging ( set up debugging if requested )
draw-banner ( draw banner if requested )
BRK
@env "TERM=ansi 00
@query
( expansion cmd ) 03
( console device ) 10
( uuid ) 0123 1250 d878 4462 bc41 d092 7645 a2fa
( version ) 00
( flags ) &flags 0000
@has-subprocess ( -> bool^ )
;query .System/expansion DEO2
;query/flags LDA2 #00ff EQU2 JMP2r
( these only work with a patched uxnemu )
( on other emulators they should be no-ops )
@setup-subprocess ( -> )
;shell .Console/exec DEO2 ( set up bash subprocess )
#80 .Console/mode DEO ( start bash subprocess )
@setup-shell ( -> )
has-subprocess ?{
( without subprocess, just use stdin/stdout )
.Console/stdout .put-port STZ
#01 .get-type STZ
JMP2r
}
( with subprocess, use proc put/get )
.Console/proc-put .put-port STZ
#21 .get-type STZ
( setenv 'TERM=ansi' )
;env .Console/param DEO2
#11 .Console/host-put DEO
( exec 'bash -i' )
#81 .Console/opts DEO
;shell .Console/param DEO2
#01 .Console/host-put DEO
( TODO: run stty to communicate terminal size? )
JMP2r
@setup-debugging ( -> )
.debug LDZ ?&continue JMP2r &continue
( #99 #010e DEO ) ( put 99 in wst so #010e DEO reliably logs )
;debug-log .File1/name DEO2
#01 .File1/append DEO
JMP2r
@ -224,7 +278,7 @@
.rows LDZ2 #000c MUL2 ADD2 .Screen/h DEO2
JMP2r
@shell "bash 00 "-i 00 00
@shell "bash 20 "-l 20 "-i 00
@load-theme ( -> )
;&path .File1/name DEO2
@ -381,18 +435,18 @@
( send ESC [ $c )
@arrow ( c^ -> )
.Console/w STH
( .Console/proc-put ) .put-port LDZ STH
#1b STHkr DEO LIT "[ STHkr DEO STHr DEO
JMP2r
@paste-from-buf ( size* -> )
;paste-buf SWP2 OVR2 ADD2 SWP2 ( limit* start* )
&loop ( limit* pos* )
LDAk .Console/w DEO INC2 ( limit* pos+1* )
LDAk ( .Console/proc-put ) .put-port LDZ DEO INC2 ( limit* pos+1* )
GTH2k ?&loop POP2 POP2 JMP2r
@bracket-paste ( c^ -> )
.Console/w STH
( .Console/proc-put ) .put-port LDZ STH
#1b STHkr DEO
LIT "[ STHkr DEO
LIT "2 STHkr DEO
@ -607,16 +661,16 @@
.Controller/key DEI
DUP #08 NEQ ?&done
POP #7f ( send DEL instead of BS )
&done .Console/w DEO BRK
&done ( .Console/proc-put ) .put-port LDZ DEO BRK
@ctrl ( -> is-down? ) .Controller/button DEI #01 AND JMP2r
@alt ( -> is-down? ) .Controller/button DEI #02 AND JMP2r
( alt-XYZ emits ESC and then emits XYZ )
@on-alt-key ( -> BRK )
#1b .Console/w DEO
#1b ( .Console/proc-put ) .put-port LDZ DEO
ctrl ?on-ctrl-key
.Controller/key DEI .Console/w DEO BRK
.Controller/key DEI ( .Console/proc-put ) .put-port LDZ DEO BRK
( control seqs: )
( ctrl-sp -> 00 )
@ -651,10 +705,15 @@
&rs #1e !&done
&us #1f !&done
&c1 LIT "@ SUB
&done .Console/w DEO BRK
&done ( .Console/proc-put ) .put-port LDZ DEO BRK
@read-or-brk ( -> BRK? )
.Console/type DEI .get-type LDZ EQU ?{ BRK } JMP2r
@on-read-priv ( -> BRK )
.Console/r DEI
read-or-brk
( .Console/type DEI #21 EQU ?{ BRK } )
.Console/stdin DEI
DUP LIT "; EQU ?next-arg
DUP LIT "0 LTH ?end-arg-priv
DUP LIT "9 GTH ?end-arg-priv
@ -664,7 +723,9 @@
POP ;on-read-priv .Console/vect DEO2 BRK
@on-read-csi ( -> BRK )
.Console/r DEI
read-or-brk
( .Console/type DEI #21 EQU ?{ BRK } )
.Console/stdin DEI
DUP LIT "? EQU ?start-priv
DUP LIT "; EQU ?next-arg
DUP LIT "0 LTH ?end-arg
@ -672,7 +733,9 @@
!add-to-arg
@on-read-osc ( -> BRK )
.Console/r DEI
read-or-brk
( .Console/type DEI #21 EQU ?{ BRK } )
.Console/stdin DEI
DUP #07 ( bell ) EQU ?&end-osc
#9c ( esc-\ ) EQU ?&end-osc BRK
&end-osc ;on-read .Console/vect DEO2 BRK
@ -873,12 +936,12 @@
@dsr ( n* -> )
#0006 NEQ2 ?&done
#1b .Console/w DEO
LIT "[ .Console/w DEO
#1b ( .Console/proc-put ) .put-port LDZ DEO
LIT "[ ( .Console/proc-put ) .put-port LDZ DEO
.cur-y LDZ2 INC2 emit-dec2
LIT "; .Console/w DEO
LIT "; ( .Console/proc-put ) .put-port LDZ DEO
.cur-x LDZ2 INC2 emit-dec2
LIT "R .Console/w DEO
LIT "R ( .Console/proc-put ) .put-port LDZ DEO
&done BRK
@cnl ( n* -> ) clear-cursor #0000 .cur-x STZ2 !down-n
@ -948,7 +1011,9 @@
JMP2r
@on-read-esc ( -> BRK )
.Console/r DEI
read-or-brk
( .Console/type DEI #21 EQU ?{ BRK } )
.Console/stdin DEI
DUP debug-esc
DUP LIT "D EQU ?exec-ind
DUP LIT "E EQU ?exec-nel
@ -995,7 +1060,9 @@
POP reset-args ;on-read-osc .Console/vect DEO2 BRK
@on-read ( -> BRK )
.Console/r DEI read BRK
read-or-brk
( .Console/type DEI #21 EQU ?{ BRK } )
.Console/stdin DEI read BRK
@read ( c^ -> )
DUP debug-read
@ -1223,7 +1290,7 @@
JMP2r ( )
@highlight-cell ( cell* -> )
NIP LITr 47 ( c^ [tint^] )
NIP LITr 07 ( c^ [tint^] )
#00 SWP #40 SFT2 ;cp437 ADD2 ( addr* [tint^] )
.Screen/addr DEO2k ( addr* s^ [tint^] )
STHkr .Screen/sprite DEO ( addr* s^ [tint^] )
@ -1256,14 +1323,21 @@
( emit a signed short as a decimal )
@emit-sdec2 ( n* -> )
DUP2k #1f SFT2 EQUk ?&s LIT2 "- 18 DEO
DUP2k #1f SFT2 EQUk ?&s LIT "- ( .Console/proc-put ) .put-port LDZ DEO
&s MUL2 SUB2 ( fall-through to emit-dec2 )
( emit an unsigned short as a decimal )
@emit-dec2 ( n* -> )
LITr ff00 &read #000a DIV2k STH2k MUL2 SUB2 STH2r INCr ORAk ?&read
POP2 &write NIP #30 ADD #18 DEO OVRr ADDr STHkr ?&write
POP2r JMP2r
LIT2r ff00 ( n* [ff^ 0^] )
&read ( ... x* )
#000a DIV2k STH2k ( x* 10* x/10* [ff^ i^ x/10*] )
MUL2 SUB2 STH2r ( x%10* x/10* [ff^ i^] )
INCr ORAk ?&read ( x%10* x/10* [ff^ i+1^] )
POP2 ( x0* ... xn* [ff^ i+1^] )
&write
NIP #30 ADD ( .Console/proc-put ) .put-port LDZ DEO ( x0* ... xn-1* [ff^ j^] )
OVRr ADDr STHkr ?&write ( x* ... xn-1* [ff^ j-1^] )
POP2r JMP2r ( )
@debug-log "debug_term.log 00
@scratch $40 &pos $2
@ -1300,9 +1374,9 @@
0d 0a
20 20 c9 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd bb 0d 0a
20 20 ba 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ba 0d 0a
20 20 ba 20 20 "d "e "t "e "r "m 20 20 "v "1 "0 20 20 ba 0d 0a
20 20 ba 20 20 "d "e "t "e "r "m 20 20 "v "1 "2 20 20 ba 0d 0a
20 20 ba 20 20 20 20 "b "y 20 "d "_ "m 20 20 20 20 20 ba 0d 0a
20 20 ba 20 20 "1 "8 20 "m "a "r 20 "2 "0 "2 "3 20 20 ba 0d 0a
20 20 ba 20 20 "1 "5 20 "d "e "c 20 "2 "0 "2 "3 20 20 ba 0d 0a
20 20 ba 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ba 0d 0a
20 20 c8 cd cd cb cd cd cd cd cd cd cd cd cd cb cd cd bc 0d 0a
20 20 c9 cb cb ce cb cb cb cb cb cb cb cb cb ce cb cb bb 0d 0a