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

14
tty.c
View File

@@ -408,10 +408,7 @@ tty_send_requests(struct tty *tty)
return;
if (tty->term->flags & TERM_VT100LIKE) {
if (~tty->flags & TTY_HAVEKKB &&
options_get_number(global_options, "extended-keys") != 0 &&
options_get_number(global_options, "extended-keys-format") ==
EXTENDED_KEYS_KITTY)
if (~tty->flags & TTY_HAVEKKB)
tty_puts(tty, "\033[?u");
if (~tty->flags & TTY_HAVEDA)
tty_puts(tty, "\033[c");
@@ -558,19 +555,14 @@ void
tty_update_features(struct tty *tty)
{
struct client *c = tty->client;
int extended_keys, format;
if (tty_apply_features(tty->term))
tty_term_apply_overrides(tty->term);
if (tty_use_margin(tty))
tty_putcode(tty, TTYC_ENMG);
extended_keys = options_get_number(global_options, "extended-keys");
format = options_get_number(global_options, "extended-keys-format");
if (extended_keys == 0 ||
(format == EXTENDED_KEYS_KITTY &&
(tty->flags & (TTY_HAVEKKB|TTY_KKBSUPPORT)) ==
(TTY_HAVEKKB|TTY_KKBSUPPORT)))
if (options_get_number(global_options, "extended-keys") == 0 ||
(tty->term->flags & TERM_KITTYKEYS))
tty_puts(tty, tty_term_string(tty->term, TTYC_DSEKS));
else
tty_puts(tty, tty_term_string(tty->term, TTYC_ENEKS));