From 99337665f6c1ca0f0e8b0f63320de00feec177c3 Mon Sep 17 00:00:00 2001 From: d_m Date: Thu, 7 Dec 2023 00:00:15 -0500 Subject: [PATCH] term.tal works --- src/devices/console.c | 3 ++- src/uxn11.c | 5 ++++- test/term.tal | 23 ++++++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/devices/console.c b/src/devices/console.c index 46c1151..dfc19f6 100644 --- a/src/devices/console.c +++ b/src/devices/console.c @@ -83,7 +83,8 @@ static void start_fork_pty(UxnSubprocess *child, int mode) { int fd = -1; - pid_t pid = forkpty(&fd, NULL, NULL, NULL); + struct winsize ws = {23, 80, 8, 12}; // rows, cols, xps, ypx + pid_t pid = forkpty(&fd, NULL, NULL, &ws); if(pid < 0) { /* failure */ fprintf(stderr, "parent fork failure\n"); } else if(pid == 0) { /* child */ diff --git a/src/uxn11.c b/src/uxn11.c index 4f60117..91dd136 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -273,7 +273,10 @@ emu_run(Uxn *u, char *rom) /* main loop */ while(!u->dev[0x0f]) { - if(poll(fds, 3, 1000) <= 0) + for(i = 0; i < 4; i++) { + fds[i + 3].fd = get_child(i)->fd_out; + } + if(poll(fds, 7, 1000) <= 0) continue; while(XPending(display)) emu_event(u); diff --git a/test/term.tal b/test/term.tal index dd1d07b..ec6da7f 100644 --- a/test/term.tal +++ b/test/term.tal @@ -175,24 +175,32 @@ ;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 + ( these only work with a patched uxnemu ) ( on other emulators they should be no-ops ) -@setup-subprocess ( -> ) - #80 .Console/opts DEO +@setup-shell ( -> ) + ( 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 @@ -244,7 +252,7 @@ .rows LDZ2 #000c MUL2 ADD2 .Screen/h DEO2 JMP2r -@shell "bash 20 "-i 00 +@shell "bash 20 "-l 20 "-i 00 @load-theme ( -> ) ;&path .File1/name DEO2 @@ -681,6 +689,7 @@ &done .Console/proc-put DEO BRK @on-read-priv ( -> BRK ) + .Console/type DEI #21 EQU ?{ BRK } .Console/stdin DEI DUP LIT "; EQU ?next-arg DUP LIT "0 LTH ?end-arg-priv @@ -691,6 +700,7 @@ POP ;on-read-priv .Console/vect DEO2 BRK @on-read-csi ( -> BRK ) + .Console/type DEI #21 EQU ?{ BRK } .Console/stdin DEI DUP LIT "? EQU ?start-priv DUP LIT "; EQU ?next-arg @@ -699,6 +709,7 @@ !add-to-arg @on-read-osc ( -> BRK ) + .Console/type DEI #21 EQU ?{ BRK } .Console/stdin DEI DUP #07 ( bell ) EQU ?&end-osc #9c ( esc-\ ) EQU ?&end-osc BRK @@ -979,6 +990,7 @@ JMP2r @on-read-esc ( -> BRK ) + .Console/type DEI #21 EQU ?{ BRK } .Console/stdin DEI DUP debug-esc DUP LIT "D EQU ?exec-ind @@ -1026,6 +1038,7 @@ POP reset-args ;on-read-osc .Console/vect DEO2 BRK @on-read ( -> BRK ) + .Console/type DEI #21 EQU ?{ BRK } .Console/stdin DEI read BRK @read ( c^ -> )