diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index f2f4b2e3..a1167af8 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -33,7 +33,7 @@ const struct cmd_entry cmd_choose_tree_entry = { .name = "choose-tree", .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] " "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", @@ -47,7 +47,7 @@ const struct cmd_entry cmd_choose_client_entry = { .name = "choose-client", .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] " "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", @@ -61,7 +61,7 @@ const struct cmd_entry cmd_choose_buffer_entry = { .name = "choose-buffer", .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] " "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", @@ -75,7 +75,7 @@ const struct cmd_entry cmd_customize_mode_entry = { .name = "customize-mode", .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, .target = { 't', CMD_FIND_PANE, 0 }, diff --git a/status.c b/status.c index e24c64cf..d4a25aeb 100644 --- a/status.c +++ b/status.c @@ -598,6 +598,19 @@ status_message_redraw(struct client *c) 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. */ void 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); format_free(ft); + + if ((flags & PROMPT_SINGLE) && (flags & PROMPT_ACCEPT)) + cmdq_append(c, cmdq_get_callback(status_prompt_accept, c)); } /* Remove status line prompt. */ diff --git a/tmux.1 b/tmux.1 index 97eb2deb..17b4f156 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2583,7 +2583,7 @@ the end of the visible pane. The default is to capture only the visible contents of the pane. .It Xo .Ic choose-client -.Op Fl NrZ +.Op Fl NryZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl K Ar key-format @@ -2599,6 +2599,8 @@ or the list may be navigated and an item chosen or otherwise manipulated using the keys below. .Fl Z zooms the pane. +.Fl y +disables any confirmation prompts. The following keys may be used in client mode: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" @@ -2657,7 +2659,7 @@ starts without the preview or if given twice with the larger preview. This command works only if at least one client is attached. .It Xo .Ic choose-tree -.Op Fl GNrswZ +.Op Fl GNrswyZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl K Ar key-format @@ -2677,6 +2679,8 @@ starts with sessions collapsed and with windows collapsed. .Fl Z zooms the pane. +.Fl y +disables any confirmation prompts. The following keys may be used in tree mode: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" @@ -6809,7 +6813,7 @@ The buffer commands are as follows: .Bl -tag -width Ds .It Xo .Ic choose-buffer -.Op Fl NZr +.Op Fl NryZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl K Ar key-format @@ -6825,6 +6829,8 @@ or the list may be navigated and an item chosen or otherwise manipulated using the keys below. .Fl Z zooms the pane. +.Fl y +disables any confirmation prompts. The following keys may be used in buffer mode: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" diff --git a/tmux.h b/tmux.h index 9ea71e10..b7bb03c9 100644 --- a/tmux.h +++ b/tmux.h @@ -1969,6 +1969,7 @@ struct client { #define PROMPT_INCREMENTAL 0x4 #define PROMPT_NOFORMAT 0x8 #define PROMPT_KEY 0x10 +#define PROMPT_ACCEPT 0x20 int prompt_flags; enum prompt_type prompt_type; int prompt_cursor; diff --git a/window-customize.c b/window-customize.c index 4a16e90c..387254e0 100644 --- a/window-customize.c +++ b/window-customize.c @@ -101,6 +101,7 @@ struct window_customize_modedata { struct mode_tree_data *data; char *format; int hide_global; + int prompt_flags; struct window_customize_itemdata **item_list; 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); else 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, 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, "", window_customize_change_current_callback, window_customize_free_callback, data, - PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND); + PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags, + PROMPT_TYPE_COMMAND); free(prompt); break; case 'D': @@ -1466,7 +1470,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c, status_prompt_set(c, NULL, prompt, "", window_customize_change_tagged_callback, window_customize_free_callback, data, - PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND); + PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags, + PROMPT_TYPE_COMMAND); free(prompt); break; case 'u': @@ -1482,7 +1487,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c, status_prompt_set(c, NULL, prompt, "", window_customize_change_current_callback, window_customize_free_callback, data, - PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND); + PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags, + PROMPT_TYPE_COMMAND); free(prompt); break; case 'U': @@ -1495,7 +1501,8 @@ window_customize_key(struct window_mode_entry *wme, struct client *c, status_prompt_set(c, NULL, prompt, "", window_customize_change_tagged_callback, window_customize_free_callback, data, - PROMPT_SINGLE|PROMPT_NOFORMAT, PROMPT_TYPE_COMMAND); + PROMPT_SINGLE|PROMPT_NOFORMAT|data->prompt_flags, + PROMPT_TYPE_COMMAND); free(prompt); break; case 'H': diff --git a/window-tree.c b/window-tree.c index b2f397f5..07d2bc2e 100644 --- a/window-tree.c +++ b/window-tree.c @@ -131,6 +131,7 @@ struct window_tree_modedata { char *key_format; char *command; int squash_groups; + int prompt_flags; struct window_tree_itemdata **item_list; u_int item_size; @@ -934,6 +935,8 @@ window_tree_init(struct window_mode_entry *wme, struct cmd_find_state *fs, else data->command = xstrdup(args_string(args, 0)); 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, window_tree_draw, window_tree_search, window_tree_menu, NULL, @@ -1305,7 +1308,8 @@ again: data->references++; status_prompt_set(c, NULL, prompt, "", 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); break; case 'X': @@ -1316,7 +1320,8 @@ again: data->references++; status_prompt_set(c, NULL, prompt, "", 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); break; case ':':