diff options
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/term.c b/term.c index a79a084..357861f 100644 --- a/term.c +++ b/term.c @@ -216,6 +216,9 @@ static void updateSGR(uint ps[], uint n) { } } +// SGR toggling all attributes and setting both colors in 256 palette. +enum { PSCap = 4 + 2 * 3 }; + enum { DEC = '?', CUU = 'A', @@ -248,11 +251,11 @@ static char updateCSI(wchar_t ch) { return CSI; } - static uint n, p, ps[8]; + static uint n, p, ps[PSCap]; if (ch == ';') { n++; p++; - ps[p %= 8] = 0; + ps[p %= PSCap] = 0; return CSI; } if (ch >= '0' && ch <= '9') { @@ -376,7 +379,8 @@ styleDiff(FILE *file, const struct Style *prev, const struct Style *next) { if (!memcmp(next, &Default, sizeof(*next))) { return fprintf(file, "%c%c%c", ESC, CSI, SGR); } - uint ps[10]; + + uint ps[PSCap]; uint n = 0; if (next->bold != prev->bold) { ps[n++] = (next->bold ? Bold : NotBold); @@ -416,6 +420,7 @@ styleDiff(FILE *file, const struct Style *prev, const struct Style *next) { ps[n++] = next->fg; } } + if (0 > fprintf(file, "%c%c%u", ESC, CSI, ps[0])) return -1; for (uint i = 1; i < n; ++i) { if (0 > fprintf(file, ";%u", ps[i])) return -1; |