term.tal works

This commit is contained in:
~d6 2023-12-07 00:00:15 -05:00
parent a0a0eecfc4
commit 99337665f6
3 changed files with 24 additions and 7 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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^ -> )