From cf90b09e5c0b0d5a91dd2d789842369b44b8b900 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sun, 10 Feb 2019 23:51:13 -0500 Subject: Avoid excessive tags in ttpre --- bin/ttpre.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'bin/ttpre.c') diff --git a/bin/ttpre.c b/bin/ttpre.c index 52e30f54..79006ca9 100644 --- a/bin/ttpre.c +++ b/bin/ttpre.c @@ -19,27 +19,36 @@ #include #include -static void put(const char *tag, wchar_t ch) { - if (tag) printf("<%s>", tag); +static void put(wchar_t ch) { switch (ch) { break; case L'&': printf("&"); break; case L'<': printf("<"); break; case L'>': printf(">"); break; default: printf("%lc", ch); } - if (tag) printf("", tag); +} + +static void tag(const char *open) { + static const char *close = NULL; + if (close == open) return; + if (close) printf("", close); + if (open) printf("<%s>", open); + close = open; } static void push(wchar_t ch) { static wchar_t q[3]; if (q[1] == L'\b' && q[0] == L'_') { - put("i", q[2]); + tag("i"); + put(q[2]); q[0] = q[1] = q[2] = 0; } else if (q[1] == L'\b' && q[0] == q[2]) { - put("b", q[2]); + tag("b"); + put(q[2]); q[0] = q[1] = q[2] = 0; } else if (q[0]) { - put(NULL, q[0]); + tag(NULL); + put(q[0]); } q[0] = q[1]; q[1] = q[2]; -- cgit 1.4.1 d=5bf9a73af5cbf66abf0c84aa480e7c9fa76d4228&follow=1'>commit diff
Commit message (Collapse)Author
2019-07-12Color html rather than bodyJune McEnroe
If background-color is only set on body then overscroll in Safari reveals white.
2019-07-12Make author consistent and update URLsJune McEnroe
2019-07-12Move to www/text.causal.agencyJune McEnroe
2019-07-12Add new causal.agency with shotty shotsJune McEnroe
2019-07-12Use -s to infer terminal sizeJune McEnroe
2019-07-12Add DCH to shottyJune McEnroe
This makes htop mostly work. Scrolling region still missing.
2019-07-12Support insert mode in shottyJune McEnroe
This is how curses puts characters into the bottom-right cell of the terminal.
2019-07-11Don't do carriage return on line feedJune McEnroe
2019-07-11Interpret 256color-style SGRsJune McEnroe
2019-07-11Use inline style rather than <b>, <i>, <u>June McEnroe
2019-07-11Factor out clearJune McEnroe
2019-07-11Add bright option to shottyJune McEnroe
2019-07-11Output <b>, <i>, <u> in shottyJune McEnroe
2019-07-10Ignore SM and RMJune McEnroe
2019-07-09Add shotty man page and build itJune McEnroe
2019-07-09Add up -cJune McEnroe
2019-07-09Add options for default colors to shottyJune McEnroe
2019-07-08Use char literals consistentlyJune McEnroe