From dae2868d1227b95fd076fb4a5efa6256c7245943 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 27 Jun 2019 15:17:41 +0000 Subject: Add support for underscore colours with Setulc capability, mostly from Kai Moschcau. --- grid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index d185f364..cddb5871 100644 --- a/grid.c +++ b/grid.c @@ -37,12 +37,12 @@ /* Default grid cell data. */ const struct grid_cell grid_default_cell = { - 0, 0, 8, 8, { { ' ' }, 0, 1, 1 } + 0, 0, 8, 8, 0, { { ' ' }, 0, 1, 1 } }; /* Cleared grid cell data. */ const struct grid_cell grid_cleared_cell = { - GRID_FLAG_CLEARED, 0, 8, 8, { { ' ' }, 0, 1, 1 } + GRID_FLAG_CLEARED, 0, 8, 8, 0, { { ' ' }, 0, 1, 1 } }; 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); } -- cgit From 3635b3cd6c3343b2ec3f7173facef8a284e7e613 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 6 Jul 2019 20:37:29 +0000 Subject: Correctly clear underscore colour in grid_get_cell1, also fix struct grid_cell to avoid padding. Fixes increased memory use reported by Suraj N Kurapati. --- grid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index cddb5871..cbff99e2 100644 --- a/grid.c +++ b/grid.c @@ -37,12 +37,12 @@ /* Default grid cell data. */ const struct grid_cell grid_default_cell = { - 0, 0, 8, 8, 0, { { ' ' }, 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, { { ' ' }, 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, ' ' } } @@ -475,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); } -- cgit From b89f2f28bb5f21bfe836870d907ec6992acb5f28 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 16 Jul 2019 10:30:56 +0000 Subject: Fix grid clear code to correctly clear with the default background colour rather than ending up with the used count higher than the total size, GitHub issue 1829. --- grid.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index cbff99e2..f33eef72 100644 --- a/grid.c +++ b/grid.c @@ -547,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; @@ -564,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); } } @@ -1216,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. -- cgit