Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.

This commit is contained in:
nicm 2020-07-06 07:27:39 +00:00
parent 1e42689661
commit 2bf612a806
3 changed files with 47 additions and 28 deletions

View File

@ -164,6 +164,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "invalid key: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}
only &= KEYC_MASK_KEY;
}
tablename = args_get(args, 'T');

View File

@ -32,30 +32,30 @@ static const struct {
key_code key;
} key_string_table[] = {
/* Function keys. */
{ "F1", KEYC_F1 },
{ "F2", KEYC_F2 },
{ "F3", KEYC_F3 },
{ "F4", KEYC_F4 },
{ "F5", KEYC_F5 },
{ "F6", KEYC_F6 },
{ "F7", KEYC_F7 },
{ "F8", KEYC_F8 },
{ "F9", KEYC_F9 },
{ "F10", KEYC_F10 },
{ "F11", KEYC_F11 },
{ "F12", KEYC_F12 },
{ "IC", KEYC_IC },
{ "Insert", KEYC_IC },
{ "DC", KEYC_DC },
{ "Delete", KEYC_DC },
{ "Home", KEYC_HOME },
{ "End", KEYC_END },
{ "NPage", KEYC_NPAGE },
{ "PageDown", KEYC_NPAGE },
{ "PgDn", KEYC_NPAGE },
{ "PPage", KEYC_PPAGE },
{ "PageUp", KEYC_PPAGE },
{ "PgUp", KEYC_PPAGE },
{ "F1", KEYC_F1|KEYC_IMPLIED_META },
{ "F2", KEYC_F2|KEYC_IMPLIED_META },
{ "F3", KEYC_F3|KEYC_IMPLIED_META },
{ "F4", KEYC_F4|KEYC_IMPLIED_META },
{ "F5", KEYC_F5|KEYC_IMPLIED_META },
{ "F6", KEYC_F6|KEYC_IMPLIED_META },
{ "F7", KEYC_F7|KEYC_IMPLIED_META },
{ "F8", KEYC_F8|KEYC_IMPLIED_META },
{ "F9", KEYC_F9|KEYC_IMPLIED_META },
{ "F10", KEYC_F10|KEYC_IMPLIED_META },
{ "F11", KEYC_F11|KEYC_IMPLIED_META },
{ "F12", KEYC_F12|KEYC_IMPLIED_META },
{ "IC", KEYC_IC|KEYC_IMPLIED_META },
{ "Insert", KEYC_IC|KEYC_IMPLIED_META },
{ "DC", KEYC_DC|KEYC_IMPLIED_META },
{ "Delete", KEYC_DC|KEYC_IMPLIED_META },
{ "Home", KEYC_HOME|KEYC_IMPLIED_META },
{ "End", KEYC_END|KEYC_IMPLIED_META },
{ "NPage", KEYC_NPAGE|KEYC_IMPLIED_META },
{ "PageDown", KEYC_NPAGE|KEYC_IMPLIED_META },
{ "PgDn", KEYC_NPAGE|KEYC_IMPLIED_META },
{ "PPage", KEYC_PPAGE|KEYC_IMPLIED_META },
{ "PageUp", KEYC_PPAGE|KEYC_IMPLIED_META },
{ "PgUp", KEYC_PPAGE|KEYC_IMPLIED_META },
{ "Tab", '\011' },
{ "BTab", KEYC_BTAB },
{ "Space", ' ' },
@ -64,10 +64,10 @@ static const struct {
{ "Escape", '\033' },
/* Arrow keys. */
{ "Up", KEYC_UP|KEYC_CURSOR },
{ "Down", KEYC_DOWN|KEYC_CURSOR },
{ "Left", KEYC_LEFT|KEYC_CURSOR },
{ "Right", KEYC_RIGHT|KEYC_CURSOR },
{ "Up", KEYC_UP|KEYC_CURSOR|KEYC_IMPLIED_META },
{ "Down", KEYC_DOWN|KEYC_CURSOR|KEYC_IMPLIED_META },
{ "Left", KEYC_LEFT|KEYC_CURSOR|KEYC_IMPLIED_META },
{ "Right", KEYC_RIGHT|KEYC_CURSOR|KEYC_IMPLIED_META },
/* Numeric keypad. */
{ "KP/", KEYC_KP_SLASH|KEYC_KEYPAD },
@ -233,6 +233,8 @@ key_string_lookup_string(const char *string)
key = key_string_search_table(string);
if (key == KEYC_UNKNOWN)
return (KEYC_UNKNOWN);
if (~modifiers & KEYC_META)
key &= ~KEYC_IMPLIED_META;
}
/* Convert the standard control keys. */

View File

@ -95,18 +95,34 @@ static const struct tty_default_key_raw tty_default_raw_keys[] = {
{ "\033OC", KEYC_RIGHT|KEYC_CURSOR },
{ "\033OD", KEYC_LEFT|KEYC_CURSOR },
{ "\033\033OA", KEYC_UP|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033OB", KEYC_DOWN|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033OC", KEYC_RIGHT|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033OD", KEYC_LEFT|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033[A", KEYC_UP|KEYC_CURSOR },
{ "\033[B", KEYC_DOWN|KEYC_CURSOR },
{ "\033[C", KEYC_RIGHT|KEYC_CURSOR },
{ "\033[D", KEYC_LEFT|KEYC_CURSOR },
{ "\033\033[A", KEYC_UP|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033[B", KEYC_DOWN|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033[C", KEYC_RIGHT|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033[D", KEYC_LEFT|KEYC_CURSOR|KEYC_META|KEYC_IMPLIED_META },
/* Other (xterm) "cursor" keys. */
{ "\033OH", KEYC_HOME },
{ "\033OF", KEYC_END },
{ "\033\033OH", KEYC_HOME|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033OF", KEYC_END|KEYC_META|KEYC_IMPLIED_META },
{ "\033[H", KEYC_HOME },
{ "\033[F", KEYC_END },
{ "\033\033[H", KEYC_HOME|KEYC_META|KEYC_IMPLIED_META },
{ "\033\033[F", KEYC_END|KEYC_META|KEYC_IMPLIED_META },
/* rxvt-style arrow + modifier keys. */
{ "\033Oa", KEYC_UP|KEYC_CTRL },
{ "\033Ob", KEYC_DOWN|KEYC_CTRL },