=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty-keys.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/tmux/tty-keys.c 2009/10/11 07:01:10 1.5 --- src/usr.bin/tmux/tty-keys.c 2009/10/26 13:02:53 1.6 *************** *** 1,4 **** ! /* $OpenBSD: tty-keys.c,v 1.5 2009/10/11 07:01:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty-keys.c,v 1.6 2009/10/26 13:02:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 26,33 **** #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 *); struct tty_key_ent { enum tty_code_code code; --- 26,32 ---- #include "tmux.h" void tty_keys_add(struct tty *, const char *, int, int); ! int tty_keys_mouse(char *, size_t, size_t *, struct mouse_event *); struct tty_key_ent { enum tty_code_code code; *************** *** 269,287 **** } /* 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); - if (*key != KEYC_NONE) { - buffer_remove(tty->in, size); - goto found; - } - /* Escape but no key string. If the timer isn't started, start it. */ if (!(tty->flags & TTY_ESCAPE)) { tv.tv_sec = 0; --- 268,279 ---- } /* Not found. Is this a mouse key press? */ ! *key = tty_keys_mouse(buf, len, &size, mouse); if (*key != KEYC_NONE) { buffer_remove(tty->in, size); goto found; } /* Escape but no key string. If the timer isn't started, start it. */ if (!(tty->flags & TTY_ESCAPE)) { tv.tv_sec = 0; *************** *** 331,337 **** } int ! tty_keys_parse_mouse(char *buf, size_t len, size_t *size, struct mouse_event *m) { /* * Mouse sequences are \033[M followed by three characters indicating --- 323,329 ---- } int ! 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 *************** *** 352,420 **** m->x -= 33; 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); } --- 344,347 ----