diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-07-14 18:29:59 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-07-14 18:29:59 +0000 |
| commit | b0798ad0bed7dac45c167040644df6599cc390f0 (patch) | |
| tree | 4b0583f8ebd10611d8f42de13a47409e4eb0a357 /grid.c | |
| parent | term: copy current VT attributes to multi-column spacer cells (diff) | |
grid: reflow: use macro print_spacer() to insert multi-column character spacers
Diffstat (limited to 'grid.c')
| -rw-r--r-- | grid.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -183,6 +183,13 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, } \ } while(0) +#define print_spacer() \ + do { \ + new_row->cells[new_col_idx].wc = CELL_MULT_COL_SPACER; \ + new_row->cells[new_col_idx].attrs = old_cell->attrs; \ + new_row->cells[new_col_idx].attrs.clean = 1; \ + } while (0) + /* * Keep track of empty cells. If the old line ends with a * string of empty cells, we don't need to, nor do we want to, @@ -231,11 +238,8 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, /* Out of columns on current row in new grid? */ if (new_col_idx + max(1, wcwidth(old_cell->wc)) > new_cols) { /* Pad to end-of-line with spacers, then line-wrap */ - for (;new_col_idx < new_cols; new_col_idx++) { - new_row->cells[new_col_idx] = (struct cell){}; - new_row->cells[new_col_idx].wc = CELL_MULT_COL_SPACER; - new_row->cells[new_col_idx].attrs.clean = 1; - } + for (;new_col_idx < new_cols; new_col_idx++) + print_spacer(); line_wrap(); } @@ -262,9 +266,7 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, * subsequent cells */ for (size_t i = 0; i < width - 1; i++) { assert(new_col_idx < new_cols); - new_row->cells[new_col_idx] = (struct cell){}; - new_row->cells[new_col_idx].wc = CELL_MULT_COL_SPACER; - new_row->cells[new_col_idx].attrs.clean = 1; + print_spacer(); new_col_idx++; } } @@ -278,6 +280,7 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, line_wrap(); } +#undef print_spacer #undef line_wrap } |
