aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-02-18 14:52:27 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-02-18 14:52:27 +0000
commite5eee7de0c35e296b92707fdf66ddd5271f4bcfc (patch)
treeaf6397f3e9e169d12a4cc35b25485cbb4274a313 /tty.c
parentd8261019f1b1fcf58a79b82448e8851e3acfd026 (diff)
downloadrtmux-e5eee7de0c35e296b92707fdf66ddd5271f4bcfc.tar.gz
rtmux-e5eee7de0c35e296b92707fdf66ddd5271f4bcfc.tar.bz2
rtmux-e5eee7de0c35e296b92707fdf66ddd5271f4bcfc.zip
Support the latest theory for mouse input, this is enabled/disabled with SM/RM
1006 and is similar in style to SGR input: \033[<b;x;yM or \033[b;x;ym. From Egmont Koblinger.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tty.c b/tty.c
index bae97ac8..6da63bf1 100644
--- a/tty.c
+++ b/tty.c
@@ -218,7 +218,7 @@ tty_start_tty(struct tty *tty)
tty_putcode(tty, TTYC_CNORM);
if (tty_term_has(tty->term, TTYC_KMOUS))
- tty_puts(tty, "\033[?1000l");
+ tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l");
if (tty_term_has(tty->term, TTYC_XT))
tty_puts(tty, "\033[c\033[>4;1m");
@@ -281,7 +281,7 @@ tty_stop_tty(struct tty *tty)
tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
if (tty_term_has(tty->term, TTYC_KMOUS))
- tty_raw(tty, "\033[?1000l");
+ tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l");
if (tty_term_has(tty->term, TTYC_XT))
tty_puts(tty, "\033[>4m");
@@ -491,8 +491,17 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
}
if (changed & ALL_MOUSE_MODES) {
if (mode & ALL_MOUSE_MODES) {
+ /*
+ * Enable the UTF-8 (1005) extension if configured to.
+ * Enable the SGR (1006) extension unconditionally, as
+ * this is safe from misinterpretation. Do it in this
+ * order, because in some terminals it's the last one
+ * that takes effect and SGR is the preferred one.
+ */
if (mode & MODE_MOUSE_UTF8)
tty_puts(tty, "\033[?1005h");
+ tty_puts(tty, "\033[?1006h");
+
if (mode & MODE_MOUSE_ANY)
tty_puts(tty, "\033[?1003h");
else if (mode & MODE_MOUSE_BUTTON)
@@ -506,6 +515,8 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
tty_puts(tty, "\033[?1002l");
else if (tty->mode & MODE_MOUSE_STANDARD)
tty_puts(tty, "\033[?1000l");
+
+ tty_puts(tty, "\033[?1006l");
if (tty->mode & MODE_MOUSE_UTF8)
tty_puts(tty, "\033[?1005l");
}