Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit a383ab8

Browse files
committed
Ignore key_mouse unless it is exactly \e[M because some terminfos relate to different encoding modes (thanks Ninji)
1 parent c97f926 commit a383ab8

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

driver-ti.c

+22-3
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,28 @@ static int load_terminfo(TermKeyTI *ti)
332332
}
333333

334334
/* Finally mouse mode */
335-
try_load_terminfo_key(ti, "key_mouse", &(struct keyinfo){
336-
.type = TERMKEY_TYPE_MOUSE,
337-
});
335+
{
336+
const char *value = NULL;
337+
338+
#ifdef HAVE_UNIBILIUM
339+
if(ti->unibi)
340+
value = unibi_get_str_by_name(ti->unibi, "key_mouse");
341+
#else
342+
if(ti->term)
343+
value = tigetstr("key_mouse");
344+
#endif
345+
346+
if(ti->tk->ti_getstr_hook)
347+
value = (ti->tk->ti_getstr_hook)("key_mouse", value, ti->tk->ti_getstr_hook_data);
348+
349+
/* Some terminfos (e.g. xterm-1006) claim a different key_mouse that won't
350+
* give X10 encoding. We'll only accept this if it's exactly "\e[M"
351+
*/
352+
if(value && streq(value, "\x1b[M")) {
353+
struct trie_node *node = new_node_key(TERMKEY_TYPE_MOUSE, 0, 0, 0);
354+
insert_seq(ti, value, node);
355+
}
356+
}
338357

339358
/* Take copies of these terminfo strings, in case we build multiple termkey
340359
* instances for multiple different termtypes, and it's different by the

0 commit comments

Comments
 (0)