summaryrefslogtreecommitdiffstats
path: root/input-keys.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-11-08 23:02:56 +0000
committerTiago Cunha <tcunha@gmx.com>2009-11-08 23:02:56 +0000
commit2df08827223872cd6b3ac1df527e55c2275a08cc (patch)
treefb8469066812b92a57e837a1c9b8e338a8968071 /input-keys.c
parent70b2f1981e76794f0de84427df733fc2e5eb5242 (diff)
Sync OpenBSD patchset 498:
Convert the window pane (pty master side) fd over to use a bufferevent. The evbuffer API is very similar to the existing tmux buffer API so this was remarkably painless. Not many possible ways to do it, I suppose.
Diffstat (limited to 'input-keys.c')
-rw-r--r--input-keys.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/input-keys.c b/input-keys.c
index 0f85f089..516a349f 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -1,4 +1,4 @@
-/* $Id: input-keys.c,v 1.39 2009-10-28 23:05:01 tcunha Exp $ */
+/* $Id: input-keys.c,v 1.40 2009-11-08 23:02:56 tcunha 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));
}
}