Sync OpenBSD patchset 449:

Remove the xterm-keys code which is broken (a replacement is coming but some
more cleanup is needed first).
This commit is contained in:
Tiago Cunha 2009-10-28 22:51:55 +00:00
parent 6338fd78f7
commit 165538b4bd
2 changed files with 31 additions and 136 deletions

View File

@ -1,4 +1,4 @@
/* $Id: input-keys.c,v 1.30 2009-10-12 00:18:19 tcunha Exp $ */
/* $Id: input-keys.c,v 1.31 2009-10-28 22:51:55 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -32,7 +32,6 @@ struct input_key_ent {
#define INPUTKEY_KEYPAD 0x1 /* keypad key */
#define INPUTKEY_CURSOR 0x2 /* cursor key */
#define INPUTKEY_CTRL 0x4 /* may be modified with ctrl */
#define INPUTKEY_XTERM 0x4 /* may have xterm argument appended */
};
struct input_key_ent input_keys[] = {
@ -40,32 +39,32 @@ struct input_key_ent input_keys[] = {
{ KEYC_BSPACE, "\177", 0 },
/* Function keys. */
{ KEYC_F1, "\033OP", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F2, "\033OQ", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F3, "\033OR", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F4, "\033OS", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F5, "\033[15~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F6, "\033[17~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F7, "\033[18~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F8, "\033[19~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F9, "\033[20~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F10, "\033[21~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F11, "\033[23~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F12, "\033[24~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F13, "\033[25~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F14, "\033[26~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F15, "\033[28~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F16, "\033[29~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F17, "\033[31~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F18, "\033[32~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F19, "\033[33~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F20, "\033[34~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_IC, "\033[2~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_DC, "\033[3~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_HOME, "\033[1~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_END, "\033[4~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_NPAGE, "\033[6~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_PPAGE, "\033[5~", INPUTKEY_CTRL|INPUTKEY_XTERM },
{ KEYC_F1, "\033OP", INPUTKEY_CTRL },
{ KEYC_F2, "\033OQ", INPUTKEY_CTRL },
{ KEYC_F3, "\033OR", INPUTKEY_CTRL },
{ KEYC_F4, "\033OS", INPUTKEY_CTRL },
{ KEYC_F5, "\033[15~", INPUTKEY_CTRL },
{ KEYC_F6, "\033[17~", INPUTKEY_CTRL },
{ KEYC_F7, "\033[18~", INPUTKEY_CTRL },
{ KEYC_F8, "\033[19~", INPUTKEY_CTRL },
{ KEYC_F9, "\033[20~", INPUTKEY_CTRL },
{ KEYC_F10, "\033[21~", INPUTKEY_CTRL },
{ KEYC_F11, "\033[23~", INPUTKEY_CTRL },
{ KEYC_F12, "\033[24~", INPUTKEY_CTRL },
{ KEYC_F13, "\033[25~", INPUTKEY_CTRL },
{ KEYC_F14, "\033[26~", INPUTKEY_CTRL },
{ KEYC_F15, "\033[28~", INPUTKEY_CTRL },
{ KEYC_F16, "\033[29~", INPUTKEY_CTRL },
{ KEYC_F17, "\033[31~", INPUTKEY_CTRL },
{ KEYC_F18, "\033[32~", INPUTKEY_CTRL },
{ KEYC_F19, "\033[33~", INPUTKEY_CTRL },
{ KEYC_F20, "\033[34~", INPUTKEY_CTRL },
{ KEYC_IC, "\033[2~", INPUTKEY_CTRL },
{ KEYC_DC, "\033[3~", INPUTKEY_CTRL },
{ KEYC_HOME, "\033[1~", INPUTKEY_CTRL },
{ KEYC_END, "\033[4~", INPUTKEY_CTRL },
{ KEYC_NPAGE, "\033[6~", INPUTKEY_CTRL },
{ KEYC_PPAGE, "\033[5~", INPUTKEY_CTRL },
{ KEYC_BTAB, "\033[Z", INPUTKEY_CTRL },
/* Arrow keys. Cursor versions must come first. */
@ -172,37 +171,6 @@ input_key(struct window_pane *wp, int key)
log_debug2("found key 0x%x: \"%s\"", key, ike->data);
/*
* If in xterm keys mode, work out and append the modifier as an
* argument.
*/
xterm_keys = options_get_number(&wp->window->options, "xterm-keys");
if (xterm_keys && ike->flags & INPUTKEY_XTERM) {
ch = '\0';
if (key & (KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL))
ch = '8';
else if (key & (KEYC_ESCAPE|KEYC_CTRL))
ch = '7';
else if (key & (KEYC_SHIFT|KEYC_CTRL))
ch = '6';
else if (key & KEYC_CTRL)
ch = '5';
else if (key & (KEYC_SHIFT|KEYC_ESCAPE))
ch = '4';
else if (key & KEYC_ESCAPE)
ch = '3';
else if (key & KEYC_SHIFT)
ch = '2';
if (ch != '\0') {
buffer_write(wp->out, ike->data, dlen - 1);
buffer_write8(wp->out, ';');
buffer_write8(wp->out, ch);
buffer_write8(wp->out, ike->data[dlen - 1]);
} else
buffer_write(wp->out, ike->data, dlen);
return;
}
/*
* Not in xterm mode. Prefix a \033 for escape, and set bit 5 of the
* last byte for ctrl.

View File

@ -1,4 +1,4 @@
/* $Id: tty-keys.c,v 1.31 2009-10-12 00:18:19 tcunha Exp $ */
/* $Id: tty-keys.c,v 1.32 2009-10-28 22:51:55 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -26,8 +26,7 @@
#include "tmux.h"
void tty_keys_add(struct tty *, const char *, int, int);
int tty_keys_parse_xterm(struct tty *, char *, size_t, size_t *);
int tty_keys_parse_mouse(char *, size_t, size_t *, struct mouse_event *);
int tty_keys_mouse(char *, size_t, size_t *, struct mouse_event *);
struct tty_key_ent {
enum tty_code_code code;
@ -269,14 +268,7 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse)
}
/* Not found. Is this a mouse key press? */
*key = tty_keys_parse_mouse(buf, len, &size, mouse);
if (*key != KEYC_NONE) {
buffer_remove(tty->in, size);
goto found;
}
/* Not found. Try to parse xterm-type arguments. */
*key = tty_keys_parse_xterm(tty, buf, len, &size);
*key = tty_keys_mouse(buf, len, &size, mouse);
if (*key != KEYC_NONE) {
buffer_remove(tty->in, size);
goto found;
@ -331,7 +323,7 @@ found:
}
int
tty_keys_parse_mouse(char *buf, size_t len, size_t *size, struct mouse_event *m)
tty_keys_mouse(char *buf, size_t len, size_t *size, struct mouse_event *m)
{
/*
* Mouse sequences are \033[M followed by three characters indicating
@ -353,68 +345,3 @@ tty_keys_parse_mouse(char *buf, size_t len, size_t *size, struct mouse_event *m)
m->y -= 33;
return (KEYC_MOUSE);
}
int
tty_keys_parse_xterm(struct tty *tty, char *buf, size_t len, size_t *size)
{
struct tty_key *tk;
char tmp[5];
size_t tmplen;
int key;
/*
* xterm sequences with modifier keys are of the form:
*
* ^[[1;xD becomes ^[[D
* ^[[5;x~ becomes ^[[5~
*
* This function is a bit of a hack. Need to figure out what exact
* format and meaning xterm outputs and fix it. XXX
*/
log_debug("xterm input is: %.*s", (int) len, buf);
if (len != 6 || memcmp(buf, "\033[1;", 4) != 0)
return (KEYC_NONE);
*size = 6;
tmplen = 0;
tmp[tmplen++] = '[';
if (buf[5] == '~') {
tmp[tmplen++] = buf[2];
tmp[tmplen++] = '~';
} else
tmp[tmplen++] = buf[5];
log_debug("xterm output is: %.*s", (int) tmplen, tmp);
tk = tty_keys_find(tty, tmp, tmplen, size);
if (tk == NULL)
return (KEYC_NONE);
key = tk->key;
switch (buf[4]) {
case '8':
key |= KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL;
break;
case '7':
key |= KEYC_ESCAPE|KEYC_CTRL;
break;
case '6':
key |= KEYC_SHIFT|KEYC_CTRL;
break;
case '5':
key |= KEYC_CTRL;
break;
case '4':
key |= KEYC_SHIFT|KEYC_ESCAPE;
break;
case '3':
key |= KEYC_ESCAPE;
break;
case '2':
key |= KEYC_SHIFT;
break;
}
*size = 6;
return (key);
}