diff options
author | nicm <nicm> | 2016-11-24 13:38:44 +0000 |
---|---|---|
committer | nicm <nicm> | 2016-11-24 13:38:44 +0000 |
commit | 7e6c2cb23868fbfec11adacdc5da7e670a9b8bdb (patch) | |
tree | 8434375eb7b93316b239160a312fa77392bfa80d /screen.c | |
parent | 6de466cf8b665d8725301307c57f6d8cb2e65a3f (diff) |
Make the selection able to exist independent of the cursor position, so
that it is not affected by scrolling. If MouseDragEnd1Pane is bound to
the new "stop-selection" command:
bind -Tcopy-mode MouseDragEnd1Pane stop-selection
A selection made with the mouse will stay as it is after button 1 is
released. (It also works bound to a key.)
From Artem Fokin.
Diffstat (limited to 'screen.c')
-rw-r--r-- | screen.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -258,6 +258,8 @@ screen_set_selection(struct screen *s, u_int sx, u_int sy, memcpy(&sel->cell, gc, sizeof sel->cell); sel->flag = 1; + sel->hidden = 0; + sel->rectflag = rectflag; sel->sx = sx; sel->sy = sy; @@ -271,9 +273,19 @@ screen_clear_selection(struct screen *s) struct screen_sel *sel = &s->sel; sel->flag = 0; + sel->hidden = 0; sel->lineflag = LINE_SEL_NONE; } +/* Hide selection. */ +void +screen_hide_selection(struct screen *s) +{ + struct screen_sel *sel = &s->sel; + + sel->hidden = 1; +} + /* Check if cell in selection. */ int screen_check_selection(struct screen *s, u_int px, u_int py) @@ -281,7 +293,7 @@ screen_check_selection(struct screen *s, u_int px, u_int py) struct screen_sel *sel = &s->sel; u_int xx; - if (!sel->flag) + if (!sel->flag || sel->hidden) return (0); if (sel->rectflag) { @@ -377,7 +389,7 @@ void screen_select_cell(struct screen *s, struct grid_cell *dst, const struct grid_cell *src) { - if (!s->sel.flag) + if (!s->sel.flag || s->sel.hidden) return; memcpy(dst, &s->sel.cell, sizeof *dst); |