mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
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.
This commit is contained in:
parent
a868bacb46
commit
649e5970e9
@ -36,8 +36,8 @@ const struct cmd_entry cmd_display_menu_entry = {
|
|||||||
.name = "display-menu",
|
.name = "display-menu",
|
||||||
.alias = "menu",
|
.alias = "menu",
|
||||||
|
|
||||||
.args = { "c:t:T:x:y:", 1, -1 },
|
.args = { "c:t:OT:x:y:", 1, -1 },
|
||||||
.usage = "[-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
|
.usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
|
||||||
"[-x position] [-y position] name key command ...",
|
"[-x position] [-y position] name key command ...",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.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,
|
cmd_display_menu_get_position(tc, item, args, &px, &py, menu->width + 4,
|
||||||
menu->count + 2);
|
menu->count + 2);
|
||||||
|
|
||||||
|
if (args_has(args, 'O'))
|
||||||
|
flags |= MENU_STAYOPEN;
|
||||||
if (!event->m.valid)
|
if (!event->m.valid)
|
||||||
flags |= MENU_NOMOUSE;
|
flags |= MENU_NOMOUSE;
|
||||||
if (menu_display(menu, flags, item, px, py, tc, target, NULL,
|
if (menu_display(menu, flags, item, px, py, tc, target, NULL,
|
||||||
|
22
menu.c
22
menu.c
@ -203,16 +203,28 @@ menu_key_cb(struct client *c, struct key_event *event)
|
|||||||
m->x > md->px + 4 + menu->width ||
|
m->x > md->px + 4 + menu->width ||
|
||||||
m->y < md->py + 1 ||
|
m->y < md->py + 1 ||
|
||||||
m->y > md->py + 1 + count - 1) {
|
m->y > md->py + 1 + count - 1) {
|
||||||
if (MOUSE_RELEASE(m->b))
|
if (~md->flags & MENU_STAYOPEN) {
|
||||||
return (1);
|
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) {
|
if (md->choice != -1) {
|
||||||
md->choice = -1;
|
md->choice = -1;
|
||||||
c->flags |= CLIENT_REDRAWOVERLAY;
|
c->flags |= CLIENT_REDRAWOVERLAY;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (MOUSE_RELEASE(m->b))
|
if (~md->flags & MENU_STAYOPEN) {
|
||||||
goto chosen;
|
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);
|
md->choice = m->y - (md->py + 1);
|
||||||
if (md->choice != old)
|
if (md->choice != old)
|
||||||
c->flags |= CLIENT_REDRAWOVERLAY;
|
c->flags |= CLIENT_REDRAWOVERLAY;
|
||||||
@ -303,6 +315,8 @@ chosen:
|
|||||||
if (md->choice == -1)
|
if (md->choice == -1)
|
||||||
return (1);
|
return (1);
|
||||||
item = &menu->items[md->choice];
|
item = &menu->items[md->choice];
|
||||||
|
if ((md->flags & MENU_STAYOPEN) && item->name == NULL)
|
||||||
|
return (0);
|
||||||
if (item->name == NULL || *item->name == '-')
|
if (item->name == NULL || *item->name == '-')
|
||||||
return (1);
|
return (1);
|
||||||
if (md->cb != NULL) {
|
if (md->cb != NULL) {
|
||||||
|
@ -1693,8 +1693,8 @@ server_client_reset_state(struct client *c)
|
|||||||
* mode.
|
* mode.
|
||||||
*/
|
*/
|
||||||
if (options_get_number(oo, "mouse")) {
|
if (options_get_number(oo, "mouse")) {
|
||||||
mode &= ~ALL_MOUSE_MODES;
|
|
||||||
if (c->overlay_draw == NULL) {
|
if (c->overlay_draw == NULL) {
|
||||||
|
mode &= ~ALL_MOUSE_MODES;
|
||||||
TAILQ_FOREACH(loop, &w->panes, entry) {
|
TAILQ_FOREACH(loop, &w->panes, entry) {
|
||||||
if (loop->screen->mode & MODE_MOUSE_ALL)
|
if (loop->screen->mode & MODE_MOUSE_ALL)
|
||||||
mode |= MODE_MOUSE_ALL;
|
mode |= MODE_MOUSE_ALL;
|
||||||
|
11
tmux.1
11
tmux.1
@ -5331,6 +5331,7 @@ option.
|
|||||||
This command works only from inside
|
This command works only from inside
|
||||||
.Nm .
|
.Nm .
|
||||||
.It Xo Ic display-menu
|
.It Xo Ic display-menu
|
||||||
|
.Op Fl O
|
||||||
.Op Fl c Ar target-client
|
.Op Fl c Ar target-client
|
||||||
.Op Fl t Ar target-pane
|
.Op Fl t Ar target-pane
|
||||||
.Op Fl T Ar title
|
.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.
|
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.
|
If the menu is too large to fit on the terminal, it is not displayed.
|
||||||
Pressing the key shortcut chooses the corresponding item.
|
Pressing the key shortcut chooses the corresponding item.
|
||||||
If the mouse is enabled and the menu is opened from a mouse key binding, releasing
|
If the mouse is enabled and the menu is opened from a mouse key binding,
|
||||||
the mouse button with an item selected will choose that item.
|
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:
|
The following keys are also available:
|
||||||
.Bl -column "Key" "Function" -offset indent
|
.Bl -column "Key" "Function" -offset indent
|
||||||
.It Sy "Key" Ta Sy "Function"
|
.It Sy "Key" Ta Sy "Function"
|
||||||
|
1
tmux.h
1
tmux.h
@ -2978,6 +2978,7 @@ __dead void printflike(1, 2) fatalx(const char *, ...);
|
|||||||
/* menu.c */
|
/* menu.c */
|
||||||
#define MENU_NOMOUSE 0x1
|
#define MENU_NOMOUSE 0x1
|
||||||
#define MENU_TAB 0x2
|
#define MENU_TAB 0x2
|
||||||
|
#define MENU_STAYOPEN 0x4
|
||||||
struct menu *menu_create(const char *);
|
struct menu *menu_create(const char *);
|
||||||
void menu_add_items(struct menu *, const struct menu_item *,
|
void menu_add_items(struct menu *, const struct menu_item *,
|
||||||
struct cmdq_item *, struct client *,
|
struct cmdq_item *, struct client *,
|
||||||
|
Loading…
Reference in New Issue
Block a user