aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2012-04-05 18:54:30 +0100
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2012-04-05 18:54:30 +0100
commit789a5a3c9d6be17df59491ae20e05d9620365fc7 (patch)
tree5334a34c5d2d35748f9a1b2374d2457fefbaa06a /termkey.c
parent5f942e9e3ef9a70beb31e8539dd60a5a3cc0c7a2 (diff)
downloadtermo-789a5a3c9d6be17df59491ae20e05d9620365fc7.tar.gz
termo-789a5a3c9d6be17df59491ae20e05d9620365fc7.tar.xz
termo-789a5a3c9d6be17df59491ae20e05d9620365fc7.zip
Extract modifiers for mouse events at peekkey time
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/termkey.c b/termkey.c
index 163e168..e3dec33 100644
--- a/termkey.c
+++ b/termkey.c
@@ -894,7 +894,10 @@ static TermKeyResult peekkey_mouse(TermKey *tk, TermKeyKey *key, size_t *nbytep)
key->code.mouse[0] = CHARAT(0) - 0x20;
key->code.mouse[1] = CHARAT(1) - 0x20;
key->code.mouse[2] = CHARAT(2) - 0x20;
- key->modifiers = 0;
+
+ key->modifiers = (key->code.mouse[0] & 0x1c) >> 2;
+ key->code.mouse[0] &= ~0x1c;
+
*nbytep = 3;
return TERMKEY_RES_KEY;
}
@@ -922,12 +925,14 @@ TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key, TermKe
int drag = code & 0x20;
- switch(code & ~0x20) {
+ code &= ~0x3c;
+
+ switch(code) {
case 0:
case 1:
case 2:
*event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
- btn = (code & ~0x20) + 1;
+ btn = code + 1;
break;
case 3:
@@ -938,7 +943,7 @@ TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key, TermKe
case 64:
case 65:
*event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
- btn = (code & ~0x20) + 4 - 64;
+ btn = code + 4 - 64;
break;
default: