From ce8005545d5bc94775f616d0caacd55e691e400f Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 14 Feb 2020 22:39:26 +0100 Subject: term: convert cell 'linefeed' attribute to a row 'linebreak' property To do text reflow, we only need to know if a line has been explicitly linebreaked or not. If not, that means it wrapped, and that we should *not* insert a linebreak when reflowing text. When reflowing text, when reaching the end of a row in the old grid, only insert a linebreak in the new grid if the old row had been explicitly linebreaked. Furthermore, when reflowing text and wrapping a row in the new grid, mark the previous row as linebreaked if either the last cell was (the last column in the last row) empty, or the current cell (the first column in the new row) is empty. If both are non-empty, then we assume a linewrap. --- terminal.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index cb52a416..b2fb9233 100644 --- a/terminal.c +++ b/terminal.c @@ -1253,6 +1253,7 @@ static inline void erase_line(struct terminal *term, struct row *row) { erase_cell_range(term, row, 0, term->cols - 1); + row->linebreak = false; } void @@ -1498,17 +1499,13 @@ term_scroll_reverse(struct terminal *term, int rows) void term_formfeed(struct terminal *term) { - int col = term->cursor.point.col; - if (!term->cursor.lcf) - col--; - if (col >= 0) - term->grid->cur_row->cells[col].attrs.linefeed = 1; term_cursor_left(term, term->cursor.point.col); } void term_linefeed(struct terminal *term) { + term->grid->cur_row->linebreak = true; if (term->cursor.point.row == term->scroll_region.end - 1) term_scroll(term, 1); else -- cgit v1.3 From d11a71e0b221cc24404da37ea928708a03d65c47 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 14 Feb 2020 22:43:23 +0100 Subject: term: reset: use grid_row_alloc() with initialize=true This will both zero out the cells, *and* re-initialize the row properties correctly. --- terminal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index b2fb9233..bec0ce7b 100644 --- a/terminal.c +++ b/terminal.c @@ -1090,8 +1090,8 @@ term_reset(struct terminal *term, bool hard) term->normal.offset = term->normal.view = 0; term->alt.offset = term->alt.view = 0; for (size_t i = 0; i < term->rows; i++) { - memset(grid_row_and_alloc(&term->normal, i)->cells, 0, term->cols * sizeof(struct cell)); - memset(grid_row_and_alloc(&term->alt, i)->cells, 0, term->cols * sizeof(struct cell)); + term->normal.rows[i] = grid_row_alloc(term->cols, true); + term->alt.rows[i] = grid_row_alloc(term->cols, true); } for (size_t i = term->rows; i < term->normal.num_rows; i++) { grid_row_free(term->normal.rows[i]); -- cgit v1.3