Skip to content

Commit

Permalink
Support setting pty size in script command
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Oct 22, 2024
1 parent 23da0d7 commit 26663de
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions examples/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 26663de

Please sign in to comment.