summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-06-06 07:28:53 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-06-06 07:28:53 +0000
commit345e063b98c2e7b85394933f6a5439a006d39f09 (patch)
tree05f4c456f0615a8380245574a80c413261aacc27 /usr.bin/tmux
parenteaf4f1145ebb5a15726cd56432c5eb5aa8d2b070 (diff)
Cache selected state so that cells going from selected to unselected are not
skipped, reported by Omar Sandoval.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/screen-write.c22
-rw-r--r--usr.bin/tmux/tmux.h3
2 files changed, 16 insertions, 9 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index ab4778a2fe3..aeade98f0fa 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.89 2016/05/30 09:32:24 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.90 2016/06/06 07:28:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index fd7f4ab2f08..7b1fda71041 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.633 2016/06/06 07:24:31 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.634 2016/06/06 07:28:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -642,6 +642,7 @@ enum utf8_state {
#define GRID_FLAG_EXTENDED 0x8
#define GRID_FLAG_FGRGB 0x10
#define GRID_FLAG_BGRGB 0x20
+#define GRID_FLAG_SELECTED 0x40
/* Grid line flags. */
#define GRID_LINE_WRAPPED 0x1