mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-08 09:14:22 +01:00
Merge branch 'obsd-master'
This commit is contained in:
commit
b642b3c8e3
@ -242,17 +242,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;
|
||||
|
6
input.c
6
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;
|
||||
|
@ -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);
|
||||
|
@ -816,17 +816,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);
|
||||
|
2
tmux.h
2
tmux.h
@ -601,7 +601,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
|
||||
|
36
tty-keys.c
36
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);
|
||||
|
||||
|
11
tty.c
11
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user