From d9e1aefb9173857f0632227de5ac368a505c69bf Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 14 May 2021 14:41:02 +0200 Subject: term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definition Instead of using CELL_SPACER for *all* cells that previously used CELL_MULT_COL_SPACER, include the remaining number of spacers following, and including, itself. This is encoded by adding to the CELL_SPACER value. So, a double width character will now store the character itself in the first cell (just like before), and CELL_SPACER+1 in the second cell. A three-cell character would store the character itself, then CELL_SPACER+2, and finally CELL_SPACER+1. In other words, the last spacer is always CELL_SPACER+1. CELL_SPACER+0 is used when padding at the right margin. I.e. when writing e.g. a double width character in the last column, we insert a CELL_SPACER+0 pad character, and then write the double width character in the first column on the next row. --- terminal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index a9712789..b4abbb0f 100644 --- a/terminal.c +++ b/terminal.c @@ -2764,12 +2764,12 @@ print_insert(struct terminal *term, int width) } static void -print_spacer(struct terminal *term, int col) +print_spacer(struct terminal *term, int col, int remaining) { struct row *row = term->grid->cur_row; struct cell *cell = &row->cells[col]; - cell->wc = CELL_MULT_COL_SPACER; + cell->wc = CELL_SPACER + remaining; cell->attrs = term->vt.attrs; cell->attrs.clean = 0; } @@ -2803,7 +2803,7 @@ term_print(struct terminal *term, wchar_t wc, int width) /* Multi-column character that doesn't fit on current line - * pad with spacers */ for (size_t i = term->grid->cursor.point.col; i < term->cols; i++) - print_spacer(term, i); + print_spacer(term, i, 0); /* And force a line-wrap */ term->grid->cursor.lcf = 1; @@ -2826,7 +2826,7 @@ term_print(struct terminal *term, wchar_t wc, int width) /* Advance cursor the 'additional' columns while dirty:ing the cells */ for (int i = 1; i < width && term->grid->cursor.point.col < term->cols - 1; i++) { term->grid->cursor.point.col++; - print_spacer(term, term->grid->cursor.point.col); + print_spacer(term, term->grid->cursor.point.col, width - i); } /* Advance cursor */ -- cgit v1.3