Detection, done like sync:

- ESC[?u goes to every VT100-like terminal at attach, whatever the
  options.
- A reply turns on a new kittykeys terminal feature. Users can force
  it on or off with terminal-features kittykeys, including kittykeys@
  to turn it off.
- Changing extended-keys now takes effect immediately for attached
  clients (options.c).

Use, per client, when extended-keys is on: Kitty for clients that have
kittykeys, modifyOtherKeys for clients with extkeys, VT10x otherwise.

Pane side:

- Applications can request either protocol; Kitty wins if one asks for
  both.
- Each application gets what it asked for, whichever client typed the
  key.
- ESC[?u is answered truthfully.
- The per-client gate is gone. window.c and popup.c are simply
  master's versions again.

extended-keys always is back to its master meaning, forcing
modifyOtherKeys mode 1 only. Forcing Kitty on every program would have
sent bash ESC[97;5u for Ctrl-A.

extended-keys-format kitty is still accepted, but now behaves the same
as csi-u.
This commit is contained in:
Michael Grant
2026-09-19 07:32:57 +01:00
parent 7545954d00
commit d85329e5f0
17 changed files with 117 additions and 212 deletions

View File

@@ -261,10 +261,6 @@ tty_keys_kitty_query(struct tty *tty, const char *buf, size_t len,
*size = 0;
if (tty->flags & TTY_HAVEKKB)
return (-1);
if (options_get_number(global_options, "extended-keys") == 0 ||
options_get_number(global_options, "extended-keys-format") !=
EXTENDED_KEYS_KITTY)
return (-1);
if (buf[0] != '\033')
return (-1);
@@ -291,8 +287,9 @@ tty_keys_kitty_query(struct tty *tty, const char *buf, size_t len,
*size = i + 1;
tty->kitty_keys = flags;
tty->flags |= (TTY_HAVEKKB|TTY_KKBSUPPORT);
tty->flags |= TTY_HAVEKKB;
log_debug("%s: received Kitty keyboard flags %u", c->name, flags);
tty_parse_client_features(c, "kittykeys", ",");
tty_update_features(tty);
return (0);
}
@@ -304,18 +301,13 @@ tty_update_kitty(struct tty *tty, struct screen *s)
char buf[32];
if (options_get_number(global_options, "extended-keys") == 0 ||
options_get_number(global_options, "extended-keys-format") !=
EXTENDED_KEYS_KITTY) {
(~tty->term->flags & TERM_KITTYKEYS)) {
if (tty->flags & TTY_KKBPUSHED) {
tty_puts(tty, "\033[<u");
tty->flags &= ~TTY_KKBPUSHED;
}
return;
}
if ((tty->flags & (TTY_HAVEKKB|TTY_KKBSUPPORT)) !=
(TTY_HAVEKKB|TTY_KKBSUPPORT))
return;
flags = KITTY_KEY_DISAMBIGUATE;
if (s != NULL && (s->kitty_keys.flags & KITTY_KEY_SUPPORTED) != 0)
flags = s->kitty_keys.flags & KITTY_KEY_SUPPORTED;
@@ -345,9 +337,7 @@ tty_keys_kitty(struct tty *tty, const char *buf, size_t len, size_t *size,
int result;
*size = 0;
if ((tty->flags & TTY_KKBPUSHED) == 0 ||
options_get_number(global_options, "extended-keys-format") !=
EXTENDED_KEYS_KITTY)
if ((tty->flags & TTY_KKBPUSHED) == 0)
return (-1);
if (len == 0 || buf[0] != '\033')
return (-1);