diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-11-04 22:43:11 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-11-04 22:43:11 +0000 |
commit | a02c7e804c8c6b9984e9d09c305199ccec92763f (patch) | |
tree | 396a9d8eab87fa47c0d62e12f3ec043309a99cf1 /input-keys.c | |
parent | 06ffed32169a6bf449f543803ee8b87c439ae94b (diff) | |
download | rtmux-a02c7e804c8c6b9984e9d09c305199ccec92763f.tar.gz rtmux-a02c7e804c8c6b9984e9d09c305199ccec92763f.tar.bz2 rtmux-a02c7e804c8c6b9984e9d09c305199ccec92763f.zip |
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.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/input-keys.c b/input-keys.c index 627b22cf..e8a163a0 100644 --- a/input-keys.c +++ b/input-keys.c @@ -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)); } } |