From 7e6c2cb23868fbfec11adacdc5da7e670a9b8bdb Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 24 Nov 2016 13:38:44 +0000 Subject: 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. --- screen.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'screen.c') diff --git a/screen.c b/screen.c index bf342c45..d6fbfecd 100644 --- a/screen.c +++ b/screen.c @@ -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); -- cgit