From 58e498c9d3de650d2b802712bf24f8e572ccd1c9 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 21 Jan 2026 15:35:33 +0000 Subject: [PATCH 1/2] Use right cell for empty check. --- tty-draw.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tty-draw.c b/tty-draw.c index 3d77d4a1..a3712161 100644 --- a/tty-draw.c +++ b/tty-draw.c @@ -89,7 +89,7 @@ tty_draw_line_clear(struct tty *tty, u_int px, u_int py, u_int nx, /* Is this cell empty? */ static u_int -tty_draw_line_get_empty(struct grid_cell *gc, u_int nx) +tty_draw_line_get_empty(const struct grid_cell *gc, u_int nx) { u_int empty = 0; @@ -113,7 +113,8 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, struct colour_palette *palette) { struct grid *gd = s->grid; - struct grid_cell gc, *gcp, ngc, last; + struct grid_cell gc, ngc, last; + const struct grid_cell *gcp; struct grid_line *gl; u_int i, j, last_i, cx, ex, width; u_int cellsize, bg; @@ -233,7 +234,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, if (i >= ex) empty = 1; else - empty = tty_draw_line_get_empty(&gc, nx - i); + empty = tty_draw_line_get_empty(gcp, nx - i); /* Work out the next state. */ if (empty != 0) @@ -242,7 +243,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, next_state = TTY_DRAW_LINE_SAME; else if (gcp->flags & GRID_FLAG_PADDING) next_state = TTY_DRAW_LINE_PAD; - else if (grid_cells_look_equal(&gc, &last)) { + else if (grid_cells_look_equal(gcp, &last)) { if (gcp->data.size > (sizeof buf) - len) next_state = TTY_DRAW_LINE_FLUSH; else From 7730d38339f43d48246bcc7990a40bf9cb26b250 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 21 Jan 2026 15:58:11 +0000 Subject: [PATCH 2/2] Skip correct width when moving to next position. --- tty-draw.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tty-draw.c b/tty-draw.c index a3712161..ed831677 100644 --- a/tty-draw.c +++ b/tty-draw.c @@ -169,11 +169,15 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, break; } if (i == 0) - bg = gc.bg; - else if (screen_select_cell(s, &ngc, &gc)) - bg = ngc.bg; - else bg = defaults->bg; + else { + bg = gc.bg; + if (gc.flags & GRID_FLAG_SELECTED) { + memcpy(&ngc, &gc, sizeof ngc); + if (screen_select_cell(s, &ngc, &gc)) + bg = ngc.bg; + } + } tty_attributes(tty, &last, defaults, palette, s->hyperlinks); log_debug("%s: clearing %u padding cells", __func__, cx); tty_draw_line_clear(tty, atx, aty, cx, defaults, bg, 0); @@ -227,8 +231,11 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, gcp = tty_check_codeset(tty, &gc); /* And for selection. */ - if (screen_select_cell(s, &ngc, gcp)) - gcp = &ngc; + if (gcp->flags & GRID_FLAG_SELECTED) { + memcpy(&ngc, gcp, sizeof ngc); + if (screen_select_cell(s, &ngc, gcp)) + gcp = &ngc; + } /* Work out the the empty width. */ if (i >= ex) @@ -303,7 +310,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, if (empty != 0) i += empty; else - i++; + i += gcp->data.width; } tty->flags = (tty->flags & ~TTY_NOCURSOR)|flags;