aboutsummaryrefslogtreecommitdiff
path: root/grid.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-03-05 06:38:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-03-05 17:55:01 +0000
commit605694bc938ace9a7501d6730c1865ea531870df (patch)
tree0fbd3e7d2f905229df1dce47e0efecdb06b76b3e /grid.c
parentgrid: change default value of linebreak to true (diff)
grid: set linebreak=false when printing to a line, not when allocating it
This ensures empty lines are treated correctly, and is also more in line with how lines are handled at runtime, when filling the scrollback. For now, set linebreak=false as soon as something is printed on a line. It will remain like that *until* we reach the end of an old row with linebreak=true, at which point we set linebreak=true on the current new line.
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/grid.c b/grid.c
index 4b9a7fb6..cb6e1a91 100644
--- a/grid.c
+++ b/grid.c
@@ -501,7 +501,6 @@ grid_resize_without_reflow(
sizeof(struct cell) * min(old_cols, new_cols));
new_row->dirty = old_row->dirty;
- new_row->linebreak = false;
new_row->shell_integration.prompt_marker = old_row->shell_integration.prompt_marker;
new_row->shell_integration.cmd_start = min(old_row->shell_integration.cmd_start, new_cols - 1);
new_row->shell_integration.cmd_end = min(old_row->shell_integration.cmd_end, new_cols - 1);
@@ -709,10 +708,6 @@ _line_wrap(struct grid *old_grid, struct row **new_grid, struct row *row,
/* Scrollback not yet full, allocate a completely new row */
new_row = grid_row_alloc(col_count, false);
new_grid[*row_idx] = new_row;
-
- /* *clear* linebreak, since we only want to set it when we
- reach the end of an old row, with linebreak=true */
- new_row->linebreak = false;
} else {
/* Scrollback is full, need to reuse a row */
grid_row_reset_extra(new_row);
@@ -720,10 +715,6 @@ _line_wrap(struct grid *old_grid, struct row **new_grid, struct row *row,
new_row->shell_integration.cmd_start = -1;
new_row->shell_integration.cmd_end = -1;
- /* *clear* linebreak, since we only want to set it when we
- reach the end of an old row, with linebreak=true */
- new_row->linebreak = false;
-
tll_foreach(old_grid->sixel_images, it) {
if (it->item.pos.row == *row_idx) {
sixel_destroy(&it->item);
@@ -1112,6 +1103,17 @@ grid_resize_and_reflow(
}
new_row->cells[new_col_idx++] = *old;
+
+ /*
+ * TODO: simulate LCF instead?
+ *
+ * Rows have linebreak=true by default. This is needed
+ * for a number of reasons. However, we want non-empty
+ * rows to have linebreak=false, *until* we reach the
+ * end of an old row with linebreak=true, at which
+ * point we set linebreak=true on the new row.
+ */
+ new_row->linebreak = false;
old++;
c++;
}