aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-23 08:24:50 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-26 08:15:45 +0000
commitbc71e06d5f5b9f27aca373e523627c70670e979c (patch)
treee9247b3a8383b97df54556c3445ac43461ad40ef
parenturl-mode: no need to damage the entire view when exiting URL mode (diff)
url-mode: dirty the “last cursor” cell before taking the snapshot
This ensures the “last cursor” cell is re-drawn (without a cursor, if the cursor has moved), both in the snapshot:ed grid, and later, when we switch back to the real grid. We must also be careful and reset term->render.last_cursor.row both when *entering* and *leaving* URL mode, to ensure it doesn’t point to an invalid row.
-rw-r--r--url-mode.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/url-mode.c b/url-mode.c
index 8b1b9795..54edc524 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -637,6 +637,17 @@ urls_render(struct terminal *term)
tag_cells_for_url(term, &it->item, true);
}
+ /* Dirty the last cursor, to ensure it is erased */
+ {
+ struct row *cursor_row = term->render.last_cursor.row;
+ if (cursor_row != NULL) {
+ struct cell *cell = &cursor_row->cells[term->render.last_cursor.col];
+ cell->attrs.clean = 0;
+ cursor_row->dirty = true;
+ }
+ }
+ term->render.last_cursor.row = NULL;
+
/* Snapshot the current grid */
term->url_grid_snapshot = grid_snapshot(term->grid);
@@ -662,6 +673,15 @@ urls_reset(struct terminal *term)
grid_free(term->url_grid_snapshot);
free(term->url_grid_snapshot);
term->url_grid_snapshot = NULL;
+
+ /*
+ * Make sure “last cursor” doesn’t point to a row in the just
+ * free:d snapshot grid.
+ *
+ * Note that it will still be erased properly (if hasn’t already),
+ * since we marked the cell as dirty *before* taking the grid
+ * snapshot.
+ */
term->render.last_cursor.row = NULL;
if (term->window != NULL) {