diff options
Diffstat (limited to '')
-rw-r--r-- | bin/man1/shotty.1 | 14 | ||||
-rw-r--r-- | bin/shotty.c | 12 |
2 files changed, 15 insertions, 11 deletions
diff --git a/bin/man1/shotty.1 b/bin/man1/shotty.1 index e6ecf2ca..029bb036 100644 --- a/bin/man1/shotty.1 +++ b/bin/man1/shotty.1 @@ -1,4 +1,4 @@ -.Dd July 11, 2019 +.Dd July 12, 2019 .Dt SHOTTY 1 .Os . @@ -8,7 +8,7 @@ . .Sh SYNOPSIS .Nm -.Op Fl B +.Op Fl Bs .Op Fl b Ar bg .Op Fl f Ar fg .Op Fl h Ar rows @@ -42,13 +42,15 @@ The default value is 7 (white). . .It Fl h Ar rows Set the terminal height. -If unset, -the height of the current terminal is used. +The default value is 24. +. +.It Fl s +Set the terminal size +from the current terminal size. . .It Fl w Ar cols Set the terminal width. -If unset, -the width of the current terminal is used. +The default value is 80. .El . .Sh SEE ALSO diff --git a/bin/shotty.c b/bin/shotty.c index a882e662..2d1e1f69 100644 --- a/bin/shotty.c +++ b/bin/shotty.c @@ -48,7 +48,7 @@ struct Cell { }; static struct Style def = { .fg = 7 }; -static uint rows, cols; +static uint rows = 24, cols = 80; static uint y, x; static bool insert; @@ -294,15 +294,17 @@ int main(int argc, char *argv[]) { setlocale(LC_CTYPE, ""); bool bright = false; + bool size = false; FILE *file = stdin; int opt; - while (0 < (opt = getopt(argc, argv, "Bb:f:h:w:"))) { + while (0 < (opt = getopt(argc, argv, "Bb:f:h:sw:"))) { switch (opt) { break; case 'B': bright = true; break; case 'b': def.bg = strtoul(optarg, NULL, 0); break; case 'f': def.fg = strtoul(optarg, NULL, 0); break; case 'h': rows = strtoul(optarg, NULL, 0); + break; case 's': size = true; break; case 'w': cols = strtoul(optarg, NULL, 0); break; default: return EX_USAGE; } @@ -313,12 +315,12 @@ int main(int argc, char *argv[]) { if (!file) err(EX_NOINPUT, "%s", argv[optind]); } - if (!rows || !cols) { + if (size) { struct winsize window; int error = ioctl(STDERR_FILENO, TIOCGWINSZ, &window); if (error) err(EX_IOERR, "ioctl"); - if (!rows) rows = window.ws_row; - if (!cols) cols = window.ws_col; + rows = window.ws_row; + cols = window.ws_col; } cells = calloc(rows * cols, sizeof(*cells)); |