From 1a0de0017f7b2061bad0b695a98963ca0f274e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 13:42:07 +0100 Subject: [PATCH 01/11] grid: add grid_row_uri_range_erase() This function handles erasing of an URI range. That is, a range of the row is being either erased, or overwritten (from the URI perspective, these two are the same thing). We handle both partial overwrites (split up, or truncate URI), as well as complete overwrites (remove URI). --- grid.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++-- grid.h | 3 +- terminal.c | 74 +------------------------ 3 files changed, 155 insertions(+), 78 deletions(-) diff --git a/grid.c b/grid.c index 733d8ded..d98c4696 100644 --- a/grid.c +++ b/grid.c @@ -236,7 +236,7 @@ grid_resize_without_reflow( .id = it->item.id, .uri = xstrdup(it->item.uri), }; - grid_row_add_uri_range(new_row, range); + grid_row_uri_range_add(new_row, range); } } @@ -303,7 +303,7 @@ reflow_uri_range_start(struct row_uri_range *range, struct row *new_row, .uri = range->uri, }; range->uri = NULL; - grid_row_add_uri_range(new_row, new_range); + grid_row_uri_range_add(new_row, new_range); } static void @@ -366,7 +366,7 @@ _line_wrap(struct grid *old_grid, struct row **new_grid, struct row *row, .id = range->id, .uri = xstrdup(range->uri), }; - grid_row_add_uri_range(new_row, new_range); + grid_row_uri_range_add(new_row, new_range); } } @@ -845,14 +845,160 @@ ensure_row_has_extra_data(struct row *row) } void -grid_row_add_uri_range(struct row *row, struct row_uri_range range) +grid_row_uri_range_add(struct row *row, struct row_uri_range range) { ensure_row_has_extra_data(row); tll_rforeach(row->extra->uri_ranges, it) { if (it->item.end < range.start) { tll_insert_after(row->extra->uri_ranges, it, range); - return; + goto out; } } + tll_push_front(row->extra->uri_ranges, range); + +out: + ; +#if defined(_DEBUG) + tll_foreach(row->extra->uri_ranges, it1) { + tll_foreach(row->extra->uri_ranges, it2) { + if (&it1->item == &it2->item) + continue; + + xassert(it1->item.start != it2->item.start); + xassert(it1->item.start != it2->item.end); + xassert(it1->item.end != it2->item.start); + xassert(it1->item.end != it2->item.end); + } + } +#endif +} + +void +grid_row_uri_range_erase(struct row *row, int start, int end) +{ + if (likely(row->extra == NULL)) + return; + + /* Split up, or remove, URI ranges affected by the erase */ + tll_foreach(row->extra->uri_ranges, it) { + if (it->item.start > end) { + /* This range, and all subsequent ranges, start *after* + * the erase range */ + break; + } + + if (it->item.start < start && it->item.end >= start) { + /* + * URI crosses the erase *start* point. + * + * Create a new range for the URI part *before* the erased + * cells. + * + * Also modify this URI range’s start point so that we can + * remove it below. + */ + struct row_uri_range range_before = { + .start = it->item.start, + .end = start - 1, + .id = it->item.id, + .uri = it->item.uri != NULL ? xstrdup(it->item.uri) : NULL, + }; + tll_insert_before(row->extra->uri_ranges, it, range_before); + it->item.start = start; + } + + if (it->item.start <= end && it->item.end > end) { + /* + * URI crosses the erase *end* point. + * + * Create a new range for the URI part *after* the erased + * cells. + * + * Also modify the URI range’s end point so that we can + * remove it below. + */ + struct row_uri_range range_after = { + .start = end + 1, + .end = it->item.end, + .id = it->item.id, + .uri = it->item.uri != NULL ? xstrdup(it->item.uri) : NULL, + }; + tll_insert_before(row->extra->uri_ranges, it, range_after); + it->item.end = end; + } + + if (it->item.start >= start && it->item.end <= end) { + /* URI range completey covered by the erase - remove it */ + free(it->item.uri); + tll_remove(row->extra->uri_ranges, it); + } + } +} + +UNITTEST +{ + struct row_data row_data = {.uri_ranges = tll_init()}; + struct row row = {.extra = &row_data}; + +#define row_has_no_overlapping_uris(row) \ + do { \ + tll_foreach((row)->extra->uri_ranges, it1) { \ + tll_foreach((row)->extra->uri_ranges, it2) { \ + if (&it1->item == &it2->item) \ + continue; \ + xassert(it1->item.start != it2->item.start); \ + xassert(it1->item.start != it2->item.end); \ + xassert(it1->item.end != it2->item.start); \ + xassert(it1->item.end != it2->item.end); \ + } \ + } \ + } while (0) + + grid_row_uri_range_add(&row, (struct row_uri_range){1, 10}); + xassert(tll_length(row_data.uri_ranges) == 1); + xassert(tll_front(row_data.uri_ranges).start == 1); + xassert(tll_front(row_data.uri_ranges).end == 10); + row_has_no_overlapping_uris(&row); + + grid_row_uri_range_add(&row, (struct row_uri_range){11, 20}); + xassert(tll_length(row_data.uri_ranges) == 2); + xassert(tll_back(row_data.uri_ranges).start == 11); + xassert(tll_back(row_data.uri_ranges).end == 20); + row_has_no_overlapping_uris(&row); + + /* Erase both URis */ + grid_row_uri_range_erase(&row, 1, 20); + xassert(tll_length(row_data.uri_ranges) == 0); + row_has_no_overlapping_uris(&row); + + /* Two URIs, then erase second half of the first, first half of + the second */ + grid_row_uri_range_add(&row, (struct row_uri_range){1, 10}); + grid_row_uri_range_add(&row, (struct row_uri_range){11, 20}); + grid_row_uri_range_erase(&row, 5, 15); + xassert(tll_length(row_data.uri_ranges) == 2); + xassert(tll_front(row_data.uri_ranges).start == 1); + xassert(tll_front(row_data.uri_ranges).end == 4); + xassert(tll_back(row_data.uri_ranges).start == 16); + xassert(tll_back(row_data.uri_ranges).end == 20); + row_has_no_overlapping_uris(&row); + + tll_pop_back(row_data.uri_ranges); + tll_pop_back(row_data.uri_ranges); + xassert(tll_length(row_data.uri_ranges) == 0); + + /* One URI, erase middle part of it */ + grid_row_uri_range_add(&row, (struct row_uri_range){1, 10}); + grid_row_uri_range_erase(&row, 5, 6); + xassert(tll_length(row_data.uri_ranges) == 2); + xassert(tll_front(row_data.uri_ranges).start == 1); + xassert(tll_front(row_data.uri_ranges).end == 4); + xassert(tll_back(row_data.uri_ranges).start == 7); + xassert(tll_back(row_data.uri_ranges).end == 10); + row_has_no_overlapping_uris(&row); + +#undef row_has_no_overlapping_uris + + tll_free(row_data.uri_ranges); } diff --git a/grid.h b/grid.h index 3537ddb5..e2cd3a63 100644 --- a/grid.h +++ b/grid.h @@ -74,7 +74,8 @@ grid_row_in_view(struct grid *grid, int row_no) return row; } -void grid_row_add_uri_range(struct row *row, struct row_uri_range range); +void grid_row_uri_range_add(struct row *row, struct row_uri_range range); +void grid_row_uri_range_erase(struct row *row, int start, int end); static inline void grid_row_uri_range_destroy(struct row_uri_range *range) diff --git a/terminal.c b/terminal.c index bf13dd46..3100e3a4 100644 --- a/terminal.c +++ b/terminal.c @@ -1781,63 +1781,7 @@ erase_cell_range(struct terminal *term, struct row *row, int start, int end) } else memset(&row->cells[start], 0, (end - start + 1) * sizeof(row->cells[0])); - if (likely(row->extra == NULL)) - return; - - /* Split up, or remove, URI ranges affected by the erase */ - tll_foreach(row->extra->uri_ranges, it) { - if (it->item.start > end) { - /* This range, and all subsequent ranges, start *after* - * the erase range */ - break; - } - - if (it->item.start < start && it->item.end >= start) { - /* - * URI crosses the erase *start* point. - * - * Create a new range for the URI part *before* the erased - * cells. - * - * Also modify this URI range’s start point so that we can - * remove it below. - */ - struct row_uri_range range_before = { - .start = it->item.start, - .end = start - 1, - .id = it->item.id, - .uri = xstrdup(it->item.uri), - }; - tll_insert_before(row->extra->uri_ranges, it, range_before); - it->item.start = start; - } - - if (it->item.start <= end && it->item.end > end) { - /* - * URI crosses the erase *end* point. - * - * Create a new range for the URI part *after* the erased - * cells. - * - * Also modify the URI range’s end point so that we can - * remove it below. - */ - struct row_uri_range range_after = { - .start = end + 1, - .end = it->item.end, - .id = it->item.id, - .uri = xstrdup(it->item.uri), - }; - tll_insert_before(row->extra->uri_ranges, it, range_after); - it->item.end = end; - } - - if (it->item.start >= start && it->item.end <= end) { - /* URI range completey covered by the erase - remove it */ - free(it->item.uri); - tll_remove(row->extra->uri_ranges, it); - } - } + grid_row_uri_range_erase(row, start, end); } static inline void @@ -3590,21 +3534,7 @@ term_osc8_close(struct terminal *term) .id = term->vt.osc8.id, .uri = xstrdup(term->vt.osc8.uri), }; - grid_row_add_uri_range(row, range); - -#if defined(_DEBUG) - tll_foreach(row->extra->uri_ranges, it1) { - tll_foreach(row->extra->uri_ranges, it2) { - if (&it1->item == &it2->item) - continue; - - xassert(it1->item.start != it2->item.start); - xassert(it1->item.start != it2->item.end); - xassert(it1->item.end != it2->item.start); - xassert(it1->item.end != it2->item.end); - } - } -#endif + grid_row_uri_range_add(row, range); start_col = 0; if (r == end.row) From 09a331857a8480ebce4aec83e665a0c68e6a03c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 13:54:30 +0100 Subject: [PATCH 02/11] term: call grid_row_uri_range_erase() when printing cells --- terminal.c | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/terminal.c b/terminal.c index 3100e3a4..7bf912e8 100644 --- a/terminal.c +++ b/terminal.c @@ -3162,6 +3162,8 @@ term_print(struct terminal *term, wchar_t wc, int width) { xassert(width > 0); + struct grid *grid = term->grid; + if (unlikely(term->charsets.set[term->charsets.selected] == CHARSET_GRAPHIC) && wc >= 0x60 && wc <= 0x7e) { @@ -3180,24 +3182,26 @@ term_print(struct terminal *term, wchar_t wc, int width) print_linewrap(term); print_insert(term, width); + int col = grid->cursor.point.col; + if (unlikely(width > 1) && likely(term->auto_margin) && - term->grid->cursor.point.col + width > term->cols) + col + width > term->cols) { /* 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++) + for (size_t i = col; i < term->cols; i++) print_spacer(term, i, 0); /* And force a line-wrap */ - term->grid->cursor.lcf = 1; + grid->cursor.lcf = 1; print_linewrap(term); } sixel_overwrite_at_cursor(term, width); /* *Must* get current cell *after* linewrap+insert */ - struct row *row = term->grid->cur_row; - struct cell *cell = &row->cells[term->grid->cursor.point.col]; + struct row *row = grid->cur_row; + struct cell *cell = &row->cells[col]; cell->wc = term->vt.last_printed = wc; cell->attrs = term->vt.attrs; @@ -3205,18 +3209,22 @@ term_print(struct terminal *term, wchar_t wc, int width) row->dirty = true; row->linebreak = true; + grid_row_uri_range_erase(row, col, col + width - 1); + /* 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, width - i); + for (int i = 1; i < width && col < term->cols - 1; i++) { + col++; + print_spacer(term, col, width - i); } /* Advance cursor */ - if (unlikely(++term->grid->cursor.point.col >= term->cols)) { - term->grid->cursor.lcf = true; - term->grid->cursor.point.col--; + if (unlikely(++col >= term->cols)) { + grid->cursor.lcf = true; + col--; } else - xassert(!term->grid->cursor.lcf); + xassert(!grid->cursor.lcf); + + grid->cursor.point.col = col; } static void @@ -3228,15 +3236,18 @@ ascii_printer_generic(struct terminal *term, wchar_t wc) static void ascii_printer_fast(struct terminal *term, wchar_t wc) { + struct grid *grid = term->grid; + xassert(term->charsets.set[term->charsets.selected] == CHARSET_ASCII); xassert(!term->insert_mode); - xassert(tll_length(term->grid->sixel_images) == 0); + xassert(tll_length(grid->sixel_images) == 0); print_linewrap(term); /* *Must* get current cell *after* linewrap+insert */ - struct row *row = term->grid->cur_row; - struct cell *cell = &row->cells[term->grid->cursor.point.col]; + int col = grid->cursor.point.col; + struct row *row = grid->cur_row; + struct cell *cell = &row->cells[col]; cell->wc = term->vt.last_printed = wc; cell->attrs = term->vt.attrs; @@ -3244,12 +3255,16 @@ ascii_printer_fast(struct terminal *term, wchar_t wc) row->dirty = true; row->linebreak = true; + grid_row_uri_range_erase(row, col, col); + /* Advance cursor */ - if (unlikely(++term->grid->cursor.point.col >= term->cols)) { - term->grid->cursor.lcf = true; - term->grid->cursor.point.col--; + if (unlikely(++col >= term->cols)) { + grid->cursor.lcf = true; + col--; } else - xassert(!term->grid->cursor.lcf); + xassert(!grid->cursor.lcf); + + grid->cursor.point.col = col; } static void From 53fc1a1cb12fc2367a1ff76e723be52603c39cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 14:39:32 +0100 Subject: [PATCH 03/11] term: tail-call optimize calls to grid_row_uri_range_erase() --- terminal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/terminal.c b/terminal.c index 7bf912e8..120f7ac3 100644 --- a/terminal.c +++ b/terminal.c @@ -3209,7 +3209,7 @@ term_print(struct terminal *term, wchar_t wc, int width) row->dirty = true; row->linebreak = true; - grid_row_uri_range_erase(row, col, col + width - 1); + int uri_start = col; /* Advance cursor the 'additional' columns while dirty:ing the cells */ for (int i = 1; i < width && col < term->cols - 1; i++) { @@ -3225,6 +3225,9 @@ term_print(struct terminal *term, wchar_t wc, int width) xassert(!grid->cursor.lcf); grid->cursor.point.col = col; + + if (unlikely(row->extra != NULL)) + grid_row_uri_range_erase(row, uri_start, uri_start + width - 1); } static void @@ -3255,7 +3258,7 @@ ascii_printer_fast(struct terminal *term, wchar_t wc) row->dirty = true; row->linebreak = true; - grid_row_uri_range_erase(row, col, col); + int uri_start = col; /* Advance cursor */ if (unlikely(++col >= term->cols)) { @@ -3265,6 +3268,9 @@ ascii_printer_fast(struct terminal *term, wchar_t wc) xassert(!grid->cursor.lcf); grid->cursor.point.col = col; + + if (unlikely(row->extra != NULL)) + grid_row_uri_range_erase(row, uri_start, uri_start); } static void From 0be55ef74c38140877d82c66159f112517b3825c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 14:40:03 +0100 Subject: [PATCH 04/11] term: erase_cell_range(): check if row->extra != NULL --- terminal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index 120f7ac3..ea7da6e3 100644 --- a/terminal.c +++ b/terminal.c @@ -1781,7 +1781,8 @@ erase_cell_range(struct terminal *term, struct row *row, int start, int end) } else memset(&row->cells[start], 0, (end - start + 1) * sizeof(row->cells[0])); - grid_row_uri_range_erase(row, start, end); + if (unlikely(row->extra != NULL)) + grid_row_uri_range_erase(row, start, end); } static inline void From 503c2ebd50caaf1d50b57c42d319973277a583e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 14:40:16 +0100 Subject: [PATCH 05/11] grid: row_uri_range_erase(): assume caller has checked row->extra != NULL --- grid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grid.c b/grid.c index d98c4696..22405356 100644 --- a/grid.c +++ b/grid.c @@ -877,8 +877,7 @@ out: void grid_row_uri_range_erase(struct row *row, int start, int end) { - if (likely(row->extra == NULL)) - return; + xassert(row->extra != NULL); /* Split up, or remove, URI ranges affected by the erase */ tll_foreach(row->extra->uri_ranges, it) { From f27ccd999ef6fcf10f99aed9f6aec449fe071551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 15:46:20 +0100 Subject: [PATCH 06/11] grid: refactor grid_row_uri_range_erase() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old algorithm always created a new URI, followed by (maybe) removing the existing URI, when an URI needed to be modified. That is, if e.g. the tail of an URI was being erased, the old algorithm would create a new URI for the part of the URI that should remain, and then removed the old URI. This isn’t very effective. The new algorithm instead identifies all possible overlap cases, and handles each one differently: * URI ends *before* erase range starts - continue with the next URI without further checks * URI starts *after* the erase range ends - return, we’re done * Erase range erases the entire URI - remove the URI * Erase range erases a part in the middle - split the URI * Erase range erases the head of the URI - adjust the URI’s start * Erase range erases the tail of the URI - adjust the URI’s end --- grid.c | 81 +++++++++++++++++++++++++--------------------------------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/grid.c b/grid.c index 22405356..459fa369 100644 --- a/grid.c +++ b/grid.c @@ -878,60 +878,49 @@ void grid_row_uri_range_erase(struct row *row, int start, int end) { xassert(row->extra != NULL); + xassert(start <= end); /* Split up, or remove, URI ranges affected by the erase */ tll_foreach(row->extra->uri_ranges, it) { - if (it->item.start > end) { - /* This range, and all subsequent ranges, start *after* - * the erase range */ - break; - } + struct row_uri_range *old = &it->item; - if (it->item.start < start && it->item.end >= start) { - /* - * URI crosses the erase *start* point. - * - * Create a new range for the URI part *before* the erased - * cells. - * - * Also modify this URI range’s start point so that we can - * remove it below. - */ - struct row_uri_range range_before = { - .start = it->item.start, - .end = start - 1, - .id = it->item.id, - .uri = it->item.uri != NULL ? xstrdup(it->item.uri) : NULL, - }; - tll_insert_before(row->extra->uri_ranges, it, range_before); - it->item.start = start; - } + if (old->end < start) + continue; - if (it->item.start <= end && it->item.end > end) { - /* - * URI crosses the erase *end* point. - * - * Create a new range for the URI part *after* the erased - * cells. - * - * Also modify the URI range’s end point so that we can - * remove it below. - */ - struct row_uri_range range_after = { - .start = end + 1, - .end = it->item.end, - .id = it->item.id, - .uri = it->item.uri != NULL ? xstrdup(it->item.uri) : NULL, - }; - tll_insert_before(row->extra->uri_ranges, it, range_after); - it->item.end = end; - } + if (old->start > end) + return; - if (it->item.start >= start && it->item.end <= end) { - /* URI range completey covered by the erase - remove it */ - free(it->item.uri); + if (start <= old->start && end >= old->end) { + /* Erase range covers URI completely - remove it */ + grid_row_uri_range_destroy(old); tll_remove(row->extra->uri_ranges, it); } + + else if (start > old->start && end < old->end) { + /* Erase range erases a part in the middle of the URI */ + struct row_uri_range old_tail = { + .start = end + 1, + .end = old->end, + .id = old->id, + .uri = old->uri != NULL ? xstrdup(old->uri) : NULL, + }; + tll_insert_after(row->extra->uri_ranges, it, old_tail); + old->end = start - 1; + return; /* There can be no more URIs affected by the erase range */ + } + + else if (start <= old->start && end >= old->start) { + /* Erase range erases the head of the URI */ + xassert(start <= old->start); + old->start = end + 1; + return; /* There can be no more overlapping URIs */ + } + + else if (start <= old->end && end >= old->end) { + /* Erase range erases the tail of the URI */ + xassert(end >= old->end); + old->end = start - 1; + } } } From ad8d1bf25c73be4e5561b49e44de663600db4f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Nov 2021 18:10:45 +0100 Subject: [PATCH 07/11] changelog: osc-8 data not being cleared when cell is overwritten --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47330812..3dfd029e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,8 @@ * Regression: `pipe-*` key bindings not being parsed correctly, resulting in invalid error messages (https://codeberg.org/dnkl/foot/issues/809). +* OSC-8 data not being cleared when cell is overwritten + (https://codeberg.org/dnkl/foot/issues/804). ### Security From 3c6239c66f0ea758655a891492073fd3549cd877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 21 Nov 2021 14:13:27 +0100 Subject: [PATCH 08/11] term: print: re-order col/row/cell assigments --- terminal.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/terminal.c b/terminal.c index ea7da6e3..1da97335 100644 --- a/terminal.c +++ b/terminal.c @@ -3202,15 +3202,14 @@ term_print(struct terminal *term, wchar_t wc, int width) /* *Must* get current cell *after* linewrap+insert */ struct row *row = grid->cur_row; - struct cell *cell = &row->cells[col]; - - cell->wc = term->vt.last_printed = wc; - cell->attrs = term->vt.attrs; - row->dirty = true; row->linebreak = true; - int uri_start = col; + struct cell *cell = &row->cells[col]; + cell->wc = term->vt.last_printed = wc; + cell->attrs = term->vt.attrs; + + const int uri_start = col; /* Advance cursor the 'additional' columns while dirty:ing the cells */ for (int i = 1; i < width && col < term->cols - 1; i++) { @@ -3250,16 +3249,16 @@ ascii_printer_fast(struct terminal *term, wchar_t wc) /* *Must* get current cell *after* linewrap+insert */ int col = grid->cursor.point.col; + const int uri_start = col; + struct row *row = grid->cur_row; - struct cell *cell = &row->cells[col]; - - cell->wc = term->vt.last_printed = wc; - cell->attrs = term->vt.attrs; - row->dirty = true; row->linebreak = true; - int uri_start = col; + struct cell *cell = &row->cells[col]; + cell->wc = term->vt.last_printed = wc; + cell->attrs = term->vt.attrs; + /* Advance cursor */ if (unlikely(++col >= term->cols)) { From 65944906bf87bf7ea6c404526fa3f3f88f96194a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 21 Nov 2021 14:14:08 +0100 Subject: [PATCH 09/11] term: print: erase URI range when printing right-margin padding --- terminal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/terminal.c b/terminal.c index 1da97335..21733cf5 100644 --- a/terminal.c +++ b/terminal.c @@ -3193,6 +3193,9 @@ term_print(struct terminal *term, wchar_t wc, int width) for (size_t i = col; i < term->cols; i++) print_spacer(term, i, 0); + if (grid->cur_row->extra != NULL) + grid_row_uri_range_erase(grid->cur_row, col, term->cols - 1); + /* And force a line-wrap */ grid->cursor.lcf = 1; print_linewrap(term); From 315769b50bd3df2d41cb130200bc03eb64be4078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 21 Nov 2021 14:46:05 +0100 Subject: [PATCH 10/11] Revert "term: print: erase URI range when printing right-margin padding" This reverts commit bb967fd2f927d90e881ed2b05db1fa6946033580. --- terminal.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/terminal.c b/terminal.c index 21733cf5..1da97335 100644 --- a/terminal.c +++ b/terminal.c @@ -3193,9 +3193,6 @@ term_print(struct terminal *term, wchar_t wc, int width) for (size_t i = col; i < term->cols; i++) print_spacer(term, i, 0); - if (grid->cur_row->extra != NULL) - grid_row_uri_range_erase(grid->cur_row, col, term->cols - 1); - /* And force a line-wrap */ grid->cursor.lcf = 1; print_linewrap(term); From 5b176dd5d6e55dd666b0e424cae20e7a97e3bede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 21 Nov 2021 14:47:24 +0100 Subject: [PATCH 11/11] =?UTF-8?q?term:=20print:=20reset=20=E2=80=98col?= =?UTF-8?q?=E2=80=99=20after=20padding=20the=20right=20margin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- terminal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/terminal.c b/terminal.c index 1da97335..4cc9ed09 100644 --- a/terminal.c +++ b/terminal.c @@ -3196,6 +3196,7 @@ term_print(struct terminal *term, wchar_t wc, int width) /* And force a line-wrap */ grid->cursor.lcf = 1; print_linewrap(term); + col = 0; } sixel_overwrite_at_cursor(term, width);