diff options
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -37,12 +37,12 @@ /* Default grid cell data. */ const struct grid_cell grid_default_cell = { - 0, 0, 8, 8, { { ' ' }, 0, 1, 1 } + { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0 }; /* Cleared grid cell data. */ const struct grid_cell grid_cleared_cell = { - GRID_FLAG_CLEARED, 0, 8, 8, { { ' ' }, 0, 1, 1 } + { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0 }; static const struct grid_cell_entry grid_cleared_entry = { GRID_FLAG_CLEARED, { .data = { 0, 8, 8, ' ' } } @@ -82,6 +82,8 @@ grid_need_extended_cell(const struct grid_cell_entry *gce, return (1); if ((gc->fg & COLOUR_FLAG_RGB) || (gc->bg & COLOUR_FLAG_RGB)) return (1); + if (gc->us != 0) /* only supports 256 or RGB */ + return (1); return (0); } @@ -473,6 +475,7 @@ grid_get_cell1(struct grid_line *gl, u_int px, struct grid_cell *gc) gc->bg = gce->data.bg; if (gce->flags & GRID_FLAG_BG256) gc->bg |= COLOUR_FLAG_256; + gc->us = 0; utf8_set(&gc->data, gce->data.data); } @@ -544,7 +547,7 @@ void grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg) { struct grid_line *gl; - u_int xx, yy; + u_int xx, yy, ox, sx; if (nx == 0 || ny == 0) return; @@ -561,16 +564,20 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg) for (yy = py; yy < py + ny; yy++) { gl = &gd->linedata[yy]; - if (px + nx >= gd->sx && px < gl->cellused) - gl->cellused = px; - if (px > gl->cellsize && COLOUR_DEFAULT(bg)) - continue; - if (px + nx >= gl->cellsize && COLOUR_DEFAULT(bg)) { - gl->cellsize = px; - continue; + + sx = gd->sx; + if (sx > gl->cellsize) + sx = gl->cellsize; + ox = nx; + if (COLOUR_DEFAULT(bg)) { + if (px > sx) + continue; + if (px + nx > sx) + ox = sx - px; } - grid_expand_line(gd, yy, px + nx, 8); /* default bg first */ - for (xx = px; xx < px + nx; xx++) + + grid_expand_line(gd, yy, px + ox, 8); /* default bg first */ + for (xx = px; xx < px + ox; xx++) grid_clear_cell(gd, xx, yy, bg); } } @@ -1213,6 +1220,10 @@ grid_reflow(struct grid *gd, u_int sx) struct grid_cell gc; u_int yy, width, i, at, first; + /* Do not reflow to the same size. */ + if (sx == gd->sx) + return; + /* * Create a destination grid. This is just used as a container for the * line data and may not be fully valid. |