Per NicM's suggestions this patch: * Reimplements -F for choose-{window,session}, and makes the old syntax the default, which means configs won't have to change.
* -s and -w to choose-tree are now the session/window flags. -SW are for formatting. * No more ACS drawing, the tree is rendered in ASCII. --- trunk/cmd-choose-tree.c | 91 +++++++++++++++++++++++++++++++---------------- trunk/tmux.1 | 16 ++++----- 2 files changed, 69 insertions(+), 38 deletions(-) diff --git a/trunk/cmd-choose-tree.c b/trunk/cmd-choose-tree.c index 5de71d5..b1b6489 100644 --- a/trunk/cmd-choose-tree.c +++ b/trunk/cmd-choose-tree.c @@ -24,6 +24,10 @@ #include "tmux.h" +#define DEFAULT_WIN_ACTION "select-window -t '%%'" +#define DEFAULT_SES_ACTION "switch-client -t '%%'" +#define DEFAULT_WIN_TEMPLATE DEFAULT_WINDOW_TEMPLATE " \"#{pane_title}\"" + /* * Enter choice mode to choose a session and/or window. */ @@ -35,7 +39,7 @@ void cmd_choose_tree_free(struct window_choose_data *); const struct cmd_entry cmd_choose_tree_entry = { "choose-tree", NULL, - "SWs:w:b:c:t:", 0, 1, + "S:W:swb:c:t:", 0, 1, "[-S] [-W] [-s format] [-w format ] [-b session template] " \ "[-c window template] " CMD_TARGET_WINDOW_USAGE, 0, @@ -46,8 +50,8 @@ const struct cmd_entry cmd_choose_tree_entry = { const struct cmd_entry cmd_choose_session_entry = { "choose-session", NULL, - "Ss:b:t:", 0, 1, - CMD_TARGET_WINDOW_USAGE " [-s format] [-b session template]", + "F:t:", 0, 1, + CMD_TARGET_WINDOW_USAGE " [-F format] [template]", 0, NULL, NULL, @@ -56,8 +60,8 @@ const struct cmd_entry cmd_choose_session_entry = { const struct cmd_entry cmd_choose_window_entry = { "choose-window", NULL, - "Ww:c:t:", 0, 1, - CMD_TARGET_WINDOW_USAGE "[-W] [-w format] [-c window template]", + "F:t:", 0, 1, + CMD_TARGET_WINDOW_USAGE "[-F format] [template]", 0, NULL, NULL, @@ -83,9 +87,6 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } - sflag = self->entry == &cmd_choose_session_entry; - wflag = self->entry == &cmd_choose_window_entry; - s = ctx->curclient->session; tty = &ctx->curclient->tty; @@ -95,37 +96,66 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) return (0); - if ((ses_action = args_get(args, 'b')) == NULL) - ses_action = "switch-client -t '%%'"; + if (self->entry == &cmd_choose_session_entry) + { + wflag = 0; + sflag = 1; + + if ((ses_template = args_get(args, 'F')) == NULL) + ses_template = DEFAULT_SESSION_TEMPLATE; - if ((win_action = args_get(args, 'c')) == NULL) - win_action = "select-window -t '%%'"; + if (args->argc != 0) + ses_action = args->argv[0]; + else + ses_action = DEFAULT_SES_ACTION; + } - if ((ses_template = args_get(args, 's')) == NULL) - ses_template = DEFAULT_SESSION_TEMPLATE; + if (self->entry == &cmd_choose_window_entry) + { + sflag = 0; + wflag = 1; - if ((win_template = args_get(args, 'w')) == NULL) - win_template = DEFAULT_WINDOW_TEMPLATE " \"#{pane_title}\""; + if ((win_template = args_get(args, 'F')) == NULL) + win_template = DEFAULT_WIN_TEMPLATE; - if (self->entry == &cmd_choose_tree_entry) { - wflag = args_has(args, 'W'); - sflag = args_has(args, 'S'); + if (args->argc != 0) + win_action = args->argv[0]; + else + win_action = DEFAULT_WIN_ACTION; } - if (!wflag && !sflag) { - ctx->error(ctx, "Nothing to display, no flags given."); - window_pane_reset_mode(wl->window->active); - return (-1); + if (self->entry == &cmd_choose_tree_entry) + { + wflag = args_has(args, 'w'); + sflag = args_has(args, 's'); + + if ((ses_action = args_get(args, 'b')) == NULL) + ses_action = DEFAULT_SES_ACTION; + + if ((win_action = args_get(args, 'c')) == NULL) + win_action = DEFAULT_WIN_ACTION; + + if ((ses_template = args_get(args, 'S')) == NULL) + ses_template = DEFAULT_SESSION_TEMPLATE; + + if ((win_template = args_get(args, 'W')) == NULL) + win_template = DEFAULT_WIN_TEMPLATE; } - /* If we're drawing in tree mode, including sessions, then pad the - * window template with ACS drawing characters, otherwise just render - * the windows as a flat list, without any padding. + /* + * If not asking for windows and sessions, assume no "-ws" given and + * hence display the entire tree outright. + */ + if (!wflag && !sflag) + wflag = sflag = 1; + + /* + * If we're drawing in tree mode, including sessions, then pad the + * window template, otherwise just render the windows as a flat list + * without any padding. */ if (wflag && sflag) - xasprintf(&final_win_template, " %s%s> %s", - tty_acs_get(tty, 't'), tty_acs_get(tty, 'q'), - win_template); + xasprintf(&final_win_template, " ---> %s", win_template); else final_win_template = xstrdup(win_template); @@ -133,7 +163,8 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) RB_FOREACH(s2, sessions, &sessions) { idx_ses++; - /* If we're just choosing windows, jump straight there. Note + /* + * If we're just choosing windows, jump straight there. Note * that this implies the current session, so only choose * windows when the session matches this one. */ diff --git a/trunk/tmux.1 b/trunk/tmux.1 index 4cf41b4..8de6e6a 100644 --- a/trunk/tmux.1 +++ b/trunk/tmux.1 @@ -1095,12 +1095,12 @@ This command works only from inside .Nm . .It Xo .Ic choose-tree -.Op Fl S -.Op Fl W +.Op Fl s +.Op Fl w .Op Fl b Ar session-template .Op Fl c Ar window-template -.Op Fl s Ar format -.Op Fl w Ar format +.Op Fl S Ar format +.Op Fl W Ar format .Op Fl t Ar target-window .Xc Put a window into tree choice mode, where either sessions or windows may be @@ -1117,10 +1117,10 @@ commands are wrappers around . .Pp If -.Fl S +.Fl s is given, will show sessions. If -.Fl W +.Fl w is given, will show windows. If .Fl b @@ -1139,11 +1139,11 @@ This command will run .Ar session-template before it. If -.Fl s +.Fl S is given will display the specified format instead of the default session format. If -.Fl w +.Fl W is given will display the specified format instead of the default window format. For the meaning of the -- 1.7.10 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users