aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--render.c19
-rw-r--r--selection.c10
-rw-r--r--selection.h1
4 files changed, 31 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c10c01d9..3d35b902 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@
`shift` to start a selection. This selection is now finalized only
when the mouse button is released - not as soon as `shift` is
released.
+* Selected cells did not appear selected if modified.
### Security
diff --git a/render.c b/render.c
index fb6b1794..cf2bdaa4 100644
--- a/render.c
+++ b/render.c
@@ -1354,6 +1354,25 @@ grid_render(struct terminal *term)
/* Reset clip region since scrolling may have instantiated a new pixman image */
pixman_image_set_clip_region(buf->pix, &clip);
+ /*
+ * Ensure selected cells have their 'selected' bit set. This is
+ * normally "automatically" true - the bit is set when the
+ * selection is made.
+ *
+ * However, if the cell is updated (printed to) while the
+ * selection is active, the 'selected' bit is cleared. Checking
+ * for this and re-setting the bit in term_print() is too
+ * expensive performance wise.
+ *
+ * Instead, we synchronize the selection bits here and now. This
+ * makes the performance impact linear to the number of selected
+ * cells rather than to the number of updated cells.
+ *
+ * (note that selection_dirty_cells() will not set the dirty flag
+ * on cells where the 'selected' bit is already set)
+ */
+ selection_dirty_cells(term);
+
if (term->render.workers.count > 0) {
term->render.workers.buf = buf;
diff --git a/selection.c b/selection.c
index 7e5a12ab..59cab9a7 100644
--- a/selection.c
+++ b/selection.c
@@ -403,6 +403,16 @@ selection_update(struct terminal *term, int col, int row)
selection_modify(term, term->selection.start, new_end);
}
+void
+selection_dirty_cells(struct terminal *term)
+{
+ if (term->selection.start.row == -1 || term->selection.end.row == -1)
+ return;
+
+ foreach_selected(
+ term, term->selection.start, term->selection.end, &mark_selected, NULL);
+}
+
static void
selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial)
{
diff --git a/selection.h b/selection.h
index adb66821..87d25fc5 100644
--- a/selection.h
+++ b/selection.h
@@ -13,6 +13,7 @@ void selection_start(
struct terminal *term, int col, int row, enum selection_kind kind);
void selection_update(struct terminal *term, int col, int row);
void selection_finalize(struct terminal *term, uint32_t serial);
+void selection_dirty_cells(struct terminal *term);
void selection_cancel(struct terminal *term);
void selection_extend(struct terminal *term, int col, int row, uint32_t serial);