summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-11 17:25:10 -0400
committerJune McEnroe <june@causal.agency>2019-07-11 17:25:10 -0400
commit3a87c6f209a1a197787e05d226f76106c11a063e (patch)
tree258bb7cc8d2a35e4524bf074fcf6076d7424777e /bin
parentOutput <b>, <i>, <u> in shotty (diff)
downloadsrc-3a87c6f209a1a197787e05d226f76106c11a063e.tar.gz
src-3a87c6f209a1a197787e05d226f76106c11a063e.zip
Add bright option to shotty
Diffstat (limited to 'bin')
-rw-r--r--bin/man1/shotty.19
-rw-r--r--bin/shotty.c20
2 files changed, 22 insertions, 7 deletions
diff --git a/bin/man1/shotty.1 b/bin/man1/shotty.1
index 7500f20b..e6ecf2ca 100644
--- a/bin/man1/shotty.1
+++ b/bin/man1/shotty.1
@@ -1,4 +1,4 @@
-.Dd July 9, 2019
+.Dd July 11, 2019
 .Dt SHOTTY 1
 .Os
 .
@@ -8,6 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
+.Op Fl B
 .Op Fl b Ar bg
 .Op Fl f Ar fg
 .Op Fl h Ar rows
@@ -28,16 +29,22 @@ Terminal output can be captured with
 .Pp
 The arguments are as follows:
 .Bl -tag -width "-w cols"
+.It Fl B
+Replace bold with bright colors.
+.
 .It Fl b Ar bg
 Set the default background color.
 The default value is 0 (black).
+.
 .It Fl f Ar fg
 Set the default foreground color.
 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.
+.
 .It Fl w Ar cols
 Set the terminal width.
 If unset,
diff --git a/bin/shotty.c b/bin/shotty.c
index d4a7b160..a70f40b8 100644
--- a/bin/shotty.c
+++ b/bin/shotty.c
@@ -255,11 +255,13 @@ html(const struct Style *prev, const struct Cell *cell) {
 int main(int argc, char *argv[]) {
 	setlocale(LC_CTYPE, "");
 
+	bool bright = false;
 	FILE *file = stdin;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "b:f:h:w:"))) {
+	while (0 < (opt = getopt(argc, argv, "Bb:f:h:w:"))) {
 		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);
@@ -285,11 +287,9 @@ int main(int argc, char *argv[]) {
 	if (!cells) err(EX_OSERR, "calloc");
 
 	style = def;
-	for (uint y = 0; y < rows; ++y) {
-		for (uint x = 0; x < cols; ++x) {
-			cell(y, x)->style = style;
-			cell(y, x)->ch = ' ';
-		}
+	for (uint i = 0; i < rows * cols; ++i) {
+		cells[i].style = style;
+		cells[i].ch = ' ';
 	}
 
 	wint_t ch;
@@ -298,6 +298,14 @@ int main(int argc, char *argv[]) {
 	}
 	if (ferror(file)) err(EX_IOERR, "getwc");
 
+	if (bright) {
+		for (uint i = 0; i < rows * cols; ++i) {
+			if (!cells[i].style.bold || cells[i].style.fg > 7) continue;
+			cells[i].style.bold = false;
+			cells[i].style.fg += 8;
+		}
+	}
+
 	printf(
 		"<pre style=\"width: %uch;\" class=\"bg%u fg%u\">",
 		cols, def.bg, def.fg