Support setting pty size in script command

This commit is contained in:
Justine Tunney 2024-10-21 22:55:03 -07:00
parent 23da0d75a5
commit 26663dea9c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -49,10 +49,10 @@
* @fileoverview Terminal Screencast Recorder / Player, e.g.
*
* make o//examples/script.com
* o//examples/script.com -r
* o//examples/script.com -w80 -h24 -r recording.tty
* # type stuff..
* # CTRL-D
* o//examples/script.com -p typescript
* o//examples/script.com -p recording.tty
*
* @note works on Linux, OpenBSD, NetBSD, FreeBSD, MacOS
* @see https://asciinema.org/
@ -103,9 +103,9 @@ main(int argc, char *argv[])
fd_set rfd;
int fm_fd;
int aflg, Fflg, kflg, pflg, ch, k, n;
int flushtime, readstdin;
int flushtime, readstdin, width, height;
aflg = Fflg = kflg = pflg = 0;
aflg = Fflg = kflg = pflg = height = width = 0;
usesleep = 1;
rawout = 0;
flushtime = 30;
@ -115,7 +115,7 @@ main(int argc, char *argv[])
(void)fm_fd;
while ((ch = getopt(argc, argv, "adeFfkpqrt:")) != -1)
while ((ch = getopt(argc, argv, "adeFfkpqrt:w:h:")) != -1)
switch(ch) {
case 'a':
aflg = 1;
@ -145,6 +145,12 @@ main(int argc, char *argv[])
if (flushtime < 0)
err(1, "invalid flush time %d", flushtime);
break;
case 'w':
width = atoi(optarg);
break;
case 'h':
height = atoi(optarg);
break;
case '?':
default:
usage();
@ -172,6 +178,10 @@ main(int argc, char *argv[])
if (openpty(&master, &slave, NULL, NULL, NULL) == -1)
err(1, "openpty");
} else {
if (width)
win.ws_col = width;
if (height)
win.ws_row = height;
if (openpty(&master, &slave, NULL, &tt, &win) == -1)
err(1, "openpty");
ttyflg = 1;