summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/menu.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-10-30 08:55:57 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-10-30 08:55:57 +0000
commit70a2538f1ca1bf983159464852e908260334a55c (patch)
tree8e6ca03b35480d171c3cd8692cfad7e0d98db117 /usr.bin/tmux/menu.c
parente00e63f1d27620bf25bd3b573be80b842222432c (diff)
Add a -O flag to display-menu to change the mouse behaviour and not
close the menu when the mouse is released, from teo_paul1 at yahoo dot com.
Diffstat (limited to 'usr.bin/tmux/menu.c')
-rw-r--r--usr.bin/tmux/menu.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/tmux/menu.c b/usr.bin/tmux/menu.c
index d6b7cb4e038..2d685fc16be 100644
--- a/usr.bin/tmux/menu.c
+++ b/usr.bin/tmux/menu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: menu.c,v 1.31 2020/09/16 18:37:55 nicm Exp $ */
+/* $OpenBSD: menu.c,v 1.32 2020/10/30 08:55:56 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -203,16 +203,28 @@ menu_key_cb(struct client *c, struct key_event *event)
m->x > md->px + 4 + menu->width ||
m->y < md->py + 1 ||
m->y > md->py + 1 + count - 1) {
- if (MOUSE_RELEASE(m->b))
- return (1);
+ if (~md->flags & MENU_STAYOPEN) {
+ if (MOUSE_RELEASE(m->b))
+ return (1);
+ } else {
+ if (!MOUSE_RELEASE(m->b) &&
+ MOUSE_WHEEL(m->b) == 0 &&
+ !MOUSE_DRAG(m->b))
+ return (1);
+ }
if (md->choice != -1) {
md->choice = -1;
c->flags |= CLIENT_REDRAWOVERLAY;
}
return (0);
}
- if (MOUSE_RELEASE(m->b))
- goto chosen;
+ if (~md->flags & MENU_STAYOPEN) {
+ if (MOUSE_RELEASE(m->b))
+ goto chosen;
+ } else {
+ if (MOUSE_WHEEL(m->b) == 0 && !MOUSE_DRAG(m->b))
+ goto chosen;
+ }
md->choice = m->y - (md->py + 1);
if (md->choice != old)
c->flags |= CLIENT_REDRAWOVERLAY;
@@ -303,6 +315,8 @@ chosen:
if (md->choice == -1)
return (1);
item = &menu->items[md->choice];
+ if ((md->flags & MENU_STAYOPEN) && item->name == NULL)
+ return (0);
if (item->name == NULL || *item->name == '-')
return (1);
if (md->cb != NULL) {