summary refs log tree commit diff
path: root/bin/shotty.c
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
commit5fa21ca1b98ac74bd603fc1e1a504c98bd4bed27 (patch)
treed77edec602b2de8b0e697894637ce961df4f2ffd /bin/shotty.c
parentOutput <b>, <i>, <u> in shotty (diff)
downloadsrc-5fa21ca1b98ac74bd603fc1e1a504c98bd4bed27.tar.gz
src-5fa21ca1b98ac74bd603fc1e1a504c98bd4bed27.zip
Add bright option to shotty
Diffstat (limited to 'bin/shotty.c')
-rw-r--r--bin/shotty.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/shotty.c b/bin/shotty.c
index 15ab3e4d..f643447c 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