summaryrefslogtreecommitdiffstats
path: root/tty-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2020-04-20 13:25:36 +0000
committernicm <nicm>2020-04-20 13:25:36 +0000
commitc91b4b2e142b5b3fc9ca88afec6bfa9b2711e01b (patch)
treeaa45bf3ad266b1d2d4da4fe727a2b27f3819e71b /tty-keys.c
parent86862c976af7d16524b675ea1049edce07a1aafa (diff)
Tidy up the terminal detection and feature code and add named sets of
terminal features, each of which are defined in one place and map to a builtin set of terminfo(5) capabilities. Features can be specified based on TERM with a new terminal-features option or with the -T flag when running tmux. tmux will also detect a few common terminals from the DA and DSR responses. This is intended to make it easier to configure tmux's use of terminfo(5) even in the presence of outdated ncurses(3) or terminfo(5) databases or for features which do not yet have a terminfo(5) entry. Instead of having to grok terminfo(5) capability names and what they should be set to in the terminal-overrides option, the user can hopefully just give tmux a feature name and let it do the right thing. The terminal-overrides option remains both for backwards compatibility and to allow tweaks of individual capabilities. tmux already did much of this already, this makes it tidier and simpler to configure.
Diffstat (limited to 'tty-keys.c')
-rw-r--r--tty-keys.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/tty-keys.c b/tty-keys.c
index 10c9c670..14952c05 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -1020,7 +1020,6 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
struct client *c = tty->client;
u_int i, n = 0;
char tmp[64], *endptr, p[32] = { 0 }, *cp, *next;
- int flags = 0;
*size = 0;
if (tty->flags & TTY_HAVEDA)
@@ -1060,24 +1059,42 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
n++;
}
- /* Set terminal flags. */
+ /* Add terminal features. */
switch (p[0]) {
case 41: /* VT420 */
- flags |= (TERM_DECFRA|TERM_DECSLRM);
+ tty_add_features(&c->term_features,
+ "margins,"
+ "rectfill",
+ ",");
break;
case 'M': /* mintty */
- flags |= (TERM_256COLOURS|TERM_RGBCOLOURS);
+ tty_add_features(&c->term_features,
+ "256,"
+ "RGB,"
+ "title",
+ ",");
break;
- case 'T': /* tmux - new versons reply to DSR which will set RGB */
- flags |= (TERM_UTF8|TERM_256COLOURS);
+ case 'T': /* tmux */
+ tty_add_features(&c->term_features,
+ "256,"
+ "RGB,"
+ "ccolour,"
+ "cstyle,"
+ "overline,"
+ "title,"
+ "usstyle",
+ ",");
break;
case 'U': /* rxvt-unicode */
- flags |= (TERM_UTF8);
+ tty_add_features(&c->term_features,
+ "256,"
+ "title",
+ ",");
break;
}
log_debug("%s: received secondary DA %.*s", c->name, (int)*size, buf);
- tty_set_flags(tty, flags);
+ tty_update_features(tty);
tty->flags |= TTY_HAVEDA;
return (0);
@@ -1094,7 +1111,6 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
struct client *c = tty->client;
u_int i;
char tmp[64];
- int flags = 0;
*size = 0;
if (tty->flags & TTY_HAVEDSR)
@@ -1125,15 +1141,31 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
tmp[i] = '\0';
*size = 3 + i;
- /* Set terminal flags. */
+ /* Add terminal features. */
if (strncmp(tmp, "ITERM2 ", 7) == 0) {
- flags |= (TERM_UTF8|TERM_DECSLRM|TERM_SYNC|TERM_256COLOURS|
- TERM_RGBCOLOURS);
- } else if (strncmp(tmp, "TMUX ", 5) == 0)
- flags |= (TERM_UTF8|TERM_256COLOURS|TERM_RGBCOLOURS);
+ tty_add_features(&c->term_features,
+ "256,"
+ "RGB,"
+ "clipboard,"
+ "cstyle,"
+ "margins,"
+ "sync,"
+ "title,",
+ ",");
+ } else if (strncmp(tmp, "TMUX ", 5) == 0) {
+ tty_add_features(&c->term_features,
+ "256,"
+ "RGB,"
+ "ccolour,"
+ "cstyle,"
+ "overline,"
+ "title,"
+ "usstyle",
+ ",");
+ }
log_debug("%s: received DSR %.*s", c->name, (int)*size, buf);
- tty_set_flags(tty, flags);
+ tty_update_features(tty);
tty->flags |= TTY_HAVEDSR;
return (0);