=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty-keys.c,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** src/usr.bin/tmux/tty-keys.c 2009/10/26 17:59:46 1.12 --- src/usr.bin/tmux/tty-keys.c 2009/11/04 21:47:42 1.13 *************** *** 1,4 **** ! /* $OpenBSD: tty-keys.c,v 1.12 2009/10/26 17:59:46 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty-keys.c,v 1.13 2009/11/04 21:47:42 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 299,316 **** struct tty_key *tk; struct timeval tv; char *buf; size_t len, size; cc_t bspace; ! buf = BUFFER_OUT(tty->in); ! len = BUFFER_USED(tty->in); if (len == 0) return (1); log_debug("keys are %zu (%.*s)", len, (int) len, buf); /* If a normal key, return it. */ if (*buf != '\033') { ! *key = buffer_read8(tty->in); /* * Check for backspace key using termios VERASE - the terminfo --- 299,318 ---- struct tty_key *tk; struct timeval tv; char *buf; + u_char ch; size_t len, size; cc_t bspace; ! buf = EVBUFFER_DATA(tty->event->input); ! len = EVBUFFER_LENGTH(tty->event->input); if (len == 0) return (1); log_debug("keys are %zu (%.*s)", len, (int) len, buf); /* If a normal key, return it. */ if (*buf != '\033') { ! bufferevent_read(tty->event, &ch, 1); ! *key = ch; /* * Check for backspace key using termios VERASE - the terminfo *************** *** 326,332 **** /* Look for matching key string and return if found. */ tk = tty_keys_find(tty, buf + 1, len - 1, &size); if (tk != NULL) { ! buffer_remove(tty->in, size + 1); *key = tk->key; goto found; } --- 328,334 ---- /* Look for matching key string and return if found. */ tk = tty_keys_find(tty, buf + 1, len - 1, &size); if (tk != NULL) { ! evbuffer_drain(tty->event->input, size + 1); *key = tk->key; goto found; } *************** *** 334,347 **** /* 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; } /* Not found. Try to parse a key with an xterm-style modifier. */ *key = xterm_keys_find(buf, len, &size); if (*key != KEYC_NONE) { ! buffer_remove(tty->in, size); goto found; } --- 336,349 ---- /* Not found. Is this a mouse key press? */ *key = tty_keys_mouse(buf, len, &size, mouse); if (*key != KEYC_NONE) { ! evbuffer_drain(tty->event->input, size); goto found; } /* Not found. Try to parse a key with an xterm-style modifier. */ *key = xterm_keys_find(buf, len, &size); if (*key != KEYC_NONE) { ! evbuffer_drain(tty->event->input, size); goto found; } *************** *** 363,370 **** /* Is there a normal key following? */ if (len != 0 && *buf != '\033') { ! buffer_remove(tty->in, 1); ! *key = buffer_read8(tty->in) | KEYC_ESCAPE; goto found; } --- 365,373 ---- /* Is there a normal key following? */ if (len != 0 && *buf != '\033') { ! evbuffer_drain(tty->event->input, 1); ! bufferevent_read(tty->event, &ch, 1); ! *key = ch | KEYC_ESCAPE; goto found; } *************** *** 372,378 **** if (len > 1) { tk = tty_keys_find(tty, buf + 1, len - 1, &size); if (tk != NULL) { ! buffer_remove(tty->in, size + 2); *key = tk->key | KEYC_ESCAPE; goto found; } --- 375,381 ---- if (len > 1) { tk = tty_keys_find(tty, buf + 1, len - 1, &size); if (tk != NULL) { ! evbuffer_drain(tty->event->input, size + 2); *key = tk->key | KEYC_ESCAPE; goto found; } *************** *** 385,391 **** return (1); /* Give up and return the escape. */ ! buffer_remove(tty->in, 1); *key = '\033'; found: --- 388,394 ---- return (1); /* Give up and return the escape. */ ! evbuffer_drain(tty->event->input, 1); *key = '\033'; found: