diff options
author | 2013-03-22 10:33:50 +0000 | |
---|---|---|
committer | 2013-03-22 10:33:50 +0000 | |
commit | 6c0777c525839bed1243f354e5ffc93c7045101c (patch) | |
tree | b22b51e7ff2042cf3ec6c74e352dd4a33787db61 /usr.bin/tmux/input-keys.c | |
parent | Add client_session and client_last_session formats. (diff) | |
download | wireguard-openbsd-6c0777c525839bed1243f354e5ffc93c7045101c.tar.xz wireguard-openbsd-6c0777c525839bed1243f354e5ffc93c7045101c.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 'usr.bin/tmux/input-keys.c')
-rw-r--r-- | usr.bin/tmux/input-keys.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c index 67140a35d1e..c19244dce4d 100644 --- a/usr.bin/tmux/input-keys.c +++ b/usr.bin/tmux/input-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input-keys.c,v 1.30 2012/11/27 20:22:12 nicm Exp $ */ +/* $OpenBSD: input-keys.c,v 1.31 2013/03/22 10:33:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -202,12 +202,25 @@ input_key(struct window_pane *wp, int key) void input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m) { - char buf[10]; + char buf[40]; size_t len; struct paste_buffer *pb; if (wp->screen->mode & ALL_MOUSE_MODES) { - if (wp->screen->mode & MODE_MOUSE_UTF8) { + /* + * Use the SGR (1006) extension only if the application + * requested it and the underlying terminal also sent the event + * in this format (this 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 && (wp->screen->mode & MODE_MOUSE_SGR)) { + len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c", + m->sgr_xb, m->x + 1, m->y + 1, m->sgr_rel ? 'm' : 'M'); + } else if (wp->screen->mode & MODE_MOUSE_UTF8) { len = xsnprintf(buf, sizeof buf, "\033[M"); len += utf8_split2(m->xb + 32, &buf[len]); len += utf8_split2(m->x + 33, &buf[len]); |