diff options
author | June McEnroe <june@causal.agency> | 2019-08-01 17:01:29 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-08-01 17:01:29 -0400 |
commit | 8815bc1e03e9910d453e352be0b21efd8a61f6c8 (patch) | |
tree | c8cafc2fba42ef2cc21408943f0c3acd604dac1e | |
parent | Implement termSnapshot (diff) | |
download | stream-8815bc1e03e9910d453e352be0b21efd8a61f6c8.tar.gz stream-8815bc1e03e9910d453e352be0b21efd8a61f6c8.zip |
Use PSCap in updateCSI and styleDiff
Diffstat (limited to '')
-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; |