summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-04-16 15:14:26 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-04-16 15:14:26 +0000
commitb39aa7527bdf30a627a49c7cad64ffa4444c0f10 (patch)
tree37ef7f69e8a77319fa4819db9e1669bdb08152f4
parent678ad617516931a13b099db8fd64228b8168c247 (diff)
Send secondary device attributes instead of primary which gives us a bit
more useful information on some terminals.
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/tty-keys.c34
-rw-r--r--usr.bin/tmux/tty.c7
3 files changed, 26 insertions, 18 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 66753c75794..5e2ba30b16b 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.998 2020/04/16 14:25:35 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.999 2020/04/16 15:14:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1261,6 +1261,7 @@ struct tty {
struct event key_timer;
struct tty_key *key_tree;
};
+#define tty_term_flags(tty) (tty->term->flags|tty->term_flags)
/* TTY command context. */
struct tty_ctx {
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index ff4d8fd93df..a66f2154292 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.123 2020/04/16 13:35:24 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.124 2020/04/16 15:14:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1007,8 +1007,8 @@ tty_keys_clipboard(__unused struct tty *tty, const char *buf, size_t len,
}
/*
- * Handle device attributes input. Returns 0 for success, -1 for failure, 1 for
- * partial.
+ * Handle secondary device attributes input. Returns 0 for success, -1 for
+ * failure, 1 for partial.
*/
static int
tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
@@ -1032,7 +1032,7 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
return (-1);
if (len == 2)
return (1);
- if (buf[2] != '?')
+ if (buf[2] != '>')
return (-1);
if (len == 3)
return (1);
@@ -1048,7 +1048,7 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
tmp[i] = '\0';
*size = 4 + i;
- /* Convert version numbers. */
+ /* Convert all arguments to numbers. */
cp = tmp;
while ((next = strsep(&cp, ";")) != NULL) {
p[n] = strtoul(next, &endptr, 10);
@@ -1059,13 +1059,20 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
/* Set terminal flags. */
switch (p[0]) {
- case 64: /* VT420 */
+ case 41: /* VT420 */
flags |= (TERM_DECFRA|TERM_DECSLRM);
break;
+ case 'M': /* mintty */
+ flags |= (TERM_256COLOURS|TERM_RGBCOLOURS);
+ break;
+ case 'T': /* tmux - if newer will have the DSR as well */
+ flags |= (TERM_UTF8|TERM_256COLOURS);
+ break;
+ case 'U': /* rxvt-unicode */
+ flags |= (TERM_UTF8);
+ break;
}
- for (i = 1; i < n; i++)
- log_debug("%s: DA feature: %d", c->name, p[i]);
- log_debug("%s: received DA %.*s", c->name, (int)*size, buf);
+ log_debug("%s: received secondary DA %.*s", c->name, (int)*size, buf);
tty_set_flags(tty, flags);
tty->flags |= TTY_HAVEDA;
@@ -1116,10 +1123,11 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
*size = 3 + i;
/* Set terminal flags. */
- if (strncmp(tmp, "ITERM2 ", 7) == 0)
- flags |= (TERM_DECSLRM|TERM_256COLOURS|TERM_RGBCOLOURS|TERM_SYNC);
- if (strncmp(tmp, "TMUX ", 5) == 0)
- flags |= (TERM_256COLOURS|TERM_RGBCOLOURS);
+ 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);
log_debug("%s: received DSR %.*s", c->name, (int)*size, buf);
tty_set_flags(tty, flags);
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 38c81ecea9a..87d6d098f54 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.350 2020/04/16 14:25:35 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.351 2020/04/16 15:14:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -364,7 +364,7 @@ tty_send_requests(struct tty *tty)
if (tty_term_flag(tty->term, TTYC_XT)) {
if (~tty->flags & TTY_HAVEDA)
- tty_puts(tty, "\033[c");
+ tty_puts(tty, "\033[>c");
if (~tty->flags & TTY_HAVEDSR)
tty_puts(tty, "\033[1337n");
} else
@@ -1175,8 +1175,7 @@ tty_clear_area(struct tty *tty, struct window_pane *wp, u_int py, u_int ny,
* background colour isn't default (because it doesn't work
* after SGR 0).
*/
- if ((tty_get_flags(tty) & TERM_DECFRA) &&
- !COLOUR_DEFAULT(bg)) {
+ if ((tty_get_flags(tty) & TERM_DECFRA) && !COLOUR_DEFAULT(bg)) {
xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x",
py + 1, px + 1, py + ny, px + nx);
tty_puts(tty, tmp);