mirror of
https://github.com/tmux/tmux.git
synced 2026-10-10 04:04:27 +00:00
Send kitty keyboard probe only if extended-keys is not off.
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -115,8 +115,8 @@ CHANGES FROM 3.7c TO 3.8
|
|||||||
* Change show-options and show-hooks to use formats and add a -F flag to each.
|
* Change show-options and show-hooks to use formats and add a -F flag to each.
|
||||||
|
|
||||||
* Add support for the Kitty keyboard protocol. When extended-keys is on,
|
* Add support for the Kitty keyboard protocol. When extended-keys is on,
|
||||||
tmux uses it with terminals which support it, detected when a client
|
tmux uses it with terminals which support it, detected by querying the
|
||||||
attaches or set with a new kittykeys terminal feature, and standard
|
terminal or set with a new kittykeys terminal feature, and standard
|
||||||
extended keys or VT10x keys with other terminals, so terminals with
|
extended keys or VT10x keys with other terminals, so terminals with
|
||||||
different capabilities may be attached at the same time. Programs inside
|
different capabilities may be attached at the same time. Programs inside
|
||||||
tmux may ask for either the Kitty protocol or modifyOtherKeys and get keys
|
tmux may ask for either the Kitty protocol or modifyOtherKeys and get keys
|
||||||
|
|||||||
@@ -1401,10 +1401,8 @@ options_push_changes(const char *name)
|
|||||||
server_client_set_key_table(loop, NULL);
|
server_client_set_key_table(loop, NULL);
|
||||||
}
|
}
|
||||||
if (strcmp(name, "extended-keys") == 0) {
|
if (strcmp(name, "extended-keys") == 0) {
|
||||||
TAILQ_FOREACH(loop, &clients, entry) {
|
TAILQ_FOREACH(loop, &clients, entry)
|
||||||
if (loop->tty.flags & TTY_STARTED)
|
tty_extended_keys_changed(&loop->tty);
|
||||||
tty_update_features(&loop->tty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (strcmp(name, "user-keys") == 0) {
|
if (strcmp(name, "user-keys") == 0) {
|
||||||
TAILQ_FOREACH(loop, &clients, entry) {
|
TAILQ_FOREACH(loop, &clients, entry) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ KCONF=$(mktemp)
|
|||||||
LCONF=$(mktemp)
|
LCONF=$(mktemp)
|
||||||
OUT=$(mktemp)
|
OUT=$(mktemp)
|
||||||
TMP=$(mktemp)
|
TMP=$(mktemp)
|
||||||
SOCKETS="testKmc$$ testKka$$ testKua$$ testKrt$$ testKru$$ testKlq$$ testKlu$$"
|
SOCKETS="testKmc$$ testKka$$ testKua$$ testKrt$$ testKru$$ testKlq$$ testKlu$$ testKpo$$ testKpi$$"
|
||||||
|
|
||||||
printf '%s\n' 'set -g extended-keys on' >"$KCONF"
|
printf '%s\n' 'set -g extended-keys on' >"$KCONF"
|
||||||
printf '%s\n' 'set -g extended-keys off' >"$LCONF"
|
printf '%s\n' 'set -g extended-keys off' >"$LCONF"
|
||||||
@@ -142,5 +142,22 @@ wait_for_client_mode "$LQ" '' 'VT10x' || exit 1
|
|||||||
$LU send-keys C-a
|
$LU send-keys C-a
|
||||||
wait_for_output "$TMP" || exit 1
|
wait_for_output "$TMP" || exit 1
|
||||||
[ "$(tr -d ' \n' <"$TMP")" = '1b5b39373b3575' ] || exit 1
|
[ "$(tr -d ' \n' <"$TMP")" = '1b5b39373b3575' ] || exit 1
|
||||||
|
$LU kill-server 2>/dev/null
|
||||||
|
$LQ kill-server 2>/dev/null
|
||||||
|
|
||||||
|
# The Kitty query must not be sent while extended-keys is off, but must be sent
|
||||||
|
# and answered once it is turned on.
|
||||||
|
: >"$OUT"
|
||||||
|
PO="$TEST_TMUX -LtestKpo$$ -f$KCONF"
|
||||||
|
PI="$TEST_TMUX -LtestKpi$$ -f$LCONF"
|
||||||
|
$PI new-session -d -x80 -y24 -s q || exit 1
|
||||||
|
$PO new-session -d -x80 -y24 "sleep 1; $PI attach-session -t q" || exit 1
|
||||||
|
$PO pipe-pane -O -t: "cat >>'$OUT'"
|
||||||
|
wait_for_client_mode "$PI" '' 'VT10x' || exit 1
|
||||||
|
sleep 1
|
||||||
|
od -An -v -t x1 <"$OUT" | tr -d ' \n' | grep -q 1b5b3f75 && exit 1
|
||||||
|
$PI set-option -g extended-keys on
|
||||||
|
wait_for_client_mode "$PI" '' 'Kitty 1' || exit 1
|
||||||
|
od -An -v -t x1 <"$OUT" | tr -d ' \n' | grep -q 1b5b3f75 || exit 1
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
3
tmux.1
3
tmux.1
@@ -4955,7 +4955,8 @@ this feature is disabled and only standard keys are reported.
|
|||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Nm
|
||||||
will always request extended keys itself if the terminal supports them.
|
will always request extended keys itself if the terminal supports them.
|
||||||
Support for the Kitty keyboard protocol is detected when a client attaches.
|
When enabled, support for the Kitty keyboard protocol is detected by asking the
|
||||||
|
terminal when a client attaches or the option is changed.
|
||||||
See also the
|
See also the
|
||||||
.Ic kittykeys
|
.Ic kittykeys
|
||||||
and
|
and
|
||||||
|
|||||||
1
tmux.h
1
tmux.h
@@ -3037,6 +3037,7 @@ void tty_invalidate(struct tty *);
|
|||||||
void tty_start_tty(struct tty *);
|
void tty_start_tty(struct tty *);
|
||||||
void tty_send_requests(struct tty *);
|
void tty_send_requests(struct tty *);
|
||||||
void tty_repeat_requests(struct tty *, int);
|
void tty_repeat_requests(struct tty *, int);
|
||||||
|
void tty_extended_keys_changed(struct tty *);
|
||||||
void tty_stop_tty(struct tty *);
|
void tty_stop_tty(struct tty *);
|
||||||
void tty_set_title(struct tty *, const char *);
|
void tty_set_title(struct tty *, const char *);
|
||||||
void tty_set_path(struct tty *, const char *);
|
void tty_set_path(struct tty *, const char *);
|
||||||
|
|||||||
@@ -1562,7 +1562,7 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
|||||||
}
|
}
|
||||||
log_debug("%s: received primary DA %.*s", c->name, (int)*size, buf);
|
log_debug("%s: received primary DA %.*s", c->name, (int)*size, buf);
|
||||||
|
|
||||||
/* A DA response without a preceding keyboard response means no support. */
|
/* The keyboard query, if sent, is answered first; else nothing is due. */
|
||||||
tty->flags |= TTY_HAVEKKB;
|
tty->flags |= TTY_HAVEKKB;
|
||||||
tty_update_features(tty);
|
tty_update_features(tty);
|
||||||
tty->flags |= TTY_HAVEDA;
|
tty->flags |= TTY_HAVEDA;
|
||||||
|
|||||||
24
tty.c
24
tty.c
@@ -404,11 +404,14 @@ tty_start_tty(struct tty *tty)
|
|||||||
void
|
void
|
||||||
tty_send_requests(struct tty *tty)
|
tty_send_requests(struct tty *tty)
|
||||||
{
|
{
|
||||||
|
int ek;
|
||||||
|
|
||||||
if (~tty->flags & TTY_STARTED)
|
if (~tty->flags & TTY_STARTED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tty->term->flags & TERM_VT100LIKE) {
|
if (tty->term->flags & TERM_VT100LIKE) {
|
||||||
if (~tty->flags & TTY_HAVEKKB)
|
ek = options_get_number(global_options, "extended-keys");
|
||||||
|
if (ek != 0 && (~tty->flags & TTY_HAVEKKB))
|
||||||
tty_puts(tty, "\033[?u");
|
tty_puts(tty, "\033[?u");
|
||||||
if (~tty->flags & TTY_HAVEDA)
|
if (~tty->flags & TTY_HAVEDA)
|
||||||
tty_puts(tty, "\033[c");
|
tty_puts(tty, "\033[c");
|
||||||
@@ -451,6 +454,25 @@ tty_repeat_requests(struct tty *tty, int force)
|
|||||||
tty_start_start_timer(tty);
|
tty_start_start_timer(tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ask about Kitty keyboard support if extended-keys was turned on later. */
|
||||||
|
void
|
||||||
|
tty_extended_keys_changed(struct tty *tty)
|
||||||
|
{
|
||||||
|
if (~tty->flags & TTY_STARTED)
|
||||||
|
return;
|
||||||
|
tty_update_features(tty);
|
||||||
|
|
||||||
|
if (options_get_number(global_options, "extended-keys") == 0)
|
||||||
|
return;
|
||||||
|
if (~tty->term->flags & TERM_VT100LIKE)
|
||||||
|
return;
|
||||||
|
if (tty->term->flags & TERM_KITTYKEYS)
|
||||||
|
return;
|
||||||
|
tty->flags &= ~TTY_HAVEKKB;
|
||||||
|
tty_puts(tty, "\033[?u");
|
||||||
|
tty_start_start_timer(tty);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_stop_tty(struct tty *tty)
|
tty_stop_tty(struct tty *tty)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user