diff --git a/input-keys.c b/input-keys.c index 9538fc42..0a18f37e 100644 --- a/input-keys.c +++ b/input-keys.c @@ -242,11 +242,17 @@ 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 b4663d10..d8e80afb 100644 --- a/input.c +++ b/input.c @@ -1461,6 +1461,9 @@ 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; @@ -1541,6 +1544,9 @@ 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 0c27945b..53067efe 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_SGR); + s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_UTF8|MODE_MOUSE_SGR); screen_write_clearscreen(ctx); screen_write_cursormove(ctx, 0, 0); diff --git a/tmux.h b/tmux.h index 6836bb99..6ed3035c 100644 --- a/tmux.h +++ b/tmux.h @@ -601,7 +601,7 @@ struct mode_key_table { #define MODE_MOUSE_STANDARD 0x20 #define MODE_MOUSE_BUTTON 0x40 #define MODE_BLINKING 0x80 -/* 0x100 unused */ +#define MODE_MOUSE_UTF8 0x100 #define MODE_MOUSE_SGR 0x200 #define MODE_BRACKETPASTE 0x400 #define MODE_FOCUSON 0x800