mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Add -y flag to disable confirmation prompts in modes, GitHub issue 4152.
This commit is contained in:
parent
34775fc235
commit
5a68730e2f
@ -33,7 +33,7 @@ const struct cmd_entry cmd_choose_tree_entry = {
|
|||||||
.name = "choose-tree",
|
.name = "choose-tree",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:f:GK:NO:rst:wZ", 0, 1, cmd_choose_tree_args_parse },
|
.args = { "F:f:GK:NO:rst:wyZ", 0, 1, cmd_choose_tree_args_parse },
|
||||||
.usage = "[-GNrswZ] [-F format] [-f filter] [-K key-format] "
|
.usage = "[-GNrswZ] [-F format] [-f filter] [-K key-format] "
|
||||||
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ const struct cmd_entry cmd_choose_client_entry = {
|
|||||||
.name = "choose-client",
|
.name = "choose-client",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:f:K:NO:rt:Z", 0, 1, cmd_choose_tree_args_parse },
|
.args = { "F:f:K:NO:rt:yZ", 0, 1, cmd_choose_tree_args_parse },
|
||||||
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
||||||
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ const struct cmd_entry cmd_choose_buffer_entry = {
|
|||||||
.name = "choose-buffer",
|
.name = "choose-buffer",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:f:K:NO:rt:Z", 0, 1, cmd_choose_tree_args_parse },
|
.args = { "F:f:K:NO:rt:yZ", 0, 1, cmd_choose_tree_args_parse },
|
||||||
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
.usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
|
||||||
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
"[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]",
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ const struct cmd_entry cmd_customize_mode_entry = {
|
|||||||
.name = "customize-mode",
|
.name = "customize-mode",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:f:Nt:Z", 0, 0, NULL },
|
.args = { "F:f:Nt:yZ", 0, 0, NULL },
|
||||||
.usage = "[-NZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
|
.usage = "[-NZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
16
status.c
16
status.c
@ -598,6 +598,19 @@ status_message_redraw(struct client *c)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Accept prompt immediately. */
|
||||||
|
static enum cmd_retval
|
||||||
|
status_prompt_accept(__unused struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
struct client *c = data;
|
||||||
|
|
||||||
|
if (c->prompt_string != NULL) {
|
||||||
|
c->prompt_inputcb(c, c->prompt_data, "y", 1);
|
||||||
|
status_prompt_clear(c);
|
||||||
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable status line prompt. */
|
/* Enable status line prompt. */
|
||||||
void
|
void
|
||||||
status_prompt_set(struct client *c, struct cmd_find_state *fs,
|
status_prompt_set(struct client *c, struct cmd_find_state *fs,
|
||||||
@ -655,6 +668,9 @@ status_prompt_set(struct client *c, struct cmd_find_state *fs,
|
|||||||
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
|
if ((flags & PROMPT_SINGLE) && (flags & PROMPT_ACCEPT))
|
||||||
|
cmdq_append(c, cmdq_get_callback(status_prompt_accept, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove status line prompt. */
|
/* Remove status line prompt. */
|
||||||
|
12
tmux.1
12
tmux.1
@ -2581,7 +2581,7 @@ the end of the visible pane.
|
|||||||
The default is to capture only the visible contents of the pane.
|
The default is to capture only the visible contents of the pane.
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic choose-client
|
.Ic choose-client
|
||||||
.Op Fl NrZ
|
.Op Fl NryZ
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
.Op Fl f Ar filter
|
.Op Fl f Ar filter
|
||||||
.Op Fl K Ar key-format
|
.Op Fl K Ar key-format
|
||||||
@ -2597,6 +2597,8 @@ or the list may be navigated and an item chosen or otherwise manipulated using
|
|||||||
the keys below.
|
the keys below.
|
||||||
.Fl Z
|
.Fl Z
|
||||||
zooms the pane.
|
zooms the pane.
|
||||||
|
.Fl y
|
||||||
|
disables any confirmation prompts.
|
||||||
The following keys may be used in client mode:
|
The following keys may be used in client mode:
|
||||||
.Bl -column "Key" "Function" -offset indent
|
.Bl -column "Key" "Function" -offset indent
|
||||||
.It Sy "Key" Ta Sy "Function"
|
.It Sy "Key" Ta Sy "Function"
|
||||||
@ -2655,7 +2657,7 @@ starts without the preview or if given twice with the larger preview.
|
|||||||
This command works only if at least one client is attached.
|
This command works only if at least one client is attached.
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic choose-tree
|
.Ic choose-tree
|
||||||
.Op Fl GNrswZ
|
.Op Fl GNrswyZ
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
.Op Fl f Ar filter
|
.Op Fl f Ar filter
|
||||||
.Op Fl K Ar key-format
|
.Op Fl K Ar key-format
|
||||||
@ -2675,6 +2677,8 @@ starts with sessions collapsed and
|
|||||||
with windows collapsed.
|
with windows collapsed.
|
||||||
.Fl Z
|
.Fl Z
|
||||||
zooms the pane.
|
zooms the pane.
|
||||||
|
.Fl y
|
||||||
|
disables any confirmation prompts.
|
||||||
The following keys may be used in tree mode:
|
The following keys may be used in tree mode:
|
||||||
.Bl -column "Key" "Function" -offset indent
|
.Bl -column "Key" "Function" -offset indent
|
||||||
.It Sy "Key" Ta Sy "Function"
|
.It Sy "Key" Ta Sy "Function"
|
||||||
@ -6807,7 +6811,7 @@ The buffer commands are as follows:
|
|||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic choose-buffer
|
.Ic choose-buffer
|
||||||
.Op Fl NZr
|
.Op Fl NryZ
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
.Op Fl f Ar filter
|
.Op Fl f Ar filter
|
||||||
.Op Fl K Ar key-format
|
.Op Fl K Ar key-format
|
||||||
@ -6823,6 +6827,8 @@ or the list may be navigated and an item chosen or otherwise manipulated using
|
|||||||
the keys below.
|
the keys below.
|
||||||
.Fl Z
|
.Fl Z
|
||||||
zooms the pane.
|
zooms the pane.
|
||||||
|
.Fl y
|
||||||
|
disables any confirmation prompts.
|
||||||
The following keys may be used in buffer mode:
|
The following keys may be used in buffer mode:
|
||||||
.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
@ -1935,6 +1935,7 @@ struct client {
|
|||||||
#define PROMPT_INCREMENTAL 0x4
|
#define PROMPT_INCREMENTAL 0x4
|
||||||
#define PROMPT_NOFORMAT 0x8
|
#define PROMPT_NOFORMAT 0x8
|
||||||
#define PROMPT_KEY 0x10
|
#define PROMPT_KEY 0x10
|
||||||
|
#define PROMPT_ACCEPT 0x20
|
||||||
int prompt_flags;
|
int prompt_flags;
|
||||||
enum prompt_type prompt_type;
|
enum prompt_type prompt_type;
|
||||||
int prompt_cursor;
|
int prompt_cursor;
|
||||||
|
@ -101,6 +101,7 @@ struct window_customize_modedata {
|
|||||||
struct mode_tree_data *data;
|
struct mode_tree_data *data;
|
||||||
char *format;
|
char *format;
|
||||||
int hide_global;
|
int hide_global;
|
||||||
|
int prompt_flags;
|
||||||
|
|
||||||
struct window_customize_itemdata **item_list;
|
struct window_customize_itemdata **item_list;
|
||||||
u_int item_size;
|
u_int item_size;
|
||||||
@ -885,6 +886,8 @@ window_customize_init(struct window_mode_entry *wme, struct cmd_find_state *fs,
|
|||||||
data->format = xstrdup(WINDOW_CUSTOMIZE_DEFAULT_FORMAT);
|
data->format = xstrdup(WINDOW_CUSTOMIZE_DEFAULT_FORMAT);
|
||||||
else
|
else
|
||||||
data->format = xstrdup(args_get(args, 'F'));
|
data->format = xstrdup(args_get(args, 'F'));
|
||||||
|
if (args_has(args, 'y'))
|
||||||
|
data->prompt_flags = PROMPT_ACCEPT;
|
||||||
|
|
||||||
data->data = mode_tree_start(wp, args, window_customize_build,
|
data->data = mode_tree_start(wp, args, window_customize_build,
|
||||||
window_customize_draw, NULL, window_customize_menu,
|
window_customize_draw, NULL, window_customize_menu,
|
||||||
@ -1453,7 +1456,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c,
|
|||||||
status_prompt_set(c, NULL, prompt, "",
|
status_prompt_set(c, NULL, prompt, "",
|
||||||
window_customize_change_current_callback,
|
window_customize_change_current_callback,
|
||||||
window_customize_free_callback, data,
|
window_customize_free_callback, data,
|
||||||
PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND);
|
PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags,
|
||||||
|
PROMPT_TYPE_COMMAND);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
@ -1466,7 +1470,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c,
|
|||||||
status_prompt_set(c, NULL, prompt, "",
|
status_prompt_set(c, NULL, prompt, "",
|
||||||
window_customize_change_tagged_callback,
|
window_customize_change_tagged_callback,
|
||||||
window_customize_free_callback, data,
|
window_customize_free_callback, data,
|
||||||
PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND);
|
PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags,
|
||||||
|
PROMPT_TYPE_COMMAND);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
@ -1482,7 +1487,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c,
|
|||||||
status_prompt_set(c, NULL, prompt, "",
|
status_prompt_set(c, NULL, prompt, "",
|
||||||
window_customize_change_current_callback,
|
window_customize_change_current_callback,
|
||||||
window_customize_free_callback, data,
|
window_customize_free_callback, data,
|
||||||
PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND);
|
PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags,
|
||||||
|
PROMPT_TYPE_COMMAND);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
@ -1495,7 +1501,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c,
|
|||||||
status_prompt_set(c, NULL, prompt, "",
|
status_prompt_set(c, NULL, prompt, "",
|
||||||
window_customize_change_tagged_callback,
|
window_customize_change_tagged_callback,
|
||||||
window_customize_free_callback, data,
|
window_customize_free_callback, data,
|
||||||
PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND);
|
PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags,
|
||||||
|
PROMPT_TYPE_COMMAND);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
|
@ -131,6 +131,7 @@ struct window_tree_modedata {
|
|||||||
char *key_format;
|
char *key_format;
|
||||||
char *command;
|
char *command;
|
||||||
int squash_groups;
|
int squash_groups;
|
||||||
|
int prompt_flags;
|
||||||
|
|
||||||
struct window_tree_itemdata **item_list;
|
struct window_tree_itemdata **item_list;
|
||||||
u_int item_size;
|
u_int item_size;
|
||||||
@ -934,6 +935,8 @@ window_tree_init(struct window_mode_entry *wme, struct cmd_find_state *fs,
|
|||||||
else
|
else
|
||||||
data->command = xstrdup(args_string(args, 0));
|
data->command = xstrdup(args_string(args, 0));
|
||||||
data->squash_groups = !args_has(args, 'G');
|
data->squash_groups = !args_has(args, 'G');
|
||||||
|
if (args_has(args, 'y'))
|
||||||
|
data->prompt_flags = PROMPT_ACCEPT;
|
||||||
|
|
||||||
data->data = mode_tree_start(wp, args, window_tree_build,
|
data->data = mode_tree_start(wp, args, window_tree_build,
|
||||||
window_tree_draw, window_tree_search, window_tree_menu, NULL,
|
window_tree_draw, window_tree_search, window_tree_menu, NULL,
|
||||||
@ -1305,7 +1308,8 @@ again:
|
|||||||
data->references++;
|
data->references++;
|
||||||
status_prompt_set(c, NULL, prompt, "",
|
status_prompt_set(c, NULL, prompt, "",
|
||||||
window_tree_kill_current_callback, window_tree_command_free,
|
window_tree_kill_current_callback, window_tree_command_free,
|
||||||
data, PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND);
|
data, PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags,
|
||||||
|
PROMPT_TYPE_COMMAND);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
@ -1316,7 +1320,8 @@ again:
|
|||||||
data->references++;
|
data->references++;
|
||||||
status_prompt_set(c, NULL, prompt, "",
|
status_prompt_set(c, NULL, prompt, "",
|
||||||
window_tree_kill_tagged_callback, window_tree_command_free,
|
window_tree_kill_tagged_callback, window_tree_command_free,
|
||||||
data, PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND);
|
data, PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags,
|
||||||
|
PROMPT_TYPE_COMMAND);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
|
Loading…
Reference in New Issue
Block a user