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

@@ -395,8 +395,7 @@ input_key_build(void)
/* Translate a key code into an output key sequence for a pane. */
int
input_key_pane(struct window_pane *wp, key_code key, struct mouse_event *m,
int extended_encoding)
input_key_pane(struct window_pane *wp, key_code key, struct mouse_event *m)
{
if (log_get_level() != 0) {
log_debug("writing key 0x%llx (%s) to %%%u", key,
@@ -408,20 +407,7 @@ input_key_pane(struct window_pane *wp, key_code key, struct mouse_event *m,
input_key_mouse(wp, m);
return (0);
}
return (input_key(wp->screen, wp->event, key, extended_encoding));
}
/* Return whether a key may use the configured extended encoding. */
int
input_key_client_supports_extended(struct client *c, key_code key)
{
if (c == NULL || (key & KEYC_SENT))
return (1);
if (options_get_number(global_options, "extended-keys") == 0)
return (0);
if (c->tty.flags & TTY_KKBPUSHED)
return (1);
return (tty_term_has(c->tty.term, TTYC_ENEKS));
return (input_key(wp->screen, wp->event, key));
}
static void
@@ -586,8 +572,7 @@ input_key_mode1(struct bufferevent *bev, key_code key)
/* Translate a key code into an output key sequence. */
int
input_key(struct screen *s, struct bufferevent *bev, key_code key,
int extended_encoding)
input_key(struct screen *s, struct bufferevent *bev, key_code key)
{
struct input_key_entry *ike = NULL;
key_code newkey;
@@ -604,9 +589,8 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key,
return (0);
}
if (extended_encoding &&
options_get_number(global_options, "extended-keys-format") ==
EXTENDED_KEYS_KITTY && input_key_kitty(s, bev, key) == 0)
/* Kitty keys take precedence if the application asked for them. */
if (input_key_kitty(s, bev, key) == 0)
return (0);
/* Is this backspace? */
@@ -700,8 +684,7 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key,
}
if (key & (KEYC_SUPER|KEYC_HYPER))
return (input_key_vt10x(bev, key));
if (options_get_number(global_options, "extended-keys-format") ==
EXTENDED_KEYS_KITTY)
if (s->kitty_keys.flags & KITTY_KEY_SUPPORTED)
return (input_key_vt10x(bev, key));
/*