diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-07-15 06:20:10 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-07-15 06:20:10 +0000 |
| commit | 6b0b3ddcccf27fd08b77945d71409ac26dfe94dc (patch) | |
| tree | 837f8ae2002a0d1f91871731d370bfda77b9ba51 /terminal.c | |
| parent | selection: recognize empty padding cells in a forced linewrap (diff) | |
| parent | term: print: don't pad with spacers if auto-margin is disabled (diff) | |
Merge branch 'multi-column-special-spacer-value'
Diffstat (limited to 'terminal.c')
| -rw-r--r-- | terminal.c | 41 |
1 files changed, 22 insertions, 19 deletions
@@ -2387,33 +2387,39 @@ print_insert(struct terminal *term, int width) row->cells[i].attrs.clean = 0; } +static void +print_spacer(struct terminal *term, int col) +{ + struct row *row = term->grid->cur_row; + struct cell *cell = &row->cells[col]; + + cell->wc = CELL_MULT_COL_SPACER; + cell->attrs = term->vt.attrs; + cell->attrs.clean = 0; +} + void term_print(struct terminal *term, wchar_t wc, int width) { if (unlikely(width <= 0)) return; - if (unlikely(width > 1) && + print_linewrap(term); + print_insert(term, width); + + if (unlikely(width > 1) && likely(term->auto_margin) && term->grid->cursor.point.col + width > term->cols) { /* Multi-column character that doesn't fit on current line - - * force a line wrap */ - term->grid->cursor.lcf = 1; + * pad with spacers */ + for (size_t i = term->grid->cursor.point.col; i < term->cols; i++) + print_spacer(term, i); - /* - * TODO: should we insert place holder values in the remaining - * cells? This would allow e.g. text extraction to simply - * skip these, instead of trying to recognize a sequence of - * empty cells at the end of the line followed by a - * multi-column character... - * - * Might also make text reflow easier, or even more correct. - */ + /* And force a line-wrap */ + term->grid->cursor.lcf = 1; + print_linewrap(term); } - print_linewrap(term); - print_insert(term, width); - sixel_overwrite_at_cursor(term, width); /* *Must* get current cell *after* linewrap+insert */ @@ -2429,10 +2435,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++; - - struct cell *cell = &row->cells[term->grid->cursor.point.col]; - cell->wc = 0; - cell->attrs.clean = 0; + print_spacer(term, term->grid->cursor.point.col); } /* Advance cursor */ |
