Sync OpenBSD patchset 453:

Drop INPUTKEY_CTRL and just handle it as part of the table.
This commit is contained in:
Tiago Cunha 2009-10-28 22:56:05 +00:00
parent dd8174f545
commit 98122860cc

View File

@ -1,4 +1,4 @@
/* $Id: input-keys.c,v 1.34 2009-10-28 22:54:54 tcunha Exp $ */ /* $Id: input-keys.c,v 1.35 2009-10-28 22:56:05 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -38,7 +38,6 @@ struct input_key_ent {
int flags; int flags;
#define INPUTKEY_KEYPAD 0x1 /* keypad key */ #define INPUTKEY_KEYPAD 0x1 /* keypad key */
#define INPUTKEY_CURSOR 0x2 /* cursor key */ #define INPUTKEY_CURSOR 0x2 /* cursor key */
#define INPUTKEY_CTRL 0x4 /* may be modified with ctrl */
}; };
struct input_key_ent input_keys[] = { struct input_key_ent input_keys[] = {
@ -46,35 +45,57 @@ struct input_key_ent input_keys[] = {
{ KEYC_BSPACE, "\177", 0 }, { KEYC_BSPACE, "\177", 0 },
/* Function keys. */ /* Function keys. */
{ KEYC_F1, "\033OP", INPUTKEY_CTRL }, { KEYC_F1, "\033OP", 0 },
{ KEYC_F2, "\033OQ", INPUTKEY_CTRL }, { KEYC_F2, "\033OQ", 0 },
{ KEYC_F3, "\033OR", INPUTKEY_CTRL }, { KEYC_F3, "\033OR", 0 },
{ KEYC_F4, "\033OS", INPUTKEY_CTRL }, { KEYC_F4, "\033OS", 0 },
{ KEYC_F5, "\033[15~", INPUTKEY_CTRL }, { KEYC_F5, "\033[15~", 0 },
{ KEYC_F6, "\033[17~", INPUTKEY_CTRL }, { KEYC_F5|KEYC_CTRL, "\033[15^", 0 },
{ KEYC_F7, "\033[18~", INPUTKEY_CTRL }, { KEYC_F6, "\033[17~", 0 },
{ KEYC_F8, "\033[19~", INPUTKEY_CTRL }, { KEYC_F6|KEYC_CTRL, "\033[17^", 0 },
{ KEYC_F9, "\033[20~", INPUTKEY_CTRL }, { KEYC_F7, "\033[18~", 0 },
{ KEYC_F10, "\033[21~", INPUTKEY_CTRL }, { KEYC_F7|KEYC_CTRL, "\033[18^", 0 },
{ KEYC_F11, "\033[23~", INPUTKEY_CTRL }, { KEYC_F8, "\033[19~", 0 },
{ KEYC_F12, "\033[24~", INPUTKEY_CTRL }, { KEYC_F8|KEYC_CTRL, "\033[19^", 0 },
{ KEYC_F13, "\033[25~", INPUTKEY_CTRL }, { KEYC_F9, "\033[20~", 0 },
{ KEYC_F14, "\033[26~", INPUTKEY_CTRL }, { KEYC_F9|KEYC_CTRL, "\033[20^", 0 },
{ KEYC_F15, "\033[28~", INPUTKEY_CTRL }, { KEYC_F10, "\033[21~", 0 },
{ KEYC_F16, "\033[29~", INPUTKEY_CTRL }, { KEYC_F10|KEYC_CTRL, "\033[21^", 0 },
{ KEYC_F17, "\033[31~", INPUTKEY_CTRL }, { KEYC_F11, "\033[23~", 0 },
{ KEYC_F18, "\033[32~", INPUTKEY_CTRL }, { KEYC_F1|KEYC_CTRL, "\033[23^", 0 },
{ KEYC_F19, "\033[33~", INPUTKEY_CTRL }, { KEYC_F12, "\033[24~", 0 },
{ KEYC_F20, "\033[34~", INPUTKEY_CTRL }, { KEYC_F12|KEYC_CTRL, "\033[24^", 0 },
{ KEYC_IC, "\033[2~", INPUTKEY_CTRL }, { KEYC_F13, "\033[25~", 0 },
{ KEYC_DC, "\033[3~", INPUTKEY_CTRL }, { KEYC_F13|KEYC_CTRL, "\033[25^", 0 },
{ KEYC_HOME, "\033[1~", INPUTKEY_CTRL }, { KEYC_F14, "\033[26~", 0 },
{ KEYC_END, "\033[4~", INPUTKEY_CTRL }, { KEYC_F14|KEYC_CTRL, "\033[26^", 0 },
{ KEYC_NPAGE, "\033[6~", INPUTKEY_CTRL }, { KEYC_F15, "\033[28~", 0 },
{ KEYC_PPAGE, "\033[5~", INPUTKEY_CTRL }, { KEYC_F15|KEYC_CTRL, "\033[28^", 0 },
{ KEYC_BTAB, "\033[Z", INPUTKEY_CTRL }, { KEYC_F16, "\033[29~", 0 },
{ KEYC_F16|KEYC_CTRL, "\033[29^", 0 },
{ KEYC_F17, "\033[31~", 0 },
{ KEYC_F17|KEYC_CTRL, "\033[31^", 0 },
{ KEYC_F18, "\033[32~", 0 },
{ KEYC_F18|KEYC_CTRL, "\033[32^", 0 },
{ KEYC_F19, "\033[33~", 0 },
{ KEYC_F19|KEYC_CTRL, "\033[33^", 0 },
{ KEYC_F20, "\033[34~", 0 },
{ KEYC_F20|KEYC_CTRL, "\033[34^", 0 },
{ KEYC_IC, "\033[2~", 0 },
{ KEYC_IC|KEYC_CTRL, "\033[2^", 0 },
{ KEYC_DC, "\033[3~", 0 },
{ KEYC_DC|KEYC_CTRL, "\033[3^", 0 },
{ KEYC_HOME, "\033[1~", 0 },
{ KEYC_HOME|KEYC_CTRL, "\033[1^", 0 },
{ KEYC_END, "\033[4~", 0 },
{ KEYC_END|KEYC_CTRL, "\033[4^", 0 },
{ KEYC_NPAGE, "\033[6~", 0 },
{ KEYC_NPAGE|KEYC_CTRL, "\033[6^", 0 },
{ KEYC_PPAGE, "\033[5~", 0 },
{ KEYC_PPAGE|KEYC_CTRL, "\033[5^", 0 },
{ KEYC_BTAB, "\033[Z", 0 },
/* Arrow keys. Cursor versions must come first .*/ /* Arrow keys. Cursor versions must come first. */
{ KEYC_UP|KEYC_CTRL, "\033Oa", 0 }, { KEYC_UP|KEYC_CTRL, "\033Oa", 0 },
{ KEYC_DOWN|KEYC_CTRL, "\033Ob", 0 }, { KEYC_DOWN|KEYC_CTRL, "\033Ob", 0 },
{ KEYC_RIGHT|KEYC_CTRL, "\033Oc", 0 }, { KEYC_RIGHT|KEYC_CTRL, "\033Oc", 0 },
@ -84,12 +105,22 @@ struct input_key_ent input_keys[] = {
{ KEYC_DOWN|KEYC_SHIFT, "\033[b", 0 }, { KEYC_DOWN|KEYC_SHIFT, "\033[b", 0 },
{ KEYC_RIGHT|KEYC_SHIFT,"\033[c", 0 }, { KEYC_RIGHT|KEYC_SHIFT,"\033[c", 0 },
{ KEYC_LEFT|KEYC_SHIFT, "\033[d", 0 }, { KEYC_LEFT|KEYC_SHIFT, "\033[d", 0 },
{ KEYC_UP|KEYC_CTRL, "\033OA", INPUTKEY_CURSOR },
{ KEYC_DOWN|KEYC_CTRL, "\033OB", INPUTKEY_CURSOR },
{ KEYC_RIGHT|KEYC_CTRL, "\033OC", INPUTKEY_CURSOR },
{ KEYC_LEFT|KEYC_CTRL, "\033OD", INPUTKEY_CURSOR },
{ KEYC_UP, "\033OA", INPUTKEY_CURSOR }, { KEYC_UP, "\033OA", INPUTKEY_CURSOR },
{ KEYC_DOWN, "\033OB", INPUTKEY_CURSOR }, { KEYC_DOWN, "\033OB", INPUTKEY_CURSOR },
{ KEYC_RIGHT, "\033OC", INPUTKEY_CURSOR }, { KEYC_RIGHT, "\033OC", INPUTKEY_CURSOR },
{ KEYC_LEFT, "\033OD", INPUTKEY_CURSOR }, { KEYC_LEFT, "\033OD", INPUTKEY_CURSOR },
{ KEYC_UP|KEYC_CTRL, "\033OA", 0 },
{ KEYC_DOWN|KEYC_CTRL, "\033OB", 0 },
{ KEYC_RIGHT|KEYC_CTRL, "\033OC", 0 },
{ KEYC_LEFT|KEYC_CTRL, "\033OD", 0 },
{ KEYC_UP, "\033[A", 0 }, { KEYC_UP, "\033[A", 0 },
{ KEYC_DOWN, "\033[B", 0 }, { KEYC_DOWN, "\033[B", 0 },
{ KEYC_RIGHT, "\033[C", 0 }, { KEYC_RIGHT, "\033[C", 0 },
@ -165,12 +196,6 @@ input_key(struct window_pane *wp, int key)
if ((key & KEYC_ESCAPE) && (ike->key | KEYC_ESCAPE) == key) if ((key & KEYC_ESCAPE) && (ike->key | KEYC_ESCAPE) == key)
break; break;
if ((key & KEYC_SHIFT) && (ike->key | KEYC_SHIFT) == key)
break;
if ((key & KEYC_CTRL) && (ike->key | KEYC_CTRL) == key) {
if (ike->flags & INPUTKEY_CTRL)
break;
}
if (ike->key == key) if (ike->key == key)
break; break;
} }
@ -179,17 +204,11 @@ input_key(struct window_pane *wp, int key)
return; return;
} }
dlen = strlen(ike->data); dlen = strlen(ike->data);
log_debug2("found key 0x%x: \"%s\"", key, ike->data); log_debug2("found key 0x%x: \"%s\"", key, ike->data);
/* Prefix a \033 for escape and set bit 5 of the last byte for ctrl. */ /* Prefix a \033 for escape. */
if (key & KEYC_ESCAPE) if (key & KEYC_ESCAPE)
buffer_write8(wp->out, '\033'); buffer_write8(wp->out, '\033');
if (key & KEYC_CTRL && ike->flags & INPUTKEY_CTRL) {
buffer_write(wp->out, ike->data, dlen - 1);
buffer_write8(wp->out, ike->data[dlen - 1] ^ 0x20);
return;
}
buffer_write(wp->out, ike->data, dlen); buffer_write(wp->out, ike->data, dlen);
} }