diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-12-17 17:39:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-12-17 17:39:57 +0000 |
commit | c3233cb536eefb71244d40d232179ef14db9f640 (patch) | |
tree | d541526c10984acd4b105f976be9af9ec8fdde65 /usr.bin/tmux/tty-keys.c | |
parent | f14c918ed15207178a34b27ded03dc260f1cef2a (diff) |
Allow keys to be replaced and reorder the table so that terminfo-defined keys
(or terminal-overrides) take precedence over internally defined.
Diffstat (limited to 'usr.bin/tmux/tty-keys.c')
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 262 |
1 files changed, 135 insertions, 127 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index 503456bc088..3a3057fda85 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.28 2009/12/14 10:43:41 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.29 2009/12/17 17:39:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -55,134 +55,38 @@ struct tty_key_ent { * otherwise they are looked up in terminfo(5). */ struct tty_key_ent tty_keys[] = { - /* Function keys. */ - { TTYC_KF1, NULL, KEYC_F1, 0 }, - { TTYC_KF2, NULL, KEYC_F2, 0 }, - { TTYC_KF3, NULL, KEYC_F3, 0 }, - { TTYC_KF4, NULL, KEYC_F4, 0 }, - { TTYC_KF5, NULL, KEYC_F5, 0 }, - { TTYC_KF6, NULL, KEYC_F6, 0 }, - { TTYC_KF7, NULL, KEYC_F7, 0 }, - { TTYC_KF8, NULL, KEYC_F8, 0 }, - { TTYC_KF9, NULL, KEYC_F9, 0 }, - { TTYC_KF10, NULL, KEYC_F10, 0 }, - { TTYC_KF11, NULL, KEYC_F11, 0 }, - { TTYC_KF12, NULL, KEYC_F12, 0 }, - { TTYC_KF13, NULL, KEYC_F13, 0 }, - { TTYC_KF14, NULL, KEYC_F14, 0 }, - { TTYC_KF15, NULL, KEYC_F15, 0 }, - { TTYC_KF16, NULL, KEYC_F16, 0 }, - { TTYC_KF17, NULL, KEYC_F17, 0 }, - { TTYC_KF18, NULL, KEYC_F18, 0 }, - { TTYC_KF19, NULL, KEYC_F19, 0 }, - { TTYC_KF20, NULL, KEYC_F20, 0 }, - { TTYC_KICH1, NULL, KEYC_IC, 0 }, - { TTYC_KDCH1, NULL, KEYC_DC, 0 }, - { TTYC_KHOME, NULL, KEYC_HOME, 0 }, - { TTYC_KEND, NULL, KEYC_END, 0 }, - { TTYC_KNP, NULL, KEYC_NPAGE, 0 }, - { TTYC_KPP, NULL, KEYC_PPAGE, 0 }, - { TTYC_KCBT, NULL, KEYC_BTAB, 0 }, - - /* Arrow keys. */ - { 0, "\033OA", KEYC_UP, TTYKEY_RAW }, - { 0, "\033OB", KEYC_DOWN, TTYKEY_RAW }, - { 0, "\033OC", KEYC_RIGHT, TTYKEY_RAW }, - { 0, "\033OD", KEYC_LEFT, TTYKEY_RAW }, - - { 0, "\033[A", KEYC_UP, TTYKEY_RAW }, - { 0, "\033[B", KEYC_DOWN, TTYKEY_RAW }, - { 0, "\033[C", KEYC_RIGHT, TTYKEY_RAW }, - { 0, "\033[D", KEYC_LEFT, TTYKEY_RAW }, - - { TTYC_KCUU1, NULL, KEYC_UP, 0 }, - { TTYC_KCUD1, NULL, KEYC_DOWN, 0 }, - { TTYC_KCUB1, NULL, KEYC_LEFT, 0 }, - { TTYC_KCUF1, NULL, KEYC_RIGHT, 0 }, - /* * Numeric keypad. Just use the vt100 escape sequences here and always * put the terminal into keypad_xmit mode. Translation of numbers * mode/applications mode is done in input-keys.c. */ - { 0, "\033Oo", KEYC_KP_SLASH, TTYKEY_RAW }, - { 0, "\033Oj", KEYC_KP_STAR, TTYKEY_RAW }, - { 0, "\033Om", KEYC_KP_MINUS, TTYKEY_RAW }, - { 0, "\033Ow", KEYC_KP_SEVEN, TTYKEY_RAW }, - { 0, "\033Ox", KEYC_KP_EIGHT, TTYKEY_RAW }, - { 0, "\033Oy", KEYC_KP_NINE, TTYKEY_RAW }, - { 0, "\033Ok", KEYC_KP_PLUS, TTYKEY_RAW }, - { 0, "\033Ot", KEYC_KP_FOUR, TTYKEY_RAW }, - { 0, "\033Ou", KEYC_KP_FIVE, TTYKEY_RAW }, - { 0, "\033Ov", KEYC_KP_SIX, TTYKEY_RAW }, - { 0, "\033Oq", KEYC_KP_ONE, TTYKEY_RAW }, - { 0, "\033Or", KEYC_KP_TWO, TTYKEY_RAW }, - { 0, "\033Os", KEYC_KP_THREE, TTYKEY_RAW }, - { 0, "\033OM", KEYC_KP_ENTER, TTYKEY_RAW }, - { 0, "\033Op", KEYC_KP_ZERO, TTYKEY_RAW }, - { 0, "\033On", KEYC_KP_PERIOD, TTYKEY_RAW }, + { 0, "\033Oo", KEYC_KP_SLASH, TTYKEY_RAW }, + { 0, "\033Oj", KEYC_KP_STAR, TTYKEY_RAW }, + { 0, "\033Om", KEYC_KP_MINUS, TTYKEY_RAW }, + { 0, "\033Ow", KEYC_KP_SEVEN, TTYKEY_RAW }, + { 0, "\033Ox", KEYC_KP_EIGHT, TTYKEY_RAW }, + { 0, "\033Oy", KEYC_KP_NINE, TTYKEY_RAW }, + { 0, "\033Ok", KEYC_KP_PLUS, TTYKEY_RAW }, + { 0, "\033Ot", KEYC_KP_FOUR, TTYKEY_RAW }, + { 0, "\033Ou", KEYC_KP_FIVE, TTYKEY_RAW }, + { 0, "\033Ov", KEYC_KP_SIX, TTYKEY_RAW }, + { 0, "\033Oq", KEYC_KP_ONE, TTYKEY_RAW }, + { 0, "\033Or", KEYC_KP_TWO, TTYKEY_RAW }, + { 0, "\033Os", KEYC_KP_THREE, TTYKEY_RAW }, + { 0, "\033OM", KEYC_KP_ENTER, TTYKEY_RAW }, + { 0, "\033Op", KEYC_KP_ZERO, TTYKEY_RAW }, + { 0, "\033On", KEYC_KP_PERIOD, TTYKEY_RAW }, - /* Key and modifier capabilities. */ - { TTYC_KDC2, NULL, KEYC_DC|KEYC_SHIFT, 0 }, - { TTYC_KDC3, NULL, KEYC_DC|KEYC_ESCAPE, 0 }, - { TTYC_KDC4, NULL, KEYC_DC|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KDC5, NULL, KEYC_DC|KEYC_CTRL, 0 }, - { TTYC_KDC6, NULL, KEYC_DC|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KDC7, NULL, KEYC_DC|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KDN2, NULL, KEYC_DOWN|KEYC_SHIFT, 0 }, - { TTYC_KDN3, NULL, KEYC_DOWN|KEYC_ESCAPE, 0 }, - { TTYC_KDN4, NULL, KEYC_DOWN|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KDN5, NULL, KEYC_DOWN|KEYC_CTRL, 0 }, - { TTYC_KDN6, NULL, KEYC_DOWN|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KDN7, NULL, KEYC_DOWN|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KEND2, NULL, KEYC_END|KEYC_SHIFT, 0 }, - { TTYC_KEND3, NULL, KEYC_END|KEYC_ESCAPE, 0 }, - { TTYC_KEND4, NULL, KEYC_END|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KEND5, NULL, KEYC_END|KEYC_CTRL, 0 }, - { TTYC_KEND6, NULL, KEYC_END|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KEND7, NULL, KEYC_END|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KHOM2, NULL, KEYC_HOME|KEYC_SHIFT, 0 }, - { TTYC_KHOM3, NULL, KEYC_HOME|KEYC_ESCAPE, 0 }, - { TTYC_KHOM4, NULL, KEYC_HOME|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KHOM5, NULL, KEYC_HOME|KEYC_CTRL, 0 }, - { TTYC_KHOM6, NULL, KEYC_HOME|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KHOM7, NULL, KEYC_HOME|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KIC2, NULL, KEYC_IC|KEYC_SHIFT, 0 }, - { TTYC_KIC3, NULL, KEYC_IC|KEYC_ESCAPE, 0 }, - { TTYC_KIC4, NULL, KEYC_IC|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KIC5, NULL, KEYC_IC|KEYC_CTRL, 0 }, - { TTYC_KIC6, NULL, KEYC_IC|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KIC7, NULL, KEYC_IC|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KLFT2, NULL, KEYC_LEFT|KEYC_SHIFT, 0 }, - { TTYC_KLFT3, NULL, KEYC_LEFT|KEYC_ESCAPE, 0 }, - { TTYC_KLFT4, NULL, KEYC_LEFT|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KLFT5, NULL, KEYC_LEFT|KEYC_CTRL, 0 }, - { TTYC_KLFT6, NULL, KEYC_LEFT|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KLFT7, NULL, KEYC_LEFT|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KNXT2, NULL, KEYC_NPAGE|KEYC_SHIFT, 0 }, - { TTYC_KNXT3, NULL, KEYC_NPAGE|KEYC_ESCAPE, 0 }, - { TTYC_KNXT4, NULL, KEYC_NPAGE|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KNXT5, NULL, KEYC_NPAGE|KEYC_CTRL, 0 }, - { TTYC_KNXT6, NULL, KEYC_NPAGE|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KNXT7, NULL, KEYC_NPAGE|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KPRV2, NULL, KEYC_PPAGE|KEYC_SHIFT, 0 }, - { TTYC_KPRV3, NULL, KEYC_PPAGE|KEYC_ESCAPE, 0 }, - { TTYC_KPRV4, NULL, KEYC_PPAGE|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KPRV5, NULL, KEYC_PPAGE|KEYC_CTRL, 0 }, - { TTYC_KPRV6, NULL, KEYC_PPAGE|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KPRV7, NULL, KEYC_PPAGE|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KRIT2, NULL, KEYC_RIGHT|KEYC_SHIFT, 0 }, - { TTYC_KRIT3, NULL, KEYC_RIGHT|KEYC_ESCAPE, 0 }, - { TTYC_KRIT4, NULL, KEYC_RIGHT|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KRIT5, NULL, KEYC_RIGHT|KEYC_CTRL, 0 }, - { TTYC_KRIT6, NULL, KEYC_RIGHT|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KRIT7, NULL, KEYC_RIGHT|KEYC_ESCAPE|KEYC_CTRL, 0 }, - { TTYC_KUP2, NULL, KEYC_UP|KEYC_SHIFT, 0 }, - { TTYC_KUP3, NULL, KEYC_UP|KEYC_ESCAPE, 0 }, - { TTYC_KUP4, NULL, KEYC_UP|KEYC_SHIFT|KEYC_ESCAPE, 0 }, - { TTYC_KUP5, NULL, KEYC_UP|KEYC_CTRL, 0 }, - { TTYC_KUP6, NULL, KEYC_UP|KEYC_SHIFT|KEYC_CTRL, 0 }, - { TTYC_KUP7, NULL, KEYC_UP|KEYC_ESCAPE|KEYC_CTRL, 0 }, + /* Arrow keys. */ + { 0, "\033OA", KEYC_UP, TTYKEY_RAW }, + { 0, "\033OB", KEYC_DOWN, TTYKEY_RAW }, + { 0, "\033OC", KEYC_RIGHT, TTYKEY_RAW }, + { 0, "\033OD", KEYC_LEFT, TTYKEY_RAW }, + + { 0, "\033[A", KEYC_UP, TTYKEY_RAW }, + { 0, "\033[B", KEYC_DOWN, TTYKEY_RAW }, + { 0, "\033[C", KEYC_RIGHT, TTYKEY_RAW }, + { 0, "\033[D", KEYC_LEFT, TTYKEY_RAW }, /* rxvt-style arrow + modifier keys. */ { 0, "\033Oa", KEYC_UP|KEYC_CTRL, TTYKEY_RAW }, @@ -279,16 +183,121 @@ struct tty_key_ent tty_keys[] = { { 0, "\033[8@", KEYC_END|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW }, { 0, "\033[6@", KEYC_NPAGE|KEYC_CTRL|KEYC_SHIFT,TTYKEY_RAW }, { 0, "\033[5@", KEYC_PPAGE|KEYC_CTRL|KEYC_SHIFT,TTYKEY_RAW }, + + /* terminfo lookups below this line so they can override raw keys. */ + + /* Function keys. */ + { TTYC_KF1, NULL, KEYC_F1, 0 }, + { TTYC_KF2, NULL, KEYC_F2, 0 }, + { TTYC_KF3, NULL, KEYC_F3, 0 }, + { TTYC_KF4, NULL, KEYC_F4, 0 }, + { TTYC_KF5, NULL, KEYC_F5, 0 }, + { TTYC_KF6, NULL, KEYC_F6, 0 }, + { TTYC_KF7, NULL, KEYC_F7, 0 }, + { TTYC_KF8, NULL, KEYC_F8, 0 }, + { TTYC_KF9, NULL, KEYC_F9, 0 }, + { TTYC_KF10, NULL, KEYC_F10, 0 }, + { TTYC_KF11, NULL, KEYC_F11, 0 }, + { TTYC_KF12, NULL, KEYC_F12, 0 }, + { TTYC_KF13, NULL, KEYC_F13, 0 }, + { TTYC_KF14, NULL, KEYC_F14, 0 }, + { TTYC_KF15, NULL, KEYC_F15, 0 }, + { TTYC_KF16, NULL, KEYC_F16, 0 }, + { TTYC_KF17, NULL, KEYC_F17, 0 }, + { TTYC_KF18, NULL, KEYC_F18, 0 }, + { TTYC_KF19, NULL, KEYC_F19, 0 }, + { TTYC_KF20, NULL, KEYC_F20, 0 }, + { TTYC_KICH1, NULL, KEYC_IC, 0 }, + { TTYC_KDCH1, NULL, KEYC_DC, 0 }, + { TTYC_KHOME, NULL, KEYC_HOME, 0 }, + { TTYC_KEND, NULL, KEYC_END, 0 }, + { TTYC_KNP, NULL, KEYC_NPAGE, 0 }, + { TTYC_KPP, NULL, KEYC_PPAGE, 0 }, + { TTYC_KCBT, NULL, KEYC_BTAB, 0 }, + + /* Arrow keys from terminfo. */ + { TTYC_KCUU1, NULL, KEYC_UP, 0 }, + { TTYC_KCUD1, NULL, KEYC_DOWN, 0 }, + { TTYC_KCUB1, NULL, KEYC_LEFT, 0 }, + { TTYC_KCUF1, NULL, KEYC_RIGHT, 0 }, + + /* Key and modifier capabilities. */ + { TTYC_KDC2, NULL, KEYC_DC|KEYC_SHIFT, 0 }, + { TTYC_KDC3, NULL, KEYC_DC|KEYC_ESCAPE, 0 }, + { TTYC_KDC4, NULL, KEYC_DC|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KDC5, NULL, KEYC_DC|KEYC_CTRL, 0 }, + { TTYC_KDC6, NULL, KEYC_DC|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KDC7, NULL, KEYC_DC|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KDN2, NULL, KEYC_DOWN|KEYC_SHIFT, 0 }, + { TTYC_KDN3, NULL, KEYC_DOWN|KEYC_ESCAPE, 0 }, + { TTYC_KDN4, NULL, KEYC_DOWN|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KDN5, NULL, KEYC_DOWN|KEYC_CTRL, 0 }, + { TTYC_KDN6, NULL, KEYC_DOWN|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KDN7, NULL, KEYC_DOWN|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KEND2, NULL, KEYC_END|KEYC_SHIFT, 0 }, + { TTYC_KEND3, NULL, KEYC_END|KEYC_ESCAPE, 0 }, + { TTYC_KEND4, NULL, KEYC_END|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KEND5, NULL, KEYC_END|KEYC_CTRL, 0 }, + { TTYC_KEND6, NULL, KEYC_END|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KEND7, NULL, KEYC_END|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KHOM2, NULL, KEYC_HOME|KEYC_SHIFT, 0 }, + { TTYC_KHOM3, NULL, KEYC_HOME|KEYC_ESCAPE, 0 }, + { TTYC_KHOM4, NULL, KEYC_HOME|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KHOM5, NULL, KEYC_HOME|KEYC_CTRL, 0 }, + { TTYC_KHOM6, NULL, KEYC_HOME|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KHOM7, NULL, KEYC_HOME|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KIC2, NULL, KEYC_IC|KEYC_SHIFT, 0 }, + { TTYC_KIC3, NULL, KEYC_IC|KEYC_ESCAPE, 0 }, + { TTYC_KIC4, NULL, KEYC_IC|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KIC5, NULL, KEYC_IC|KEYC_CTRL, 0 }, + { TTYC_KIC6, NULL, KEYC_IC|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KIC7, NULL, KEYC_IC|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KLFT2, NULL, KEYC_LEFT|KEYC_SHIFT, 0 }, + { TTYC_KLFT3, NULL, KEYC_LEFT|KEYC_ESCAPE, 0 }, + { TTYC_KLFT4, NULL, KEYC_LEFT|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KLFT5, NULL, KEYC_LEFT|KEYC_CTRL, 0 }, + { TTYC_KLFT6, NULL, KEYC_LEFT|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KLFT7, NULL, KEYC_LEFT|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KNXT2, NULL, KEYC_NPAGE|KEYC_SHIFT, 0 }, + { TTYC_KNXT3, NULL, KEYC_NPAGE|KEYC_ESCAPE, 0 }, + { TTYC_KNXT4, NULL, KEYC_NPAGE|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KNXT5, NULL, KEYC_NPAGE|KEYC_CTRL, 0 }, + { TTYC_KNXT6, NULL, KEYC_NPAGE|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KNXT7, NULL, KEYC_NPAGE|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KPRV2, NULL, KEYC_PPAGE|KEYC_SHIFT, 0 }, + { TTYC_KPRV3, NULL, KEYC_PPAGE|KEYC_ESCAPE, 0 }, + { TTYC_KPRV4, NULL, KEYC_PPAGE|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KPRV5, NULL, KEYC_PPAGE|KEYC_CTRL, 0 }, + { TTYC_KPRV6, NULL, KEYC_PPAGE|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KPRV7, NULL, KEYC_PPAGE|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KRIT2, NULL, KEYC_RIGHT|KEYC_SHIFT, 0 }, + { TTYC_KRIT3, NULL, KEYC_RIGHT|KEYC_ESCAPE, 0 }, + { TTYC_KRIT4, NULL, KEYC_RIGHT|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KRIT5, NULL, KEYC_RIGHT|KEYC_CTRL, 0 }, + { TTYC_KRIT6, NULL, KEYC_RIGHT|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KRIT7, NULL, KEYC_RIGHT|KEYC_ESCAPE|KEYC_CTRL, 0 }, + { TTYC_KUP2, NULL, KEYC_UP|KEYC_SHIFT, 0 }, + { TTYC_KUP3, NULL, KEYC_UP|KEYC_ESCAPE, 0 }, + { TTYC_KUP4, NULL, KEYC_UP|KEYC_SHIFT|KEYC_ESCAPE, 0 }, + { TTYC_KUP5, NULL, KEYC_UP|KEYC_CTRL, 0 }, + { TTYC_KUP6, NULL, KEYC_UP|KEYC_SHIFT|KEYC_CTRL, 0 }, + { TTYC_KUP7, NULL, KEYC_UP|KEYC_ESCAPE|KEYC_CTRL, 0 }, }; void tty_keys_add(struct tty *tty, const char *s, int key) { - size_t size; + struct tty_key *tk; + size_t size; + const char *keystr; - if (tty_keys_find(tty, s, strlen(s), &size) == NULL) { - log_debug("new key 0x%x: %s", key, s); + keystr = key_string_lookup_key(key); + if ((tk = tty_keys_find(tty, s, strlen(s), &size)) == NULL) { + log_debug("new key %s: 0x%x (%s)", s, key, keystr); tty_keys_add1(&tty->key_tree, s, key); + } else { + log_debug("replacing key %s: 0x%x (%s)", s, key, keystr); + tk->key = key; } } @@ -374,7 +383,6 @@ tty_keys_free1(struct tty_key *tk) if (tk->right != NULL) tty_keys_free1(tk->right); xfree(tk); - } /* Lookup a key in the tree. */ |