From 189cfd717fd4670a97995ad9b8e08a2352c09099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 26 Dec 2021 15:59:38 +0100 Subject: [PATCH] term: replace term_put_char() with term_fill() --- csi.c | 11 ++--------- terminal.c | 32 +++++++++++++++++++------------- terminal.h | 2 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/csi.c b/csi.c index 43a358a8..ac03825e 100644 --- a/csi.c +++ b/csi.c @@ -1941,15 +1941,8 @@ csi_dispatch(struct terminal *term, uint8_t final) sixel_overwrite_by_rectangle( term, top, left, bottom - top + 1, right - left + 1); - for (int r = top; r <= bottom; r++) { - struct row *row = grid_row(term->grid, r); - - if (unlikely(row->extra != NULL)) - grid_row_uri_range_erase(row, left, right); - - for (int col = left; col <= right; col++) - term_put_char(term, r, col, (wchar_t)c); - } + for (int r = top; r <= bottom; r++) + term_fill(term, r, left, c, right - left + 1); } break; } diff --git a/terminal.c b/terminal.c index ad20c737..8abe61e8 100644 --- a/terminal.c +++ b/terminal.c @@ -3506,33 +3506,39 @@ print_spacer(struct terminal *term, int col, int remaining) * - update the cursor * - linewrap * - erase sixels - * - erase URIs (but it _does_ emit them if one is active) * * Limitations: * - double width characters not supported */ void -term_put_char(struct terminal *term, int r, int c, wchar_t wc) +term_fill(struct terminal *term, int r, int c, char data, size_t count) { struct row *row = grid_row(term->grid, r); row->dirty = true; - struct cell *cell = &row->cells[c]; - cell->wc = wc; - cell->attrs = term->vt.attrs; + xassert(c + count <= term->cols); - if (unlikely(term->vt.osc8.uri != NULL)) { - grid_row_uri_range_put(row, c, term->vt.osc8.uri, term->vt.osc8.id); + const struct cell *last = &row->cells[c + count]; + for (struct cell *cell = &row->cells[c]; cell < last; cell++) { + cell->wc = data; + cell->attrs = term->vt.attrs; - switch (term->conf->url.osc8_underline) { - case OSC8_UNDERLINE_ALWAYS: - cell->attrs.url = true; - break; + if (unlikely(term->vt.osc8.uri != NULL)) { + grid_row_uri_range_put(row, c, term->vt.osc8.uri, term->vt.osc8.id); - case OSC8_UNDERLINE_URL_MODE: - break; + switch (term->conf->url.osc8_underline) { + case OSC8_UNDERLINE_ALWAYS: + cell->attrs.url = true; + break; + + case OSC8_UNDERLINE_URL_MODE: + break; + } } } + + if (unlikely(row->extra != NULL)) + grid_row_uri_range_erase(row, c, c + count - 1); } void diff --git a/terminal.h b/terminal.h index 8abc1c8e..f56ffdb0 100644 --- a/terminal.h +++ b/terminal.h @@ -797,8 +797,8 @@ void term_cursor_up(struct terminal *term, int count); void term_cursor_down(struct terminal *term, int count); void term_cursor_blink_update(struct terminal *term); -void term_put_char(struct terminal *term, int r, int c, char32_t wc); void term_print(struct terminal *term, char32_t wc, int width); +void term_fill(struct terminal *term, int row, int col, char c, size_t count); void term_scroll(struct terminal *term, int rows); void term_scroll_reverse(struct terminal *term, int rows);