Skip to content

Commit 44dbfcf

Browse files
committed
feat(tui): recognize X1 and X2 mouse events
Ref: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons
1 parent d7aba51 commit 44dbfcf

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/nvim/os/input.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ static unsigned handle_mouse_event(const char **ptr, uint8_t *buf, unsigned bufs
403403

404404
if (type != KS_EXTRA
405405
|| !((mouse_code >= KE_LEFTMOUSE && mouse_code <= KE_RIGHTRELEASE)
406+
|| (mouse_code >= KE_X1MOUSE && mouse_code <= KE_X2RELEASE)
406407
|| (mouse_code >= KE_MOUSEDOWN && mouse_code <= KE_MOUSERIGHT)
407408
|| mouse_code == KE_MOUSEMOVE)) {
408409
return bufsize;

src/nvim/tui/input.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ static void forward_mouse_event(TermInput *input, TermKeyKey *key)
387387
len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Middle");
388388
} else if (button == 3) {
389389
len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Right");
390+
} else if (button == 8) {
391+
len += (size_t)snprintf(buf + len, sizeof(buf) - len, "X1");
392+
} else if (button == 9) {
393+
len += (size_t)snprintf(buf + len, sizeof(buf) - len, "X2");
390394
}
391395

392396
switch (ev) {

src/nvim/tui/termkey/driver-csi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key, TermKe
327327
btn = code + 4 - 64;
328328
break;
329329

330+
case 128:
331+
case 129:
332+
*event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
333+
btn = code + 8 - 128;
334+
break;
335+
330336
default:
331337
*event = TERMKEY_MOUSE_UNKNOWN;
332338
}

0 commit comments

Comments
 (0)