From 8a1f8624ee4a859477809d6a554ad290dae15e63 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 14 Aug 2019 00:05:30 -0400 Subject: Allow :<=>? in CSI params --- term.c | 36 ++++++++++++++++++++++-------------- term.h | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/term.c b/term.c index 09fe4fa..2a8960a 100644 --- a/term.c +++ b/term.c @@ -108,19 +108,27 @@ ACTION(csi) { } static void csiParam(struct Term *t, wchar_t ch) { - if (ch == L'?') { - t->param.q = true; - } else if (ch == L';' && t->param.n < ParamCap) { - t->param.n++; - t->param.i++; - } else if (ch >= L'0' && ch <= L'9') { - t->param.s[t->param.i] *= 10; - t->param.s[t->param.i] += ch - L'0'; - if (!t->param.n) t->param.n++; - } else { - // FIXME: Allow other characters in CSI params. - unhandled("CSI %lc", ch); - return; + switch (ch) { + case L'0': case L'1': case L'2': case L'3': case L'4': + case L'5': case L'6': case L'7': case L'8': case L'9': { + t->param.s[t->param.i] *= 10; + t->param.s[t->param.i] += ch - L'0'; + if (!t->param.n) t->param.n++; + } + break; case L':': // ignore + break; case L';': { + if (t->param.n == ParamCap) break; + t->param.n++; + t->param.i++; + } + break; case L'<': t->param.lt = true; + break; case L'=': t->param.eq = true; + break; case L'>': t->param.gt = true; + break; case L'?': t->param.qm = true; + break; default: { + unhandled("CSI %lc", ch); + return; + } } t->state = CSI; } @@ -227,7 +235,7 @@ enum { static void mode(struct Term *t, wchar_t ch) { enum Mode mode = 0; for (uint i = 0; i < t->param.n; ++i) { - if (t->param.q) { + if (t->param.qm) { switch (t->param.s[i]) { break; case 1: // DECCKM break; case DECAWM: mode |= Wrap; diff --git a/term.h b/term.h index b4a96af..19ebb95 100644 --- a/term.h +++ b/term.h @@ -58,7 +58,7 @@ struct Term { uint rows, cols; uint state; struct { - bool q; + bool lt, eq, gt, qm; uint s[ParamCap]; uint n, i; } param; -- cgit 1.4.1