Reuse the same extended slot when clearing non-RGB cells as well. From

Michael K Darling in GitHub issue 4865.
This commit is contained in:
nicm
2026-02-20 08:41:23 +00:00
parent 03f8690f9c
commit 0310404155

16
grid.c
View File

@@ -209,12 +209,14 @@ grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)
int had_extd = (gce->flags & GRID_FLAG_EXTENDED); int had_extd = (gce->flags & GRID_FLAG_EXTENDED);
memcpy(gce, &grid_cleared_entry, sizeof *gce); memcpy(gce, &grid_cleared_entry, sizeof *gce);
if (bg != 8) {
if (bg & COLOUR_FLAG_RGB) {
if (had_extd && old_offset < gl->extdsize) { if (had_extd && old_offset < gl->extdsize) {
gce->flags |= GRID_FLAG_EXTENDED; gce->flags |= GRID_FLAG_EXTENDED;
gce->offset = old_offset; gce->offset = old_offset;
} else gee = grid_extended_cell(gl, gce, &grid_cleared_cell);
if (bg != 8)
gee->bg = bg;
} else if (bg != 8) {
if (bg & COLOUR_FLAG_RGB) {
grid_get_extended_cell(gl, gce, gce->flags); grid_get_extended_cell(gl, gce, gce->flags);
gee = grid_extended_cell(gl, gce, &grid_cleared_cell); gee = grid_extended_cell(gl, gce, &grid_cleared_cell);
gee->bg = bg; gee->bg = bg;
@@ -493,7 +495,7 @@ static void
grid_expand_line(struct grid *gd, u_int py, u_int sx, u_int bg) grid_expand_line(struct grid *gd, u_int py, u_int sx, u_int bg)
{ {
struct grid_line *gl; struct grid_line *gl;
u_int xx; u_int xx, old_cellsize;
gl = &gd->linedata[py]; gl = &gd->linedata[py];
if (sx <= gl->cellsize) if (sx <= gl->cellsize)
@@ -506,8 +508,10 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx, u_int bg)
else if (gd->sx > sx) else if (gd->sx > sx)
sx = gd->sx; sx = gd->sx;
gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata); old_cellsize = gl->cellsize;
for (xx = gl->cellsize; xx < sx; xx++) gl->celldata = xrecallocarray(gl->celldata, old_cellsize, sx,
sizeof *gl->celldata);
for (xx = old_cellsize; xx < sx; xx++)
grid_clear_cell(gd, xx, py, bg); grid_clear_cell(gd, xx, py, bg);
gl->cellsize = sx; gl->cellsize = sx;
} }