diff options
author | 2017-10-05 08:12:24 +0000 | |
---|---|---|
committer | 2017-10-05 08:12:24 +0000 | |
commit | 856ed6d3ac0b71a1278ec4f6c6bf2065ede3c037 (patch) | |
tree | 3bd707047a92b9625a1ce33918a54da5ee36cf28 | |
parent | restore a block of code erroneously removed in r1.162 that causes a (diff) | |
download | wireguard-openbsd-856ed6d3ac0b71a1278ec4f6c6bf2065ede3c037.tar.xz wireguard-openbsd-856ed6d3ac0b71a1278ec4f6c6bf2065ede3c037.zip |
When writing batches of characters to the screen, we need to clear
padding or later UTF-8 characters could be displayed incorrectly. GitHub
issue 1090.
-rw-r--r-- | usr.bin/tmux/screen-write.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 4adcdcb317d..93489c9b9e3 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.130 2017/08/09 11:43:45 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.131 2017/10/05 08:12:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1243,6 +1243,7 @@ screen_write_collect_end(struct screen_write_ctx *ctx) struct screen *s = ctx->s; struct screen_write_collect_item *ci = ctx->item; struct grid_cell gc; + u_int xx; if (ci->used == 0) return; @@ -1255,9 +1256,27 @@ screen_write_collect_end(struct screen_write_ctx *ctx) log_debug("%s: %u %s (at %u,%u)", __func__, ci->used, ci->data, s->cx, s->cy); + if (s->cx != 0) { + for (xx = s->cx; xx > 0; xx--) { + grid_view_get_cell(s->grid, xx, s->cy, &gc); + if (~gc.flags & GRID_FLAG_PADDING) + break; + grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell); + } + if (gc.data.width > 1) + grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell); + } + memcpy(&gc, &ci->gc, sizeof gc); grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used); s->cx += ci->used; + + for (xx = s->cx; xx < screen_size_x(s); xx++) { + grid_view_get_cell(s->grid, xx, s->cy, &gc); + if (~gc.flags & GRID_FLAG_PADDING) + break; + grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell); + } } /* Write cell data, collecting if necessary. */ @@ -1388,6 +1407,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) * already ensured there is enough room. */ for (xx = s->cx + 1; xx < s->cx + width; xx++) { + log_debug("%s: new padding at %u,%u", __func__, xx, s->cy); grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell); skip = 0; } @@ -1537,10 +1557,12 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc, grid_view_get_cell(gd, xx, s->cy, &tmp_gc); if (~tmp_gc.flags & GRID_FLAG_PADDING) break; + log_debug("%s: padding at %u,%u", __func__, xx, s->cy); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); } /* Overwrite the character at the start of this padding. */ + log_debug("%s: character at %u,%u", __func__, xx, s->cy); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); done = 1; } @@ -1557,6 +1579,7 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc, grid_view_get_cell(gd, xx, s->cy, &tmp_gc); if (~tmp_gc.flags & GRID_FLAG_PADDING) break; + log_debug("%s: overwrite at %u,%u", __func__, xx, s->cy); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); done = 1; } |