From 3a5721e91ba890718319213154ba6964c9dca4d2 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Mon, 29 Jan 2018 22:47:25 +0800 Subject: [PATCH] tui: libtermkey: force CSI driver for mouse input #7948 Fixes #7932 Nvim (tui.c) always enables SGR mouse (TUIData.unibi_ext.enable_mouse). But if libtermkey sees key_mouse (kmous) in terminfo its terminfo driver (driver-ti.c) will be activated, which by accident only supports X10 protocol. The libtermkey CSI driver (driver-csi.c), in contrast, supports SGR. We can force libtermkey to ignore the terminfo key_mouse entry by returning NULL in the tui_tk_ti_getstr hook. That forces the CSI driver. What is the effect of returning NULL from `tui_tk_ti_getstr()`? - libtermkey `driver-ti.c:load_terminfo()` skips the entry. - `termkey.c:peekkey()` iterates through all drivers, it finds `TERMKEY_RES_NONE` for the ti driver and falls back to the CSI driver. --- src/nvim/tui/tui.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2dfe7faa04..70e19e1d93 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1813,6 +1813,12 @@ static const char *tui_tk_ti_getstr(const char *name, const char *value, if (value != NULL && strequal(stty_erase, value)) { return stty_erase[0] == DEL ? CTRL_H_STR : DEL_STR; } + } else if (strequal(name, "key_mouse")) { + DLOG("libtermkey:kmous=%s", value); + // If key_mouse is found, libtermkey uses its terminfo driver (driver-ti.c) + // for mouse input, which by accident only supports X10 protocol. + // Force libtermkey to fallback to its CSI driver (driver-csi.c). #7948 + return NULL; } return value;