input: add support for modifyOtherKeys=2

Similar to modifyOtherKeys=1 (foot’s default, and only, mode), except
that:

* All modifiers (and not just Ctrl) generate \E[27;m;n~ escapes
* Regular keys (with modifiers) also generate \E[27;m;n~ escapes (for
  example, C-h no longer generates ^H, but \E[27;5;104~)

For our keymap based lookups, this is handled by adding
MOD_MODIFY_OTHER_KEYS_STATE<N> variants.

For “generic” keys, we simply adjust the conditions for when to emit a
\E[27;m;n~ escape - the only requirement is that at least one modifier
is active.
This commit is contained in:
Daniel Eklöf 2021-11-11 17:43:39 +01:00
parent 9412389051
commit 4a74050999
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 90 additions and 32 deletions

20
csi.c
View file

@ -1509,19 +1509,21 @@ csi_dispatch(struct terminal *term, uint8_t final)
case 1: /* modifyCursorKeys */
case 2: /* modifyFunctionKeys */
case 4: /* modifyOtherKeys */
/* Ignored, we always report modifiers */
if (value != 2 && value != -1 &&
!(resource == 4 && value == 1))
{
LOG_WARN("unimplemented: %s = %d",
resource == 1 ? "modifyCursorKeys" :
resource == 2 ? "modifyFunctionKeys" :
resource == 4 ? "modifyOtherKeys" : "<invalid>",
value);
if (value != 2 && value != -1) {
LOG_WARN(
"unimplemented: %s = %d",
resource == 1 ? "modifyCursorKeys" :
resource == 2 ? "modifyFunctionKeys" : "<invalid>",
value);
}
break;
case 4: /* modifyOtherKeys */
term->modify_other_keys_2 = value == 2;
LOG_DBG("modifyOtherKeys=%d", value);
break;
default:
LOG_WARN("invalid resource %d in %s",
resource, csi_as_string(term, final, -1));