summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-12 21:14:43 -0400
committerJune McEnroe <june@causal.agency>2019-07-12 21:14:43 -0400
commitde9409e3888ba92b0dca38ac81fe3e4b17e7f466 (patch)
tree621f1f2981b0a8995ec7e89803a52fafd819cd34 /bin
parentAdd DCH to shotty (diff)
downloadsrc-de9409e3888ba92b0dca38ac81fe3e4b17e7f466.tar.gz
src-de9409e3888ba92b0dca38ac81fe3e4b17e7f466.zip
Use -s to infer terminal size
Diffstat (limited to 'bin')
-rw-r--r--bin/man1/shotty.114
-rw-r--r--bin/shotty.c12
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));
17-08-31Clean up merge toolJune McEnroe 2017-08-31Choose B for tiles with equal modify timesJune McEnroe 2017-08-31Add quick data file merge toolJune McEnroe 2017-08-30Use only foreground color for selecting spawnJune McEnroe 2017-08-29Add four additional spawnsJune McEnroe 2017-08-28Add respawningJune McEnroe 2017-08-26Move license above includesJune McEnroe 2017-08-26Snapshot metadataJune McEnroe 2017-08-26Add meta.c to READMEJune McEnroe 2017-08-26Use MakefileJune McEnroe