summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-11-05 08:45:09 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-11-05 08:45:09 +0000
commitc821c4e927a4ba76c998a967a8359138017a6845 (patch)
tree0e42eefc98a91d89b32e9dff637a89fe006dbcd0 /usr.bin/tmux/tty.c
parent5210a0b5123c35018c558ab47cd81a260cb427a1 (diff)
Switch tty key input over to happen on a read event. This is a bit more
complicated because of escape input, but in that case instead of processing a key immediately, schedule a timer and reprocess the bufer when it expires. This currently assumes that keys will be atomic (ie that if eg F1 is pressed the entire sequence is present in the buffer). This is usually but not always true, a change in the tree format so it can differentiate potential (partial) key sequences will happens soon and will allow this to be fixed.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index d2296f17d4c..4e5d13b2d9d 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.66 2009/11/04 21:47:42 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.67 2009/11/05 08:45:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -28,6 +28,7 @@
#include "tmux.h"
+void tty_read_callback(struct bufferevent *, void *);
void tty_error_callback(struct bufferevent *, short, void *);
void tty_fill_acs(struct tty *);
@@ -113,7 +114,7 @@ tty_open(struct tty *tty, const char *overrides, char **cause)
tty->flags &= ~(TTY_NOCURSOR|TTY_FREEZE|TTY_ESCAPE);
tty->event = bufferevent_new(
- tty->fd, NULL, NULL, tty_error_callback, tty);
+ tty->fd, tty_read_callback, NULL, tty_error_callback, tty);
tty_start_tty(tty);
@@ -125,6 +126,15 @@ tty_open(struct tty *tty, const char *overrides, char **cause)
}
void
+tty_read_callback(unused struct bufferevent *bufev, void *data)
+{
+ struct tty *tty = data;
+
+ while (tty_keys_next(tty))
+ ;
+}
+
+void
tty_error_callback(
unused struct bufferevent *bufev, unused short what, unused void *data)
{
@@ -259,6 +269,7 @@ tty_close(struct tty *tty)
tty->log_fd = -1;
}
+ evtimer_del(&tty->key_timer);
tty_stop_tty(tty);
if (tty->flags & TTY_OPENED) {