mirror of
https://github.com/tmux/tmux.git
synced 2026-10-10 12:14:43 +00:00
Merge branch 'master' into local_windows_panes
# Conflicts: # cmd-switch-client.c
This commit is contained in:
95
tty-keys.c
95
tty-keys.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tty-keys.c,v 1.212 2026/08/17 07:52:16 nicm Exp $ */
|
||||
/* $OpenBSD: tty-keys.c,v 1.214 2026/08/18 09:01:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -59,6 +59,7 @@ static int tty_keys_device_attributes2(struct tty *, const char *, size_t,
|
||||
size_t *);
|
||||
static int tty_keys_extended_device_attributes(struct tty *, const char *,
|
||||
size_t, size_t *);
|
||||
static int tty_keys_sync(struct tty *, const char *, size_t, size_t *);
|
||||
static int tty_keys_palette(struct tty *, const char *, size_t, size_t *);
|
||||
|
||||
/* A key tree entry. */
|
||||
@@ -771,6 +772,17 @@ tty_keys_next(struct tty *tty)
|
||||
goto partial_key;
|
||||
}
|
||||
|
||||
/* Is this a synchronized update mode response? */
|
||||
switch (tty_keys_sync(tty, buf, len, &size)) {
|
||||
case 0: /* yes */
|
||||
key = KEYC_UNKNOWN;
|
||||
goto complete_key;
|
||||
case -1: /* no, or not valid */
|
||||
break;
|
||||
case 1: /* partial */
|
||||
goto partial_key;
|
||||
}
|
||||
|
||||
/* Is this a primary device attributes response? */
|
||||
switch (tty_keys_device_attributes(tty, buf, len, &size)) {
|
||||
case 0: /* yes */
|
||||
@@ -1447,7 +1459,6 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
||||
size_t *size)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
int *features = &c->term_features;
|
||||
u_int i, n = 0;
|
||||
char tmp[128], *endptr, p[32] = { 0 }, *cp, *next;
|
||||
|
||||
@@ -1504,13 +1515,13 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
||||
for (i = 1; i < n; i++) {
|
||||
log_debug("%s: DA feature: %d", c->name, p[i]);
|
||||
if (p[i] == 4)
|
||||
tty_add_features(features, "sixel", ",");
|
||||
tty_parse_client_features(c, "sixel", ",");
|
||||
if (p[i] == 21)
|
||||
tty_add_features(features, "margins", ",");
|
||||
tty_parse_client_features(c, "margins", ",");
|
||||
if (p[i] == 28)
|
||||
tty_add_features(features, "rectfill", ",");
|
||||
tty_parse_client_features(c, "rectfill", ",");
|
||||
if (p[i] == 52)
|
||||
tty_add_features(features, "clipboard", ",");
|
||||
tty_parse_client_features(c, "clipboard", ",");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1522,6 +1533,54 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle a synchronized update mode response. Returns 0 for success, -1 for
|
||||
* failure, 1 for partial.
|
||||
*/
|
||||
static int
|
||||
tty_keys_sync(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
static const char prefix[] = "\033[?2026;";
|
||||
size_t i;
|
||||
int status;
|
||||
|
||||
*size = 0;
|
||||
if (tty->flags & TTY_HAVESYNC)
|
||||
return (-1);
|
||||
|
||||
/* The response is always \033[?2026;Ps$y. */
|
||||
for (i = 0; i < (sizeof prefix) - 1; i++) {
|
||||
if (i == len)
|
||||
return (1);
|
||||
if (buf[i] != prefix[i])
|
||||
return (-1);
|
||||
}
|
||||
if (i == len)
|
||||
return (1);
|
||||
if (buf[i] < '0' || buf[i] > '4')
|
||||
return (-1);
|
||||
status = buf[i++] - '0';
|
||||
if (i == len)
|
||||
return (1);
|
||||
if (buf[i++] != '$')
|
||||
return (-1);
|
||||
if (i == len)
|
||||
return (1);
|
||||
if (buf[i++] != 'y')
|
||||
return (-1);
|
||||
*size = i;
|
||||
|
||||
if (status == 1 || status == 2 || status == 3) {
|
||||
tty_parse_client_features(c, "sync", ",");
|
||||
tty_update_features(tty);
|
||||
}
|
||||
log_debug("%s: received DECRPM %.*s", c->name, (int)*size, buf);
|
||||
tty->flags |= TTY_HAVESYNC;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle secondary device attributes input. Returns 0 for success, -1 for
|
||||
* failure, 1 for partial.
|
||||
@@ -1531,7 +1590,6 @@ tty_keys_device_attributes2(struct tty *tty, const char *buf, size_t len,
|
||||
size_t *size)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
int *features = &c->term_features;
|
||||
u_int i, n = 0;
|
||||
char tmp[128], *endptr, p[32] = { 0 }, *cp, *next;
|
||||
|
||||
@@ -1585,13 +1643,13 @@ tty_keys_device_attributes2(struct tty *tty, const char *buf, size_t len,
|
||||
*/
|
||||
switch (p[0]) {
|
||||
case 'M': /* mintty */
|
||||
tty_default_features(features, "mintty", 0);
|
||||
tty_default_features(c, "mintty", 0);
|
||||
break;
|
||||
case 'T': /* tmux */
|
||||
tty_default_features(features, "tmux", 0);
|
||||
tty_default_features(c, "tmux", 0);
|
||||
break;
|
||||
case 'U': /* rxvt-unicode */
|
||||
tty_default_features(features, "rxvt-unicode", 0);
|
||||
tty_default_features(c, "rxvt-unicode", 0);
|
||||
break;
|
||||
}
|
||||
log_debug("%s: received secondary DA %.*s", c->name, (int)*size, buf);
|
||||
@@ -1611,7 +1669,6 @@ tty_keys_extended_device_attributes(struct tty *tty, const char *buf,
|
||||
size_t len, size_t *size)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
int *features = &c->term_features;
|
||||
u_int i;
|
||||
char tmp[128];
|
||||
|
||||
@@ -1654,21 +1711,21 @@ tty_keys_extended_device_attributes(struct tty *tty, const char *buf,
|
||||
|
||||
/* Add terminal features. */
|
||||
if (strncmp(tmp, "iTerm2 ", 7) == 0)
|
||||
tty_default_features(features, "iTerm2", 0);
|
||||
tty_default_features(c, "iTerm2", 0);
|
||||
else if (strncmp(tmp, "tmux ", 5) == 0)
|
||||
tty_default_features(features, "tmux", 0);
|
||||
tty_default_features(c, "tmux", 0);
|
||||
else if (strncmp(tmp, "XTerm(", 6) == 0)
|
||||
tty_default_features(features, "XTerm", 0);
|
||||
tty_default_features(c, "XTerm", 0);
|
||||
else if (strncmp(tmp, "mintty ", 7) == 0)
|
||||
tty_default_features(features, "mintty", 0);
|
||||
tty_default_features(c, "mintty", 0);
|
||||
else if (strncmp(tmp, "foot(", 5) == 0)
|
||||
tty_default_features(features, "foot", 0);
|
||||
tty_default_features(c, "foot", 0);
|
||||
else if (strncmp(tmp, "WezTerm ", 7) == 0)
|
||||
tty_default_features(features, "WezTerm", 0);
|
||||
tty_default_features(c, "WezTerm", 0);
|
||||
else if (strncmp(tmp, "ghostty ", 8) == 0)
|
||||
tty_default_features(features, "ghostty", 0);
|
||||
tty_default_features(c, "ghostty", 0);
|
||||
else if (strncmp(tmp, "Rio ", 4) == 0)
|
||||
tty_default_features(features, "Rio", 0);
|
||||
tty_default_features(c, "Rio", 0);
|
||||
log_debug("%s: received extended DA %.*s", c->name, (int)*size, buf);
|
||||
|
||||
free(c->term_type);
|
||||
|
||||
Reference in New Issue
Block a user