summaryrefslogtreecommitdiffstats
path: root/tty-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2014-04-03 08:20:29 +0000
committernicm <nicm>2014-04-03 08:20:29 +0000
commitacef311fe356f408690e9f94727ed63a934b742f (patch)
treede04ad3fd0267ac02a8fd127aaf802b4287d2b45 /tty-keys.c
parent8824dae6f7b21f95ea824ecc1abc31140763c971 (diff)
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.
Diffstat (limited to 'tty-keys.c')
-rw-r--r--tty-keys.c9
1 files changed, 9 insertions, 0 deletions
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;