From 32e510bd70eedbeec8590b9bf786b11430ddaac3 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 23 Nov 2015 20:53:09 +0000 Subject: [PATCH] Remove support for the UTF-8 mouse extension. This was a briefly used, poor idea that was fairly quickly replaced by SGR mouse input (which is now widespread). It is impossible to tell the difference between UTF-8 and non-UTF-8 mouse input; since the mouse-utf8 option was removed tmux has not handled it correctly in any case; and it is ridiculous to have three different forms of mouse input. --- input-keys.c | 6 ------ input.c | 6 ------ screen-write.c | 2 +- server-client.c | 11 ----------- tmux.h | 2 +- tty-keys.c | 36 ++++++++---------------------------- tty.c | 11 +---------- 7 files changed, 11 insertions(+), 63 deletions(-) diff --git a/input-keys.c b/input-keys.c index 2915cb45..4fee2f58 100644 --- a/input-keys.c +++ b/input-keys.c @@ -243,17 +243,11 @@ input_key_mouse(struct window_pane *wp, struct mouse_event *m) * is because an old style mouse release event cannot be converted into * the new SGR format, since the released button is unknown). Otherwise * pretend that tmux doesn't speak this extension, and fall back to the - * UTF-8 (1005) extension if the application requested, or to the * legacy format. */ if (m->sgr_type != ' ' && (wp->screen->mode & MODE_MOUSE_SGR)) { len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c", m->sgr_b, x + 1, y + 1, m->sgr_type); - } else if (wp->screen->mode & MODE_MOUSE_UTF8) { - len = xsnprintf(buf, sizeof buf, "\033[M"); - len += utf8_split2(m->b + 32, &buf[len]); - len += utf8_split2(x + 33, &buf[len]); - len += utf8_split2(y + 33, &buf[len]); } else { if (m->b > 223) return; diff --git a/input.c b/input.c index d8e80afb..b4663d10 100644 --- a/input.c +++ b/input.c @@ -1461,9 +1461,6 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx) case 1004: screen_write_mode_clear(&ictx->ctx, MODE_FOCUSON); break; - case 1005: - screen_write_mode_clear(&ictx->ctx, MODE_MOUSE_UTF8); - break; case 1006: screen_write_mode_clear(&ictx->ctx, MODE_MOUSE_SGR); break; @@ -1544,9 +1541,6 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx) screen_write_mode_set(&ictx->ctx, MODE_FOCUSON); wp->flags |= PANE_FOCUSPUSH; /* force update */ break; - case 1005: - screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8); - break; case 1006: screen_write_mode_set(&ictx->ctx, MODE_MOUSE_SGR); break; diff --git a/screen-write.c b/screen-write.c index 53067efe..0c27945b 100644 --- a/screen-write.c +++ b/screen-write.c @@ -56,7 +56,7 @@ screen_write_reset(struct screen_write_ctx *ctx) screen_write_scrollregion(ctx, 0, screen_size_y(s) - 1); s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD|MODE_FOCUSON); - s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_UTF8|MODE_MOUSE_SGR); + s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_SGR); screen_write_clearscreen(ctx); screen_write_cursormove(ctx, 0, 0); diff --git a/server-client.c b/server-client.c index 64426a70..c5e93438 100644 --- a/server-client.c +++ b/server-client.c @@ -808,17 +808,6 @@ server_client_reset_state(struct client *c) if (options_get_number(oo, "mouse")) mode = (mode & ~ALL_MOUSE_MODES) | MODE_MOUSE_BUTTON; - /* - * Set UTF-8 mouse input if required. If the terminal is UTF-8 and any - * mouse mode is in effect, turn on UTF-8 mouse input. If the receiving - * terminal hasn't requested it (that is, it isn't in s->mode), then - * it'll be converted in input_mouse. - */ - if ((c->tty.flags & TTY_UTF8) && (mode & ALL_MOUSE_MODES)) - mode |= MODE_MOUSE_UTF8; - else - mode &= ~MODE_MOUSE_UTF8; - /* Set the terminal mode and reset attributes. */ tty_update_mode(&c->tty, mode, s); tty_reset(&c->tty); diff --git a/tmux.h b/tmux.h index a112e7df..e697b9f8 100644 --- a/tmux.h +++ b/tmux.h @@ -599,7 +599,7 @@ struct mode_key_table { #define MODE_MOUSE_STANDARD 0x20 #define MODE_MOUSE_BUTTON 0x40 #define MODE_BLINKING 0x80 -#define MODE_MOUSE_UTF8 0x100 +/* 0x100 unused */ #define MODE_MOUSE_SGR 0x200 #define MODE_BRACKETPASTE 0x400 #define MODE_FOCUSON 0x800 diff --git a/tty-keys.c b/tty-keys.c index 706dcc30..b5e36f8e 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -481,6 +481,7 @@ tty_keys_next(struct tty *tty) /* Get key buffer. */ buf = EVBUFFER_DATA(tty->event->input); len = EVBUFFER_LENGTH(tty->event->input); + if (len == 0) return (0); log_debug("keys are %zu (%.*s)", len, (int) len, buf); @@ -653,10 +654,8 @@ int tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) { struct mouse_event *m = &tty->mouse; - struct utf8_data ud; - u_int i, value, x, y, b, sgr_b; + u_int i, x, y, b, sgr_b; u_char sgr_type, c; - enum utf8_state more; /* * Standard mouse sequences are \033[M followed by three characters @@ -686,8 +685,8 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) return (1); /* - * Third byte is M in old standard and UTF-8 extension, < in SGR - * extension. + * Third byte is M in old standard (and UTF-8 extension which we do not + * support), < in SGR extension. */ if (buf[2] == 'M') { /* Read the three inputs. */ @@ -695,32 +694,13 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) for (i = 0; i < 3; i++) { if (len <= *size) return (1); - - if (tty->mode & MODE_MOUSE_UTF8) { - if (utf8_open(&ud, buf[*size]) == UTF8_MORE) { - if (ud.size != 2) - return (-1); - (*size)++; - if (len <= *size) - return (1); - more = utf8_append(&ud, buf[*size]); - if (more != UTF8_DONE) - return (-1); - value = utf8_combine(&ud); - } else - value = (u_char)buf[*size]; - (*size)++; - } else { - value = (u_char)buf[*size]; - (*size)++; - } - + c = (u_char)buf[(*size)++]; if (i == 0) - b = value; + b = c; else if (i == 1) - x = value; + x = c; else - y = value; + y = c; } log_debug("mouse input: %.*s", (int)*size, buf); diff --git a/tty.c b/tty.c index 13ca7f8e..42be6d9f 100644 --- a/tty.c +++ b/tty.c @@ -521,21 +521,15 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s) } tty->cstyle = s->cstyle; } - if (changed & (ALL_MOUSE_MODES|MODE_MOUSE_UTF8)) { + 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"); - else - tty_puts(tty, "\033[?1005l"); tty_puts(tty, "\033[?1006h"); - if (mode & MODE_MOUSE_BUTTON) tty_puts(tty, "\033[?1002h"); else if (mode & MODE_MOUSE_STANDARD) @@ -545,10 +539,7 @@ 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"); } } if (changed & MODE_KKEYPAD) {