diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-04 21:47:43 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-04 21:47:43 +0000 |
commit | 61f1e016a392ec594bd75c723836afda9e8af879 (patch) | |
tree | 9e4a33bd9e94ea82a64f94ea857ccda80f47e47a /usr.bin/tmux/tty-keys.c | |
parent | 4a10595dee0afa24fc6f3744ea05adc59019ae4e (diff) |
Switch tty fds over to a bufferevent.
Diffstat (limited to 'usr.bin/tmux/tty-keys.c')
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index 6e66788f377..36b850f15d7 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.12 2009/10/26 17:59:46 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.13 2009/11/04 21:47:42 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -299,18 +299,20 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse) struct tty_key *tk; struct timeval tv; char *buf; + u_char ch; size_t len, size; cc_t bspace; - buf = BUFFER_OUT(tty->in); - len = BUFFER_USED(tty->in); + 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') { - *key = buffer_read8(tty->in); + bufferevent_read(tty->event, &ch, 1); + *key = ch; /* * Check for backspace key using termios VERASE - the terminfo @@ -326,7 +328,7 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse) /* 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); + evbuffer_drain(tty->event->input, size + 1); *key = tk->key; goto found; } @@ -334,14 +336,14 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse) /* 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); + 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) { - buffer_remove(tty->in, size); + evbuffer_drain(tty->event->input, size); goto found; } @@ -363,8 +365,9 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse) /* Is there a normal key following? */ if (len != 0 && *buf != '\033') { - buffer_remove(tty->in, 1); - *key = buffer_read8(tty->in) | KEYC_ESCAPE; + evbuffer_drain(tty->event->input, 1); + bufferevent_read(tty->event, &ch, 1); + *key = ch | KEYC_ESCAPE; goto found; } @@ -372,7 +375,7 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse) if (len > 1) { tk = tty_keys_find(tty, buf + 1, len - 1, &size); if (tk != NULL) { - buffer_remove(tty->in, size + 2); + evbuffer_drain(tty->event->input, size + 2); *key = tk->key | KEYC_ESCAPE; goto found; } @@ -385,7 +388,7 @@ tty_keys_next(struct tty *tty, int *key, struct mouse_event *mouse) return (1); /* Give up and return the escape. */ - buffer_remove(tty->in, 1); + evbuffer_drain(tty->event->input, 1); *key = '\033'; found: |