summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/input-keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/input-keys.c')
-rw-r--r--usr.bin/tmux/input-keys.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c
index 285eac3d75c..61e15b298a9 100644
--- a/usr.bin/tmux/input-keys.c
+++ b/usr.bin/tmux/input-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input-keys.c,v 1.13 2009/10/26 17:59:46 nicm Exp $ */
+/* $OpenBSD: input-keys.c,v 1.14 2009/11/04 22:43:11 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -163,6 +163,7 @@ input_key(struct window_pane *wp, int key)
u_int i;
size_t dlen;
char *out;
+ u_char ch;
log_debug2("writing key 0x%x", key);
@@ -172,8 +173,10 @@ input_key(struct window_pane *wp, int key)
*/
if (key != KEYC_NONE && (key & ~KEYC_ESCAPE) < 0x100) {
if (key & KEYC_ESCAPE)
- buffer_write8(wp->out, '\033');
- buffer_write8(wp->out, (uint8_t) (key & ~KEYC_ESCAPE));
+ ch = '\033';
+ else
+ ch = key & ~KEYC_ESCAPE;
+ bufferevent_write(wp->event, &ch, 1);
return;
}
@@ -183,7 +186,7 @@ input_key(struct window_pane *wp, int key)
*/
if (options_get_number(&wp->window->options, "xterm-keys")) {
if ((out = xterm_keys_lookup(key)) != NULL) {
- buffer_write(wp->out, out, strlen(out));
+ bufferevent_write(wp->event, out, strlen(out));
xfree(out);
return;
}
@@ -214,18 +217,19 @@ input_key(struct window_pane *wp, int key)
/* Prefix a \033 for escape. */
if (key & KEYC_ESCAPE)
- buffer_write8(wp->out, '\033');
- buffer_write(wp->out, ike->data, dlen);
+ bufferevent_write(wp->event, "\033", 1);
+ bufferevent_write(wp->event, ike->data, dlen);
}
/* Translate mouse and output. */
void
input_mouse(struct window_pane *wp, struct mouse_event *m)
{
+ char out[8];
+
if (wp->screen->mode & MODE_MOUSE) {
- buffer_write(wp->out, "\033[M", 3);
- buffer_write8(wp->out, m->b + 32);
- buffer_write8(wp->out, m->x + 33);
- buffer_write8(wp->out, m->y + 33);
+ xsnprintf(out, sizeof out,
+ "\033[M%c%c%c", m->b + 32, m->x + 33, m->y + 33);
+ bufferevent_write(wp->event, out, strlen(out));
}
}