From 1d4e1b921d351da349ccfbc5d587489d7b77e690 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 25 Apr 2022 20:00:14 +0200 Subject: sixel/terminal: use the new grid and selection APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use grid_row_abs_to_sb() instead of manually “rebasing” row numbers. Use selection_get_{start,end}() to retrieve the current selection coordinates. --- terminal.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index f1b05f57..7d230cdf 100644 --- a/terminal.c +++ b/terminal.c @@ -2154,18 +2154,18 @@ term_erase(struct terminal *term, int start_row, int start_col, void term_erase_scrollback(struct terminal *term) { - const int num_rows = term->grid->num_rows; + const struct grid *grid = term->grid; + const int num_rows = grid->num_rows; const int mask = num_rows - 1; - const int start = (term->grid->offset + term->rows) & mask; - const int end = (term->grid->offset - 1) & mask; + const int start = (grid->offset + term->rows) & mask; + const int end = (grid->offset - 1) & mask; - const int scrollback_start = term->grid->offset + term->rows; - const int rel_start = (start - scrollback_start + num_rows) & mask; - const int rel_end = (end - scrollback_start + num_rows) & mask; + const int rel_start = grid_row_abs_to_sb(grid, term->rows, start); + const int rel_end = grid_row_abs_to_sb(grid, term->rows, end); - const int sel_start = term->selection.coords.start.row; - const int sel_end = term->selection.coords.end.row; + const int sel_start = selection_get_start(term).row; + const int sel_end = selection_get_end(term).row; if (sel_end >= 0) { /* @@ -2183,8 +2183,8 @@ term_erase_scrollback(struct terminal *term) * closer to the screen bottom. */ - const int rel_sel_start = (sel_start - scrollback_start + num_rows) & mask; - const int rel_sel_end = (sel_end - scrollback_start + num_rows) & mask; + const int rel_sel_start = grid_row_abs_to_sb(grid, term->rows, sel_start); + const int rel_sel_end = grid_row_abs_to_sb(grid, term->rows, sel_end); if ((rel_sel_start <= rel_start && rel_sel_end >= rel_start) || (rel_sel_start <= rel_end && rel_sel_end >= rel_end) || @@ -2196,8 +2196,9 @@ term_erase_scrollback(struct terminal *term) tll_foreach(term->grid->sixel_images, it) { struct sixel *six = &it->item; - const int six_start = (six->pos.row - scrollback_start + num_rows) & mask; - const int six_end = (six->pos.row + six->rows - 1 - scrollback_start + num_rows) & mask; + const int six_start = grid_row_abs_to_sb(grid, term->rows, six->pos.row); + const int six_end = grid_row_abs_to_sb( + grid, term->rows, six->pos.row + six->rows - 1); if ((six_start <= rel_start && six_end >= rel_start) || (six_start <= rel_end && six_end >= rel_end) || -- cgit v1.3 From 398d96fdb2a18f7652c116639dc17741f5e24404 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 26 Apr 2022 17:24:55 +0200 Subject: term: flash: work around Sway sub-surface unmap bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unmapping a sub-surface in Sway does not damage the underlying surface. As a result, the OSC-555 escape (“flash”) will leave yellow margins on ~every second frame. Out of sway, river, weston and mutter, only Sway needs this workaround. This is a workaround for https://github.com/swaywm/sway/issues/6960 Closes #1046 --- terminal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 7d230cdf..9199aa31 100644 --- a/terminal.c +++ b/terminal.c @@ -355,8 +355,12 @@ fdm_flash(struct fdm *fdm, int fd, int events, void *data) (unsigned long long)expiration_count); term->flash.active = false; - term_damage_view(term); render_refresh(term); + + /* Work around Sway bug - unmapping a sub-surface does not damage + * the underlying surface */ + term_damage_margins(term); + term_damage_view(term); return true; } -- cgit v1.3 From 32d9895697584988056086cbecdc96375b4b9115 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 26 Apr 2022 21:05:17 +0200 Subject: term: reset sixel options when hard resetting the terminal state --- CHANGELOG.md | 2 ++ terminal.c | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'terminal.c') diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c05401..07c3dfbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ scrollback search mode ([#1036][1036]). * Scrollback search mode not always highlighting all matches correctly. +* Sixel options not being reset on hard resets (`\Ec`) + [1040]: https://codeberg.org/dnkl/foot/issues/1040 [1036]: https://codeberg.org/dnkl/foot/issues/1036 diff --git a/terminal.c b/terminal.c index 9199aa31..dcaca033 100644 --- a/terminal.c +++ b/terminal.c @@ -1929,6 +1929,16 @@ term_reset(struct terminal *term, bool hard) tll_free(term->alt.scroll_damage); term->render.last_cursor.row = NULL; term_damage_all(term); + + term->sixel.scrolling = true; + term->sixel.cursor_right_of_graphics = false; + term->sixel.use_private_palette = true; + term->sixel.max_width = SIXEL_MAX_WIDTH; + term->sixel.max_height = SIXEL_MAX_HEIGHT; + term->sixel.palette_size = SIXEL_MAX_COLORS; + free(term->sixel.private_palette); + free(term->sixel.shared_palette); + term->sixel.private_palette = term->sixel.shared_palette = NULL; } static bool -- cgit v1.3