From cc36a11e38b65ff512bf6e66f8c44d9ac8e55446 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 14 Jul 2019 14:26:00 -0400 Subject: Add CSI names to shotty -d --- bin/shotty.c | 60 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/bin/shotty.c b/bin/shotty.c index fb5482ca..a81e18c0 100644 --- a/bin/shotty.c +++ b/bin/shotty.c @@ -146,26 +146,38 @@ static char updateNUL(wchar_t ch) { return NUL; } +#define ENUM_CHARS \ + X('?', DEC) \ + X('A', CUU) \ + X('B', CUD) \ + X('C', CUF) \ + X('D', CUB) \ + X('E', CNL) \ + X('F', CPL) \ + X('G', CHA) \ + X('H', CUP) \ + X('J', ED) \ + X('K', EL) \ + X('M', DL) \ + X('P', DCH) \ + X('[', CSI) \ + X('\\', ST) \ + X(']', OSC) \ + X('d', VPA) \ + X('h', SM) \ + X('l', RM) \ + X('m', SGR) + enum { - CSI = '[', - ST = '\\', - OSC = ']', - CUU = 'A', - CUD = 'B', - CUF = 'C', - CUB = 'D', - CNL = 'E', - CPL = 'F', - CHA = 'G', - CUP = 'H', - ED = 'J', - EL = 'K', - DL = 'M', - DCH = 'P', - VPA = 'd', - SM = 'h', - RM = 'l', - SGR = 'm', +#define X(ch, name) name = ch, + ENUM_CHARS +#undef X +}; + +static const char *Name[128] = { +#define X(ch, name) [ch] = #name, + ENUM_CHARS +#undef X }; static char updateESC(wchar_t ch) { @@ -185,7 +197,7 @@ static char updateESC(wchar_t ch) { static char updateCSI(wchar_t ch) { static bool dec; - if (ch == '?') { + if (ch == DEC) { dec = true; return CSI; } @@ -305,11 +317,15 @@ static char updateCSI(wchar_t ch) { } if (debug) { - printf("CSI %s", (dec ? "? " : "")); + printf("CSI %s", (dec ? "DEC " : "")); for (uint i = 0; i < n; ++i) { printf("%s%u ", (i ? "; " : ""), ps[i]); } - printf("%lc\n", ch); + if (ch < 128 && Name[ch]) { + printf("%s\n", Name[ch]); + } else { + printf("%lc\n", ch); + } html(true); } -- cgit 1.4.1 n value='range'>range
path: root/doc/zlib/gzfread.3 (unfollow)
Commit message (Collapse)Author
2021-01-01Remove empty comma statement from bitJune McEnroe
2021-01-01Increment license header templatesJune McEnroe
2020-12-31Tell "Music" rather than "iTunes"June McEnroe
It's the new era.
2020-12-31Add ASCII control code names to bitJune McEnroe
2020-12-31Simplify bit lexing and parsingJune McEnroe
Also print the value of each expression separated by commas.
2020-12-31Add ddateJune McEnroe
I'm tired of package managers not having this!
2020-12-30Print octal for 8 bits in bitJune McEnroe
2020-12-30Add unary & to bitJune McEnroe
Also unary + and fix precedence of unary -.
2020-12-30Support unary + in orderJune McEnroe
Missed this because operator(7) just doesn't list it, oddly.
2020-12-30Add postfix $ operator to bitJune McEnroe
2020-12-29Add make lexerJune McEnroe
This is kind of a mess and needs to be cleaned up against more careful reading of the make grammar.
2020-12-29Clean up C lexerJune McEnroe
This ordering of rules feels much cleaner.
2020-12-29Clean up hilex code somewhatJune McEnroe
2020-12-29Match lex/yacc %% %{ %} lines as MacroJune McEnroe
2020-12-29Match top-level C definitions as IdentifierTagJune McEnroe
2020-12-29Match C type declarations as IdentifierTagJune McEnroe
2020-12-29Match function-like macro definitions as IdentifierTagJune McEnroe
2020-12-29Reconfigure C macro start conditionsJune McEnroe
2020-12-29Document HTML class namesJune McEnroe
2020-12-29Rename Tag class to IdentifierTagJune McEnroe
2020-12-29Change HTML class from hi to hilexJune McEnroe
You can tell I was just copying the HTML code huh.
2020-12-29Add hilex HTML outputJune McEnroe