From dc7642f2a52076aacc04b72e1cb213ac96649d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 26 Apr 2023 18:30:09 +0200 Subject: [PATCH] csi: implement "CSI ? m" --- CHANGELOG.md | 4 ++++ csi.c | 35 ++++++++++++++++++++++++++++++++++- doc/foot-ctlseqs.7.scd | 4 ++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca98ed5c..0d16a6ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ ## Unreleased ### Added + +* VT: implemented `XTQMODKEYS` query (`CSI ? Pp m`). + + ### Changed ### Deprecated ### Removed diff --git a/csi.c b/csi.c index d22c1da5..7b318d0a 100644 --- a/csi.c +++ b/csi.c @@ -1398,6 +1398,39 @@ csi_dispatch(struct terminal *term, uint8_t final) break; } + case 'm': { + int resource = vt_param_get(term, 0, 0); + int value = -1; + + switch (resource) { + case 0: /* modifyKeyboard */ + value = 0; + break; + + case 1: /* modifyCursorKeys */ + case 2: /* modifyFunctionKeys */ + value = 1; + break; + + case 4: /* modifyOtherKeys */ + value = term->modify_other_keys_2 ? 2 : 1; + break; + + default: + LOG_WARN("XTQMODKEYS: invalid resource '%d' in '%s'", + resource, csi_as_string(term, final, -1)); + break; + } + + if (value >= 0) { + char reply[16] = {0}; + int chars = snprintf(reply, sizeof(reply), + "\033[>%d;%dm", resource, value); + term_to_slave(term, reply, chars); + } + break; + } + case 'u': { enum kitty_kbd_flags flags = term->grid->kitty_kbd.flags[term->grid->kitty_kbd.idx]; @@ -1489,7 +1522,7 @@ csi_dispatch(struct terminal *term, uint8_t final) break; default: - LOG_WARN("invalid resource %d in %s", + LOG_WARN("XTMODKEYS: invalid resource '%d' in '%s'", resource, csi_as_string(term, final, -1)); break; } diff --git a/doc/foot-ctlseqs.7.scd b/doc/foot-ctlseqs.7.scd index ec970127..3fa03158 100644 --- a/doc/foot-ctlseqs.7.scd +++ b/doc/foot-ctlseqs.7.scd @@ -565,6 +565,10 @@ manipulation sequences. The generic format is: : xterm : Set level of the _modifyOtherKeys_ property to _Pv_. Note that foot only supports level 1 and 2, where level 1 is the default setting. +| \\E[ ? _Pp_ m +: XTQMODKEYS +: xterm +: Query key modifier options | \\E[ > 4 n : : xterm