mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Support setting pty size in script command
This commit is contained in:
parent
23da0d75a5
commit
26663dea9c
1 changed files with 15 additions and 5 deletions
|
@ -49,10 +49,10 @@
|
||||||
* @fileoverview Terminal Screencast Recorder / Player, e.g.
|
* @fileoverview Terminal Screencast Recorder / Player, e.g.
|
||||||
*
|
*
|
||||||
* make o//examples/script.com
|
* make o//examples/script.com
|
||||||
* o//examples/script.com -r
|
* o//examples/script.com -w80 -h24 -r recording.tty
|
||||||
* # type stuff..
|
* # type stuff..
|
||||||
* # CTRL-D
|
* # CTRL-D
|
||||||
* o//examples/script.com -p typescript
|
* o//examples/script.com -p recording.tty
|
||||||
*
|
*
|
||||||
* @note works on Linux, OpenBSD, NetBSD, FreeBSD, MacOS
|
* @note works on Linux, OpenBSD, NetBSD, FreeBSD, MacOS
|
||||||
* @see https://asciinema.org/
|
* @see https://asciinema.org/
|
||||||
|
@ -103,9 +103,9 @@ main(int argc, char *argv[])
|
||||||
fd_set rfd;
|
fd_set rfd;
|
||||||
int fm_fd;
|
int fm_fd;
|
||||||
int aflg, Fflg, kflg, pflg, ch, k, n;
|
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;
|
usesleep = 1;
|
||||||
rawout = 0;
|
rawout = 0;
|
||||||
flushtime = 30;
|
flushtime = 30;
|
||||||
|
@ -115,7 +115,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
(void)fm_fd;
|
(void)fm_fd;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "adeFfkpqrt:")) != -1)
|
while ((ch = getopt(argc, argv, "adeFfkpqrt:w:h:")) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
aflg = 1;
|
aflg = 1;
|
||||||
|
@ -145,6 +145,12 @@ main(int argc, char *argv[])
|
||||||
if (flushtime < 0)
|
if (flushtime < 0)
|
||||||
err(1, "invalid flush time %d", flushtime);
|
err(1, "invalid flush time %d", flushtime);
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
width = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
height = atoi(optarg);
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -172,6 +178,10 @@ main(int argc, char *argv[])
|
||||||
if (openpty(&master, &slave, NULL, NULL, NULL) == -1)
|
if (openpty(&master, &slave, NULL, NULL, NULL) == -1)
|
||||||
err(1, "openpty");
|
err(1, "openpty");
|
||||||
} else {
|
} else {
|
||||||
|
if (width)
|
||||||
|
win.ws_col = width;
|
||||||
|
if (height)
|
||||||
|
win.ws_row = height;
|
||||||
if (openpty(&master, &slave, NULL, &tt, &win) == -1)
|
if (openpty(&master, &slave, NULL, &tt, &win) == -1)
|
||||||
err(1, "openpty");
|
err(1, "openpty");
|
||||||
ttyflg = 1;
|
ttyflg = 1;
|
||||||
|
|
Loading…
Reference in a new issue