Commit: fec440a921cd85c312ff0d1dfded51e45c4e6320
Parent: 654067bc97ec3674218f917dc4b3eb5344e66fcc
Author: Randy Palamar
Date: Thu, 7 Nov 2024 06:31:55 -0700
test: fix broken csi_embedded_control and test for proper line splitting
Scrollback would be broken if were to allow a line to split in the
middle of a CSI because part of the CSI would look like normal
text at the start of a line.
Diffstat:
M | test.c | | | 21 | +++++++++++++++------ |
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/test.c b/test.c
@@ -155,18 +155,27 @@ static TEST_FN(csi_embedded_control)
dump_csi(&term->csi);
#endif
+ CellStyle final_style = {
+ .bg = (Colour){.r = 75, .g = 63, .b = 42, .a = 0xFF},
+ .fg = g_colours.data[g_colours.fgidx],
+ .attr = ATTR_NULL,
+ };
+
Cell c1 = {.cp = '1',
.bg = SHADER_PACK_BG(g_colours.data[g_colours.bgidx].rgba, ATTR_NULL),
.fg = SHADER_PACK_FG(g_colours.data[g_colours.fgidx].rgba, ATTR_NULL),
};
- u32 attr = (ATTR_INVISIBLE|ATTR_STRUCK);
Cell c2 = {.cp = '2',
- .bg = SHADER_PACK_BG(((Colour){.r = 75, .g = 63, .b = 42, .a = 0xFF}.rgba), attr),
- .fg = SHADER_PACK_FG(g_colours.data[3].rgba, attr),
+ .bg = SHADER_PACK_BG(final_style.bg.rgba, final_style.attr),
+ .fg = SHADER_PACK_FG(final_style.fg.rgba, final_style.attr),
};
- result.status = term->cursor.pos.y == 1 && term->cursor.pos.x == 3;
- result.status |= check_cells_equal(&c1, &term->views[term->view_idx].fb.rows[0][0]);
- result.status |= check_cells_equal(&c2, &term->views[term->view_idx].fb.rows[1][1]);
+
+ result.status = term->cursor.pos.y == 1 && term->cursor.pos.x == 2;
+ result.status &= check_cells_equal(&c1, &term->views[term->view_idx].fb.rows[0][0]);
+ result.status &= check_cells_equal(&c2, &term->views[term->view_idx].fb.rows[1][1]);
+ /* NOTE: we also want to ensure that we cannot split a line in the middle of a CSI */
+ LineBuf *lb = &term->views[0].lines;
+ result.status &= lb->filled == 0 && *lb->buf[lb->widx].start != '2';
return result;
}