summaryrefslogtreecommitdiffstats
path: root/screen-write.c
diff options
context:
space:
mode:
authornicm <nicm>2016-06-06 07:28:52 +0000
committernicm <nicm>2016-06-06 07:28:52 +0000
commitaba44380137b5d78f9033e46b5dc4a4f3ef1012a (patch)
tree0f2d961fbe2de021056b3b45078d8d0f10a6442b /screen-write.c
parent00cf5fbde6d846a10804447204dd55e8c3a68dbd (diff)
Cache selected state so that cells going from selected to unselected are not
skipped, reported by Omar Sandoval.
Diffstat (limited to 'screen-write.c')
-rw-r--r--screen-write.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/screen-write.c b/screen-write.c
index 0341f0ad..48af1383 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -989,8 +989,19 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
if (skip)
skip = (memcmp(&now_gc, gc, sizeof now_gc) == 0);
- /* Set the cell. */
- if (!skip)
+ /* Update the selection the flag and set the cell. */
+ selected = screen_check_selection(s, s->cx, s->cy);
+ if (selected && ~gc->flags & GRID_FLAG_SELECTED) {
+ skip = 0;
+ memcpy(&tmp_gc, gc, sizeof tmp_gc);
+ tmp_gc.flags |= GRID_FLAG_SELECTED;
+ grid_view_set_cell(gd, s->cx, s->cy, &tmp_gc);
+ } else if (!selected && gc->flags & GRID_FLAG_SELECTED) {
+ skip = 0;
+ memcpy(&tmp_gc, gc, sizeof tmp_gc);
+ tmp_gc.flags &= ~GRID_FLAG_SELECTED;
+ grid_view_set_cell(gd, s->cx, s->cy, &tmp_gc);
+ } else if (!skip)
grid_view_set_cell(gd, s->cx, s->cy, gc);
/*
@@ -1009,11 +1020,6 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
tty_write(tty_cmd_insertcharacter, &ttyctx);
}
- /* Check if this is selected. */
- selected = screen_check_selection(s, s->cx - width, s->cy);
- if (selected)
- skip = 0;
-
/* Save last cell if it will be needed. */
if (!skip && ctx->wp != NULL && ttyctx.ocx > ctx->wp->sx - width)
screen_write_save_last(ctx, &ttyctx);