Support rxvt-style keys again, but this time: support all the variations, put

them in as raw escape sequences rather than fiddling with the values from
terminfo, put them /after/ the terminfo values so the latter take precedence.
This commit is contained in:
Nicholas Marriott 2009-11-12 08:01:02 +00:00
parent 89763f2ace
commit d9deb4b530

View File

@ -57,7 +57,6 @@ struct tty_key_ent {
struct tty_key_ent tty_keys[] = {
/* Function keys. */
{ TTYC_KF1, NULL, KEYC_F1, 0 },
{ TTYC_KF1, NULL, KEYC_F1, 0 },
{ TTYC_KF2, NULL, KEYC_F2, 0 },
{ TTYC_KF3, NULL, KEYC_F3, 0 },
{ TTYC_KF4, NULL, KEYC_F4, 0 },
@ -101,17 +100,6 @@ struct tty_key_ent tty_keys[] = {
{ TTYC_KCUB1, NULL, KEYC_LEFT, 0 },
{ TTYC_KCUF1, NULL, KEYC_RIGHT, 0 },
/* Special-case arrow keys for rxvt until terminfo has kRIT5 etc. */
{ 0, "\033Oa", KEYC_UP|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033Ob", KEYC_DOWN|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033Oc", KEYC_RIGHT|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033Od", KEYC_LEFT|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[a", KEYC_UP|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[b", KEYC_DOWN|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[c", KEYC_RIGHT|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[d", KEYC_LEFT|KEYC_SHIFT, TTYKEY_RAW },
/*
* Numeric keypad. Just use the vt100 escape sequences here and always
* put the terminal into keypad_xmit mode. Translation of numbers
@ -195,6 +183,102 @@ struct tty_key_ent tty_keys[] = {
{ 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 },
/* rxvt-style arrow + modifier keys. */
{ 0, "\033Oa", KEYC_UP|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033Ob", KEYC_DOWN|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033Oc", KEYC_RIGHT|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033Od", KEYC_LEFT|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[a", KEYC_UP|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[b", KEYC_DOWN|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[c", KEYC_RIGHT|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[d", KEYC_LEFT|KEYC_SHIFT, TTYKEY_RAW },
/*
* rxvt-style function + modifier keys:
* Ctrl = ^, Shift = $, Ctrl+Shift = @
*/
{ 0, "\033[11^", KEYC_F1|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[12^", KEYC_F2|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[13^", KEYC_F3|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[14^", KEYC_F4|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[15^", KEYC_F5|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[17^", KEYC_F6|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[18^", KEYC_F7|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[19^", KEYC_F8|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[20^", KEYC_F9|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[21^", KEYC_F10|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[23^", KEYC_F11|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[24^", KEYC_F12|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[25^", KEYC_F13|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[26^", KEYC_F14|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[28^", KEYC_F15|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[29^", KEYC_F16|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[31^", KEYC_F17|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[32^", KEYC_F18|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[33^", KEYC_F19|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[34^", KEYC_F20|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[2^", KEYC_IC|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[3^", KEYC_DC|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[7^", KEYC_HOME|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[8^", KEYC_END|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[6^", KEYC_NPAGE|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[5^", KEYC_PPAGE|KEYC_CTRL, TTYKEY_RAW },
{ 0, "\033[11$", KEYC_F1|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[12$", KEYC_F2|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[13$", KEYC_F3|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[14$", KEYC_F4|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[15$", KEYC_F5|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[17$", KEYC_F6|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[18$", KEYC_F7|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[19$", KEYC_F8|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[20$", KEYC_F9|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[21$", KEYC_F10|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[23$", KEYC_F11|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[24$", KEYC_F12|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[25$", KEYC_F13|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[26$", KEYC_F14|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[28$", KEYC_F15|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[29$", KEYC_F16|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[31$", KEYC_F17|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[32$", KEYC_F18|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[33$", KEYC_F19|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[34$", KEYC_F20|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[2$", KEYC_IC|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[3$", KEYC_DC|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[7$", KEYC_HOME|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[8$", KEYC_END|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[6$", KEYC_NPAGE|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[5$", KEYC_PPAGE|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[11@", KEYC_F1|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[12@", KEYC_F2|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[13@", KEYC_F3|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[14@", KEYC_F4|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[15@", KEYC_F5|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[17@", KEYC_F6|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[18@", KEYC_F7|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[19@", KEYC_F8|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[20@", KEYC_F9|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[21@", KEYC_F10|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[23@", KEYC_F11|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[24@", KEYC_F12|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[25@", KEYC_F13|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[26@", KEYC_F14|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[28@", KEYC_F15|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[29@", KEYC_F16|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[31@", KEYC_F17|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[32@", KEYC_F18|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[33@", KEYC_F19|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[34@", KEYC_F20|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[2@", KEYC_IC|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[3@", KEYC_DC|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 0, "\033[7@", KEYC_HOME|KEYC_CTRL|KEYC_SHIFT, TTYKEY_RAW },
{ 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 },
};
void