aboutsummaryrefslogtreecommitdiff
path: root/input-keys.c
diff options
context:
space:
mode:
authorThomas Adam <thomas.adam@smoothwall.net>2013-03-25 14:59:29 +0000
committerThomas Adam <thomas.adam@smoothwall.net>2013-03-25 14:59:29 +0000
commitf90eb43fcb12720711ea01b110c5b474111e6600 (patch)
tree43b2e85bcf1626e3810ade10578ac18399931772 /input-keys.c
parent418ba99078a2712ece398e17a5a9bc1f6600126b (diff)
parent58bb6f8c5650d496fb3b872766c0278aa024631d (diff)
downloadrtmux-f90eb43fcb12720711ea01b110c5b474111e6600.tar.gz
rtmux-f90eb43fcb12720711ea01b110c5b474111e6600.tar.bz2
rtmux-f90eb43fcb12720711ea01b110c5b474111e6600.zip
Merge branch 'obsd-master'
Diffstat (limited to 'input-keys.c')
-rw-r--r--input-keys.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/input-keys.c b/input-keys.c
index 0953ce7e..faa7bd17 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -201,12 +201,26 @@ 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]);