diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2020-04-24 15:52:44 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2020-04-24 15:52:44 +0100 |
commit | 527f66ed23a88a59fb3d8c1972336f55612059bf (patch) | |
tree | f5b23f00bd547d2d89777b93b49232498dcdf506 | |
parent | e67d65064e5541482990402fef85342f8cb4996b (diff) | |
download | rtmux-527f66ed23a88a59fb3d8c1972336f55612059bf.tar.gz rtmux-527f66ed23a88a59fb3d8c1972336f55612059bf.tar.bz2 rtmux-527f66ed23a88a59fb3d8c1972336f55612059bf.zip |
Instead of having a default set of terminals in terminal-overrides that get XT
added and using that as a marker for xterm(1)-like, assume that if the
terminfo(5) entry already has XT or the clear capability starts with CSI then
the terminal is VT100-like and it should be safe to send DA requests. The DA
responses trigger additional features being added.
This is all to detect extensions if terminfo(5) is wrong or inadequate. If it
fails, tmux will just fall back to using the capabilities in the terminfo(5)
entry alone.
-rw-r--r-- | options-table.c | 2 | ||||
-rw-r--r-- | tmux.h | 1 | ||||
-rw-r--r-- | tty-term.c | 22 | ||||
-rw-r--r-- | tty.c | 6 |
4 files changed, 23 insertions, 8 deletions
diff --git a/options-table.c b/options-table.c index 35d6b086..d593eff6 100644 --- a/options-table.c +++ b/options-table.c @@ -260,7 +260,7 @@ const struct options_table_entry options_table[] = { .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_SERVER, .flags = OPTIONS_TABLE_IS_ARRAY, - .default_str = "tmux*:XT,rxvt*:XT,screen*:XT,xterm*:XT", + .default_str = "", .separator = "," }, @@ -1202,6 +1202,7 @@ struct tty_term { #define TERM_DECSLRM 0x4 #define TERM_DECFRA 0x8 #define TERM_RGBCOLOURS 0x10 +#define TERM_VT100LIKE 0x20 int flags; LIST_ENTRY(tty_term) entry; @@ -561,16 +561,30 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause) goto error; } + /* + * If TERM has XT or clear starts with CSI then it is safe to assume + * the terminal is derived from a VT100. This controls whether device + * attributes requests are sent to get more information. + * + * This is a bit of a hack but there aren't that many alternatives. + * Worst case tmux will just fall back to using whatever terminfo(5) + * says without trying to correct anything that is missing. + * + * Also add few features that VT100-like terminals should either + * support or safely ignore. + */ + s = tty_term_string(term, TTYC_CLEAR); + if (tty_term_flag(term, TTYC_XT) || strncmp(s, "\033[", 2) == 0) { + term->flags |= TERM_VT100LIKE; + tty_add_features(feat, "bpaste,focus,title", ","); + } + /* Add RGB feature if terminal has RGB colours. */ if ((tty_term_flag(term, TTYC_TC) || tty_term_has(term, TTYC_RGB)) && (!tty_term_has(term, TTYC_SETRGBF) || !tty_term_has(term, TTYC_SETRGBB))) tty_add_features(feat, "RGB", ","); - /* Add some features if terminal has XT. */ - if (tty_term_flag(term, TTYC_XT)) - tty_add_features(feat, "bpaste,focus,title", ","); - /* Apply the features and overrides again. */ tty_apply_features(term, *feat); tty_term_apply_overrides(term); @@ -334,7 +334,7 @@ tty_start_tty(struct tty *tty) tty->flags |= TTY_FOCUS; tty_raw(tty, tty_term_string(tty->term, TTYC_ENFCS)); } - if (tty_term_flag(tty->term, TTYC_XT)) + if (tty->term->flags & TERM_VT100LIKE) tty_puts(tty, "\033[?7727h"); evtimer_set(&tty->start_timer, tty_start_timer_callback, tty); @@ -357,7 +357,7 @@ tty_send_requests(struct tty *tty) if (~tty->flags & TTY_STARTED) return; - if (tty_term_flag(tty->term, TTYC_XT)) { + if (tty->term->flags & TERM_VT100LIKE) { if (~tty->flags & TTY_HAVEDA) tty_puts(tty, "\033[>c"); if (~tty->flags & TTY_HAVEXDA) @@ -420,7 +420,7 @@ tty_stop_tty(struct tty *tty) tty->flags &= ~TTY_FOCUS; tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS)); } - if (tty_term_flag(tty->term, TTYC_XT)) + if (tty->term->flags & TERM_VT100LIKE) tty_raw(tty, "\033[?7727l"); if (tty_use_margin(tty)) |