From ffe96c6c1c6c54bc03f2d534c9a6bf92c2dd1e51 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Thu, 27 Jun 2019 21:45:23 +0100 Subject: [PATCH] Ignore key_mouse unless it is exactly \e[M because some terminfos relate to different encoding modes (thanks Ninji) --- src/termkey/driver-ti.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/termkey/driver-ti.c b/src/termkey/driver-ti.c index 00a7066796..1f8ee10808 100644 --- a/src/termkey/driver-ti.c +++ b/src/termkey/driver-ti.c @@ -334,9 +334,28 @@ static int load_terminfo(TermKeyTI *ti) } /* Finally mouse mode */ - try_load_terminfo_key(ti, "key_mouse", &(struct keyinfo){ - .type = TERMKEY_TYPE_MOUSE, - }); + { + const char *value = NULL; + +#ifdef HAVE_UNIBILIUM + if(ti->unibi) + value = unibi_get_str_by_name(ti->unibi, "key_mouse"); +#else + if(ti->term) + value = tigetstr("key_mouse"); +#endif + + if(ti->tk->ti_getstr_hook) + value = (ti->tk->ti_getstr_hook)("key_mouse", value, ti->tk->ti_getstr_hook_data); + + /* Some terminfos (e.g. xterm-1006) claim a different key_mouse that won't + * give X10 encoding. We'll only accept this if it's exactly "\e[M" + */ + if(value && streq(value, "\x1b[M")) { + struct trie_node *node = new_node_key(TERMKEY_TYPE_MOUSE, 0, 0, 0); + insert_seq(ti, value, node); + } + } /* Take copies of these terminfo strings, in case we build multiple termkey * instances for multiple different termtypes, and it's different by the