diff options
-rw-r--r-- | grid.c | 11 | ||||
-rw-r--r-- | screen-write.c | 67 | ||||
-rw-r--r-- | tmux.h | 22 | ||||
-rw-r--r-- | tty.c | 55 | ||||
-rw-r--r-- | window.c | 27 |
5 files changed, 41 insertions, 141 deletions
@@ -292,11 +292,12 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx, u_int bg) if (sx <= gl->cellsize) return; - if (sx < gd->sx) { - sx *= 2; - if (sx > gd->sx) - sx = gd->sx; - } + if (sx < gd->sx / 4) + sx = gd->sx / 4; + else if (sx < gd->sx / 2) + sx = gd->sx / 2; + else + sx = gd->sx; gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata); for (xx = gl->cellsize; xx < sx; xx++) diff --git a/screen-write.c b/screen-write.c index fe8419e3..eff0195b 100644 --- a/screen-write.c +++ b/screen-write.c @@ -25,8 +25,6 @@ static void screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *); -static void screen_write_save_last(struct screen_write_ctx *, - struct tty_ctx *); static void screen_write_flush(struct screen_write_ctx *); static int screen_write_overwrite(struct screen_write_ctx *, @@ -437,24 +435,6 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx) ttyctx->orupper = s->rupper; } -/* Save last cell on screen. */ -static void -screen_write_save_last(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx) -{ - struct screen *s = ctx->s; - struct grid *gd = s->grid; - struct grid_cell gc; - u_int xx; - - memcpy(&gc, &grid_default_cell, sizeof gc); - for (xx = 1; xx <= screen_size_x(s); xx++) { - grid_view_get_cell(gd, screen_size_x(s) - xx, s->cy, &gc); - if (~gc.flags & GRID_FLAG_PADDING) - break; - } - memcpy(&ttyctx->last_cell, &gc, sizeof ttyctx->last_cell); -} - /* Set a mode. */ void screen_write_mode_set(struct screen_write_ctx *ctx, int mode) @@ -1040,7 +1020,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) struct grid_line *gl; struct grid_cell tmp_gc, now_gc; struct grid_cell_entry *gce; - int insert, skip, selected, wrapped = 0; + int insert, skip, selected; ctx->cells++; @@ -1071,9 +1051,6 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) return; } - /* Initialise the redraw context. */ - screen_write_initctx(ctx, &ttyctx); - /* If in insert mode, make space for the cells. */ if (s->mode & MODE_INSERT) { if (s->cx <= sx - width) { @@ -1088,18 +1065,17 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) /* Check this will fit on the current line and wrap if not. */ if ((s->mode & MODE_WRAP) && s->cx > sx - width) { - screen_write_flush(ctx); - screen_write_save_last(ctx, &ttyctx); screen_write_linefeed(ctx, 1); s->cx = 0; /* carriage return */ - skip = 0; - wrapped = 1; } /* Sanity check cursor position. */ if (s->cx > sx - width || s->cy > sy - 1) return; + /* Initialise the redraw context. */ + screen_write_initctx(ctx, &ttyctx); + /* Handle overwriting of UTF-8 characters. */ gl = &s->grid->linedata[s->grid->hsize + s->cy]; if (gl->flags & GRID_LINE_EXTENDED) { @@ -1179,27 +1155,20 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) tty_write(tty_cmd_cell, &ttyctx); ctx->written++; } else if (!skip) { - if (wrapped) { - ttyctx.cell = gc; - tty_write(tty_cmd_cell, &ttyctx); - ctx->written++; - } else { - /* - * If wp is NULL, we are not updating the terminal and - * don't care about actually writing the cells - * (tty_write will just return). So don't even bother - * allocating the dirty array. - */ - if (ctx->wp != NULL && s->dirty == NULL) { - log_debug("%s: allocating %u bits", __func__, - s->dirtysize); - s->dirty = bit_alloc(s->dirtysize); - } - if (s->dirty != NULL) { - bit_set(s->dirty, screen_dirty_bit(s, - ttyctx.ocx, ttyctx.ocy)); - ctx->dirty++; - } + /* + * If wp is NULL, we are not updating the terminal and don't + * care about actually writing the cells (tty_write will just + * return). So don't even bother allocating the dirty array. + */ + if (ctx->wp != NULL && s->dirty == NULL) { + log_debug("%s: allocating %u bits", __func__, + s->dirtysize); + s->dirty = bit_alloc(s->dirtysize); + } + if (s->dirty != NULL) { + bit_set(s->dirty, screen_dirty_bit(s, + ttyctx.ocx, ttyctx.ocy)); + ctx->dirty++; } } else ctx->skipped++; @@ -66,18 +66,8 @@ struct tmuxproc; /* Automatic name refresh interval, in microseconds. Must be < 1 second. */ #define NAME_INTERVAL 500000 -/* - * Event watermarks. We start with FAST then if we hit full size for HITS reads - * in succession switch to SLOW, and return when we hit EMPTY the same number - * of times. - */ -#define READ_FAST_SIZE 4096 -#define READ_SLOW_SIZE 128 - -#define READ_FULL_SIZE (4096 - 16) -#define READ_EMPTY_SIZE 16 - -#define READ_CHANGE_HITS 3 +/* Maximum size of data to hold from a pane. */ +#define READ_SIZE 4096 /* Attribute to make GCC check printf-like arguments. */ #define printflike(a, b) __attribute__ ((format (printf, a, b))) @@ -242,7 +232,7 @@ enum tty_code_code { TTYC_DL1, /* delete_line, dl */ TTYC_E3, TTYC_ECH, /* erase_chars, ec */ - TTYC_ED, /* csr_eos, cd */ + TTYC_ED, /* clr_eos, cd */ TTYC_EL, /* clr_eol, ce */ TTYC_EL1, /* clr_bol, cb */ TTYC_ENACS, /* ena_acs, eA */ @@ -764,9 +754,6 @@ struct window_pane { struct event resize_timer; - u_int wmark_size; - u_int wmark_hits; - struct input_ctx *ictx; struct grid_cell colgc; @@ -1120,9 +1107,6 @@ struct tty_ctx { /* The background colour used for clearing (erasing). */ u_int bg; - - /* Saved last cell on line. */ - struct grid_cell last_cell; }; /* Saved message entry. */ @@ -439,32 +439,36 @@ tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a, void tty_puts(struct tty *tty, const char *s) { + size_t size = EVBUFFER_LENGTH(tty->event->output); + if (*s == '\0') return; + bufferevent_write(tty->event, s, strlen(s)); + log_debug("%s (%zu): %s", tty->path, size, s); if (tty_log_fd != -1) write(tty_log_fd, s, strlen(s)); - log_debug("%s: %s", tty->path, s); } void tty_putc(struct tty *tty, u_char ch) { + size_t size = EVBUFFER_LENGTH(tty->event->output); const char *acs; if (tty->cell.attr & GRID_ATTR_CHARSET) { acs = tty_acs_get(tty, ch); if (acs != NULL) { bufferevent_write(tty->event, acs, strlen(acs)); - log_debug("%s: %s", tty->path, acs); + log_debug("%s (%zu): %s", tty->path, size, acs); } else { bufferevent_write(tty->event, &ch, 1); - log_debug("%s: %c", tty->path, ch); + log_debug("%s (%zu): %c", tty->path, size, ch); } } else { bufferevent_write(tty->event, &ch, 1); - log_debug("%s: %c", tty->path, ch); + log_debug("%s (%zu): %c", tty->path, size, ch); } if (ch >= 0x20 && ch != 0x7f) { @@ -491,11 +495,13 @@ tty_putc(struct tty *tty, u_char ch) void tty_putn(struct tty *tty, const void *buf, size_t len, u_int width) { + size_t size = EVBUFFER_LENGTH(tty->event->output); + bufferevent_write(tty->event, buf, len); + log_debug("%s (%zu): %.*s", tty->path, size, (int)len, (char *)buf); if (tty_log_fd != -1) write(tty_log_fd, buf, len); - log_debug("%s: %.*s", tty->path, (int)len, (char *)buf); tty->cx += width; } @@ -998,17 +1004,6 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) return; } - /* - * If this line wrapped naturally (ctx->num is nonzero) and we are not - * using margins, don't do anything - the cursor can just be moved - * to the last cell and wrap naturally. - */ - if ((!tty_use_margin(tty) || - tty_pane_full_width(tty, ctx)) && - ctx->num != 0 && - !(tty->term->flags & TERM_EARLYWRAP)) - return; - tty_attributes(tty, &grid_default_cell, wp); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); @@ -1164,8 +1159,6 @@ void tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; - struct screen *s = wp->screen; - u_int cx, width; if (ctx->xoff + ctx->ocx > tty->sx - 1 && ctx->ocy == ctx->orlower) { if (tty_pane_full_width(tty, ctx)) @@ -1174,31 +1167,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) tty_margin_off(tty); } - /* Is the cursor in the very last position? */ - width = ctx->cell->data.width; - if (ctx->ocx > wp->sx - width) { - if (!tty_pane_full_width(tty, ctx)) { - /* - * The pane doesn't fill the entire line, the linefeed - * will already have happened, so just move the cursor. - */ - if (ctx->ocy != wp->yoff + wp->screen->rlower) - tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1); - else - tty_cursor_pane(tty, ctx, 0, ctx->ocy); - } else if (tty->cy != ctx->yoff + ctx->ocy || - tty->cx < tty->sx) { - /* - * The cursor isn't in the last position already, so - * move as far right as possible and redraw the last - * cell to move into the last position. - */ - cx = screen_size_x(s) - ctx->last_cell.data.width; - tty_cursor_pane(tty, ctx, cx, ctx->ocy); - tty_cell(tty, &ctx->last_cell, wp); - } - } else - tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); + tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cell(tty, ctx->cell, wp); } @@ -66,8 +66,6 @@ static struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int); static void window_pane_destroy(struct window_pane *); -static void window_pane_set_watermark(struct window_pane *, size_t); - static void window_pane_read_callback(struct bufferevent *, void *); static void window_pane_error_callback(struct bufferevent *, short, void *); @@ -842,14 +840,6 @@ window_pane_destroy(struct window_pane *wp) free(wp); } -static void -window_pane_set_watermark(struct window_pane *wp, size_t size) -{ - wp->wmark_hits = 0; - wp->wmark_size = size; - bufferevent_setwatermark(wp->event, EV_READ, 0, size); -} - int window_pane_spawn(struct window_pane *wp, int argc, char **argv, const char *path, const char *shell, const char *cwd, struct environ *env, @@ -969,7 +959,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, wp->event = bufferevent_new(wp->fd, window_pane_read_callback, NULL, window_pane_error_callback, wp); - window_pane_set_watermark(wp, READ_FAST_SIZE); + bufferevent_setwatermark(wp->event, EV_READ, 0, READ_SIZE); bufferevent_enable(wp->event, EV_READ|EV_WRITE); free(cmd); @@ -985,26 +975,13 @@ window_pane_read_callback(__unused struct bufferevent *bufev, void *data) char *new_data; size_t new_size; - if (wp->wmark_size == READ_FAST_SIZE) { - if (size > READ_FULL_SIZE) - wp->wmark_hits++; - if (wp->wmark_hits == READ_CHANGE_HITS) - window_pane_set_watermark(wp, READ_SLOW_SIZE); - } else if (wp->wmark_size == READ_SLOW_SIZE) { - if (size < READ_EMPTY_SIZE) - wp->wmark_hits++; - if (wp->wmark_hits == READ_CHANGE_HITS) - window_pane_set_watermark(wp, READ_FAST_SIZE); - } - log_debug("%%%u has %zu bytes (of %u, %u hits)", wp->id, size, - wp->wmark_size, wp->wmark_hits); - new_size = size - wp->pipe_off; if (wp->pipe_fd != -1 && new_size > 0) { new_data = EVBUFFER_DATA(evb) + wp->pipe_off; bufferevent_write(wp->pipe_event, new_data, new_size); } + log_debug("%%%u has %zu bytes", wp->id, size); input_parse(wp); wp->pipe_off = EVBUFFER_LENGTH(evb); |