mirror of
https://github.com/tmux/tmux.git
synced 2025-04-16 16:38:49 +00:00
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.
This commit is contained in:
parent
d563aa7c7b
commit
6a292f09ba
@ -1243,6 +1243,7 @@ screen_write_collect_end(struct screen_write_ctx *ctx)
|
|||||||
struct screen *s = ctx->s;
|
struct screen *s = ctx->s;
|
||||||
struct screen_write_collect_item *ci = ctx->item;
|
struct screen_write_collect_item *ci = ctx->item;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
|
u_int xx;
|
||||||
|
|
||||||
if (ci->used == 0)
|
if (ci->used == 0)
|
||||||
return;
|
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,
|
log_debug("%s: %u %s (at %u,%u)", __func__, ci->used, ci->data, s->cx,
|
||||||
s->cy);
|
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);
|
memcpy(&gc, &ci->gc, sizeof gc);
|
||||||
grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used);
|
grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used);
|
||||||
s->cx += 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. */
|
/* 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.
|
* already ensured there is enough room.
|
||||||
*/
|
*/
|
||||||
for (xx = s->cx + 1; xx < s->cx + width; xx++) {
|
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);
|
grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell);
|
||||||
skip = 0;
|
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);
|
grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
|
||||||
if (~tmp_gc.flags & GRID_FLAG_PADDING)
|
if (~tmp_gc.flags & GRID_FLAG_PADDING)
|
||||||
break;
|
break;
|
||||||
|
log_debug("%s: padding at %u,%u", __func__, xx, s->cy);
|
||||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Overwrite the character at the start of this padding. */
|
/* 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);
|
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||||
done = 1;
|
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);
|
grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
|
||||||
if (~tmp_gc.flags & GRID_FLAG_PADDING)
|
if (~tmp_gc.flags & GRID_FLAG_PADDING)
|
||||||
break;
|
break;
|
||||||
|
log_debug("%s: overwrite at %u,%u", __func__, xx, s->cy);
|
||||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user