diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-02-08 08:50:11 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-02-08 08:50:11 +0000 |
commit | e2f7795aa3258d08bd5a0e63dc430454a1dbbcb3 (patch) | |
tree | fec65f0eb78a9fa12c982133f8d7c552a0068fc6 | |
parent | 91d4f10f503b7c994fc68264081d3a105a3c3d6f (diff) |
Trying to avoid the occasional newline by saving the last cell on screen
is not actually helping us much and just adds complexity, so don't
bother.
-rw-r--r-- | usr.bin/tmux/screen-write.c | 69 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 41 |
3 files changed, 22 insertions, 93 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 5d20b0c48cf..8d11b52416b 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.105 2017/02/06 19:26:49 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.106 2017/02/08 08:50:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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++; diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index f102f22f0d3..1fee82eb103 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.718 2017/02/08 08:25:12 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.719 2017/02/08 08:50:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1105,9 +1105,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. */ diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index cf721449ca5..8c78b1b23d9 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.232 2017/02/07 18:27:46 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.233 2017/02/08 08:50:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -998,17 +998,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 +1153,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 +1161,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); } |