summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-display-menu.c8
-rw-r--r--usr.bin/tmux/menu.c24
-rw-r--r--usr.bin/tmux/server-client.c4
-rw-r--r--usr.bin/tmux/tmux.115
-rw-r--r--usr.bin/tmux/tmux.h3
5 files changed, 39 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-display-menu.c b/usr.bin/tmux/cmd-display-menu.c
index e97537cf5d2..c6b8938f557 100644
--- a/usr.bin/tmux/cmd-display-menu.c
+++ b/usr.bin/tmux/cmd-display-menu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-display-menu.c,v 1.19 2020/05/16 15:24:28 nicm Exp $ */
+/* $OpenBSD: cmd-display-menu.c,v 1.20 2020/10/30 08:55:56 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -36,8 +36,8 @@ const struct cmd_entry cmd_display_menu_entry = {
.name = "display-menu",
.alias = "menu",
- .args = { "c:t:T:x:y:", 1, -1 },
- .usage = "[-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
+ .args = { "c:t:OT:x:y:", 1, -1 },
+ .usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
"[-x position] [-y position] name key command ...",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -229,6 +229,8 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
cmd_display_menu_get_position(tc, item, args, &px, &py, menu->width + 4,
menu->count + 2);
+ if (args_has(args, 'O'))
+ flags |= MENU_STAYOPEN;
if (!event->m.valid)
flags |= MENU_NOMOUSE;
if (menu_display(menu, flags, item, px, py, tc, target, NULL,
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) {
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 75bb0e50c87..25df84ab807 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.362 2020/10/28 10:09:10 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.363 2020/10/30 08:55:56 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1693,8 +1693,8 @@ server_client_reset_state(struct client *c)
* mode.
*/
if (options_get_number(oo, "mouse")) {
- mode &= ~ALL_MOUSE_MODES;
if (c->overlay_draw == NULL) {
+ mode &= ~ALL_MOUSE_MODES;
TAILQ_FOREACH(loop, &w->panes, entry) {
if (loop->screen->mode & MODE_MOUSE_ALL)
mode |= MODE_MOUSE_ALL;
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index b437dad4303..ad87a0b6102 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.799 2020/10/09 19:12:36 tim Exp $
+.\" $OpenBSD: tmux.1,v 1.800 2020/10/30 08:55:56 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 9 2020 $
+.Dd $Mdocdate: October 30 2020 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -5331,6 +5331,7 @@ option.
This command works only from inside
.Nm .
.It Xo Ic display-menu
+.Op Fl O
.Op Fl c Ar target-client
.Op Fl t Ar target-pane
.Op Fl T Ar title
@@ -5382,8 +5383,14 @@ Both may be a row or column number, or one of the following special values:
Each menu consists of items followed by a key shortcut shown in brackets.
If the menu is too large to fit on the terminal, it is not displayed.
Pressing the key shortcut chooses the corresponding item.
-If the mouse is enabled and the menu is opened from a mouse key binding, releasing
-the mouse button with an item selected will choose that item.
+If the mouse is enabled and the menu is opened from a mouse key binding,
+releasing the mouse button with an item selected chooses that item and
+releasing the mouse button without an item selected closes the menu.
+.Fl O
+changes this behaviour so that the menu does not close when the mouse button is
+released without an item selected the menu is not closed and a mouse button
+must be clicked to choose an item.
+.Pp
The following keys are also available:
.Bl -column "Key" "Function" -offset indent
.It Sy "Key" Ta Sy "Function"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 3f405b28737..36d85223f3d 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1079 2020/10/05 09:53:01 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1080 2020/10/30 08:55:56 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2978,6 +2978,7 @@ __dead void printflike(1, 2) fatalx(const char *, ...);
/* menu.c */
#define MENU_NOMOUSE 0x1
#define MENU_TAB 0x2
+#define MENU_STAYOPEN 0x4
struct menu *menu_create(const char *);
void menu_add_items(struct menu *, const struct menu_item *,
struct cmdq_item *, struct client *,