From a02c7e804c8c6b9984e9d09c305199ccec92763f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 4 Nov 2009 22:43:11 +0000 Subject: 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. --- input.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'input.c') diff --git a/input.c b/input.c index f0a566e5..b846e060 100644 --- a/input.c +++ b/input.c @@ -256,12 +256,12 @@ input_parse(struct window_pane *wp) struct input_ctx *ictx = &wp->ictx; u_char ch; - if (BUFFER_USED(wp->in) == ictx->was) + if (EVBUFFER_LENGTH(wp->event->input) == ictx->was) return; wp->window->flags |= WINDOW_ACTIVITY; - ictx->buf = BUFFER_OUT(wp->in); - ictx->len = BUFFER_USED(wp->in); + ictx->buf = EVBUFFER_DATA(wp->event->input); + ictx->len = EVBUFFER_LENGTH(wp->event->input); ictx->off = 0; ictx->wp = wp; @@ -278,8 +278,8 @@ input_parse(struct window_pane *wp) screen_write_stop(&ictx->ctx); - buffer_remove(wp->in, ictx->len); - ictx->was = BUFFER_USED(wp->in); + evbuffer_drain(wp->event->input, ictx->len); + ictx->was = EVBUFFER_LENGTH(wp->event->input); } void @@ -932,7 +932,8 @@ input_handle_sequence_cbt(struct input_ctx *ictx) void input_handle_sequence_da(struct input_ctx *ictx) { - uint16_t n; + struct window_pane *wp = ictx->wp; + uint16_t n; if (ictx->private != '\0') return; @@ -944,7 +945,7 @@ input_handle_sequence_da(struct input_ctx *ictx) if (n != 0) return; - buffer_write(ictx->wp->out, "\033[?1;2c", (sizeof "\033[?1;2c") - 1); + bufferevent_write(wp->event, "\033[?1;2c", (sizeof "\033[?1;2c") - 1); } void @@ -1314,9 +1315,10 @@ input_handle_sequence_rm(struct input_ctx *ictx) void input_handle_sequence_dsr(struct input_ctx *ictx) { - struct screen *s = ictx->ctx.s; - uint16_t n; - char reply[32]; + struct window_pane *wp = ictx->wp; + struct screen *s = ictx->ctx.s; + uint16_t n; + char reply[32]; if (ARRAY_LENGTH(&ictx->args) > 1) return; @@ -1329,7 +1331,7 @@ input_handle_sequence_dsr(struct input_ctx *ictx) xsnprintf(reply, sizeof reply, "\033[%u;%uR", s->cy + 1, s->cx + 1); log_debug("cursor request, reply: %s", reply); - buffer_write(ictx->wp->out, reply, strlen(reply)); + bufferevent_write(wp->event, reply, strlen(reply)); break; } } -- cgit v1.2.3