mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
c42087c789
@ -38,9 +38,10 @@ const struct cmd_entry cmd_display_menu_entry = {
|
||||
.name = "display-menu",
|
||||
.alias = "menu",
|
||||
|
||||
.args = { "c:t:OT:x:y:", 1, -1, cmd_display_menu_args_parse },
|
||||
.usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
|
||||
"[-x position] [-y position] name key command ...",
|
||||
.args = { "c:t:S:OT:x:y:", 1, -1, cmd_display_menu_args_parse },
|
||||
.usage = "[-O] [-c target-client] [-S starting-choice] "
|
||||
CMD_TARGET_PANE_USAGE " [-T title] [-x position] "
|
||||
"[-y position] name key command ...",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
|
||||
@ -287,13 +288,27 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct menu *menu = NULL;
|
||||
struct menu_item menu_item;
|
||||
const char *key, *name;
|
||||
char *title;
|
||||
int flags = 0;
|
||||
char *title, *cause;
|
||||
int flags = 0, starting_choice = 0;
|
||||
u_int px, py, i, count = args_count(args);
|
||||
|
||||
if (tc->overlay_draw != NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
if (args_has(args, 'S')) {
|
||||
if (strcmp(args_get(args, 'S'), "-") == 0)
|
||||
starting_choice = -1;
|
||||
else {
|
||||
starting_choice = args_strtonum(args, 'S', 0, UINT_MAX,
|
||||
&cause);
|
||||
if (cause != NULL) {
|
||||
cmdq_error(item, "starting choice %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args_has(args, 'T'))
|
||||
title = format_single_from_target(item, args_get(args, 'T'));
|
||||
else
|
||||
@ -340,8 +355,8 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
flags |= MENU_STAYOPEN;
|
||||
if (!event->m.valid)
|
||||
flags |= MENU_NOMOUSE;
|
||||
if (menu_display(menu, flags, item, px, py, tc, target, NULL,
|
||||
NULL) != 0)
|
||||
if (menu_display(menu, flags, starting_choice, item, px, py, tc, target,
|
||||
NULL, NULL) != 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
55
menu.c
55
menu.c
@ -427,12 +427,12 @@ chosen:
|
||||
}
|
||||
|
||||
struct menu_data *
|
||||
menu_prepare(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
|
||||
u_int py, struct client *c, struct cmd_find_state *fs, menu_choice_cb cb,
|
||||
void *data)
|
||||
menu_prepare(struct menu *menu, int flags, int starting_choice,
|
||||
struct cmdq_item *item, u_int px, u_int py, struct client *c,
|
||||
struct cmd_find_state *fs, menu_choice_cb cb, void *data)
|
||||
{
|
||||
struct menu_data *md;
|
||||
u_int i;
|
||||
int choice;
|
||||
const char *name;
|
||||
|
||||
if (c->tty.sx < menu->width + 4 || c->tty.sy < menu->count + 2)
|
||||
@ -457,18 +457,38 @@ menu_prepare(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
|
||||
md->py = py;
|
||||
|
||||
md->menu = menu;
|
||||
md->choice = -1;
|
||||
|
||||
if (md->flags & MENU_NOMOUSE) {
|
||||
for (i = 0; i < menu->count; i++) {
|
||||
name = menu->items[i].name;
|
||||
if (name != NULL && *name != '-')
|
||||
if (starting_choice >= (int)menu->count) {
|
||||
starting_choice = menu->count - 1;
|
||||
choice = starting_choice + 1;
|
||||
for (;;) {
|
||||
name = menu->items[choice - 1].name;
|
||||
if (name != NULL && *name != '-') {
|
||||
md->choice = choice - 1;
|
||||
break;
|
||||
}
|
||||
if (i != menu->count)
|
||||
md->choice = i;
|
||||
else
|
||||
md->choice = -1;
|
||||
} else
|
||||
md->choice = -1;
|
||||
if (--choice == 0)
|
||||
choice = menu->count;
|
||||
if (choice == starting_choice + 1)
|
||||
break;
|
||||
}
|
||||
} else if (starting_choice >= 0) {
|
||||
choice = starting_choice;
|
||||
for (;;) {
|
||||
name = menu->items[choice].name;
|
||||
if (name != NULL && *name != '-') {
|
||||
md->choice = choice;
|
||||
break;
|
||||
}
|
||||
if (++choice == (int)menu->count)
|
||||
choice = 0;
|
||||
if (choice == starting_choice)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
md->cb = cb;
|
||||
md->data = data;
|
||||
@ -476,13 +496,14 @@ menu_prepare(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
|
||||
}
|
||||
|
||||
int
|
||||
menu_display(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
|
||||
u_int py, struct client *c, struct cmd_find_state *fs, menu_choice_cb cb,
|
||||
void *data)
|
||||
menu_display(struct menu *menu, int flags, int starting_choice,
|
||||
struct cmdq_item *item, u_int px, u_int py, struct client *c,
|
||||
struct cmd_find_state *fs, menu_choice_cb cb, void *data)
|
||||
{
|
||||
struct menu_data *md;
|
||||
|
||||
md = menu_prepare(menu, flags, item, px, py, c, fs, cb, data);
|
||||
md = menu_prepare(menu, flags, starting_choice, item, px, py, c, fs, cb,
|
||||
data);
|
||||
if (md == NULL)
|
||||
return (-1);
|
||||
server_client_set_overlay(c, 0, NULL, menu_mode_cb, menu_draw_cb,
|
||||
|
@ -962,8 +962,8 @@ mode_tree_display_menu(struct mode_tree_data *mtd, struct client *c, u_int x,
|
||||
x -= (menu->width + 4) / 2;
|
||||
else
|
||||
x = 0;
|
||||
if (menu_display(menu, 0, NULL, x, y, c, NULL, mode_tree_menu_callback,
|
||||
mtm) != 0)
|
||||
if (menu_display(menu, 0, 0, NULL, x, y, c, NULL,
|
||||
mode_tree_menu_callback, mtm) != 0)
|
||||
menu_free(menu);
|
||||
}
|
||||
|
||||
|
2
popup.c
2
popup.c
@ -573,7 +573,7 @@ menu:
|
||||
x = m->x - (pd->menu->width + 4) / 2;
|
||||
else
|
||||
x = 0;
|
||||
pd->md = menu_prepare(pd->menu, 0, NULL, x, m->y, c, NULL,
|
||||
pd->md = menu_prepare(pd->menu, 0, 0, NULL, x, m->y, c, NULL,
|
||||
popup_menu_done, pd);
|
||||
c->flags |= CLIENT_REDRAWOVERLAY;
|
||||
|
||||
|
4
status.c
4
status.c
@ -1766,7 +1766,7 @@ status_prompt_complete_list_menu(struct client *c, char **list, u_int size,
|
||||
else
|
||||
offset = 0;
|
||||
|
||||
if (menu_display(menu, MENU_NOMOUSE|MENU_TAB, NULL, offset,
|
||||
if (menu_display(menu, MENU_NOMOUSE|MENU_TAB, 0, NULL, offset,
|
||||
py, c, NULL, status_prompt_menu_callback, spm) != 0) {
|
||||
menu_free(menu);
|
||||
free(spm);
|
||||
@ -1859,7 +1859,7 @@ status_prompt_complete_window_menu(struct client *c, struct session *s,
|
||||
else
|
||||
offset = 0;
|
||||
|
||||
if (menu_display(menu, MENU_NOMOUSE|MENU_TAB, NULL, offset,
|
||||
if (menu_display(menu, MENU_NOMOUSE|MENU_TAB, 0, NULL, offset,
|
||||
py, c, NULL, status_prompt_menu_callback, spm) != 0) {
|
||||
menu_free(menu);
|
||||
free(spm);
|
||||
|
4
tmux.1
4
tmux.1
@ -5818,6 +5818,7 @@ until it is dismissed.
|
||||
.Op Fl O
|
||||
.Op Fl c Ar target-client
|
||||
.Op Fl t Ar target-pane
|
||||
.Op Fl S Ar starting-choice
|
||||
.Op Fl T Ar title
|
||||
.Op Fl x Ar position
|
||||
.Op Fl y Ar position
|
||||
@ -5847,6 +5848,9 @@ command should be omitted.
|
||||
.Fl T
|
||||
is a format for the menu title (see
|
||||
.Sx FORMATS ) .
|
||||
.Fl S
|
||||
sets the menu item selected by default, if the menu is not bound to a mouse key
|
||||
binding.
|
||||
.Pp
|
||||
.Fl x
|
||||
and
|
||||
|
8
tmux.h
8
tmux.h
@ -3295,11 +3295,11 @@ void menu_add_item(struct menu *, const struct menu_item *,
|
||||
struct cmdq_item *, struct client *,
|
||||
struct cmd_find_state *);
|
||||
void menu_free(struct menu *);
|
||||
struct menu_data *menu_prepare(struct menu *, int, struct cmdq_item *, u_int,
|
||||
u_int, struct client *, struct cmd_find_state *,
|
||||
struct menu_data *menu_prepare(struct menu *, int, int, struct cmdq_item *,
|
||||
u_int, u_int, struct client *, struct cmd_find_state *,
|
||||
menu_choice_cb, void *);
|
||||
int menu_display(struct menu *, int, struct cmdq_item *, u_int,
|
||||
u_int, struct client *, struct cmd_find_state *,
|
||||
int menu_display(struct menu *, int, int, struct cmdq_item *,
|
||||
u_int, u_int, struct client *, struct cmd_find_state *,
|
||||
menu_choice_cb, void *);
|
||||
struct screen *menu_mode_cb(struct client *, void *, u_int *, u_int *);
|
||||
void menu_check_cb(struct client *, void *, u_int, u_int, u_int,
|
||||
|
Loading…
Reference in New Issue
Block a user