From 46593e7aa26b83f0ba1b0d36a700d7158ac2b178 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 31 Mar 2014 21:40:21 +0000 Subject: Add names for mouse button bits rather than using magic numbers, from Marcel Partap. --- tty-keys.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index 4492df1e..e0e794cc 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -748,21 +748,21 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->sgr_rel = sgr_rel; m->x = x; m->y = y; - if (b & 64) { /* wheel button */ - b &= 3; + if (b & MOUSE_MASK_WHEEL) { + b &= MOUSE_MASK_BUTTONS; if (b == 0) m->wheel = MOUSE_WHEEL_UP; else if (b == 1) m->wheel = MOUSE_WHEEL_DOWN; m->event = MOUSE_EVENT_WHEEL; - } else if ((b & 3) == 3) { + } else if ((b & MOUSE_MASK_BUTTONS) == 3) { if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) { m->event = MOUSE_EVENT_CLICK; } else m->event = MOUSE_EVENT_DRAG; m->event |= MOUSE_EVENT_UP; } else { - if (b & 32) /* drag motion */ + if (b & MOUSE_MASK_DRAG) m->event = MOUSE_EVENT_DRAG; else { if (m->event & MOUSE_EVENT_UP && x == m->x && y == m->y) @@ -773,7 +773,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->sy = y; m->event = MOUSE_EVENT_DOWN; } - m->button = (b & 3); + m->button = (b & MOUSE_MASK_BUTTONS); } return (0); -- cgit From 8824dae6f7b21f95ea824ecc1abc31140763c971 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Apr 2014 08:15:17 +0000 Subject: A couple of trivial mouse-related style nits. --- tty-keys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index e0e794cc..1116df2b 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -756,9 +756,9 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->wheel = MOUSE_WHEEL_DOWN; m->event = MOUSE_EVENT_WHEEL; } else if ((b & MOUSE_MASK_BUTTONS) == 3) { - if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) { + if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) m->event = MOUSE_EVENT_CLICK; - } else + else m->event = MOUSE_EVENT_DRAG; m->event |= MOUSE_EVENT_UP; } else { -- cgit From acef311fe356f408690e9f94727ed63a934b742f Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Apr 2014 08:20:29 +0000 Subject: Work out mouse scroll wheel effect when the mouse is first detected and store it in struct mouse_event, reduce the scroll size the 3 but allow shift to reduce it to 1 and meta and ctrl to multiply by 3 if the terminal supports them, also support wheel in choose mode. From Marcel Partap. --- tty-keys.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index 1116df2b..4f55a80c 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -749,6 +749,15 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->x = x; m->y = y; if (b & MOUSE_MASK_WHEEL) { + if (b & MOUSE_MASK_SHIFT) + m->scroll = 1; + else + m->scroll = 3; + if (b & MOUSE_MASK_META) + m->scroll *= 3; + if (b & MOUSE_MASK_CTRL) + m->scroll *= 3; + b &= MOUSE_MASK_BUTTONS; if (b == 0) m->wheel = MOUSE_WHEEL_UP; -- cgit