diff options
author | nicm <nicm> | 2017-10-05 08:12:24 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-10-05 08:12:24 +0000 |
commit | 6a292f09ba575690c8af3ff8b5a94acbbe6acacf (patch) | |
tree | 1aea010a5d0c6e339119366e4ebd727144deba93 /screen-write.c | |
parent | d563aa7c7b45e6fbd87fb1072579583dbaba86bc (diff) | |
download | rtmux-6a292f09ba575690c8af3ff8b5a94acbbe6acacf.tar.gz rtmux-6a292f09ba575690c8af3ff8b5a94acbbe6acacf.tar.bz2 rtmux-6a292f09ba575690c8af3ff8b5a94acbbe6acacf.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.
Diffstat (limited to 'screen-write.c')
-rw-r--r-- | screen-write.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/screen-write.c b/screen-write.c index 15f8d07f..f090d6fa 100644 --- a/screen-write.c +++ b/screen-write.c @@ -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; } |