diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-09-03 09:01:17 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-09-03 09:01:17 +0000 |
commit | da3560bfe41be49fc07fe264351543d7ea0dc98f (patch) | |
tree | 33f157a1c101b4cef321fee6b12992aae1f1349e /usr.bin/tmux | |
parent | 8541c9752590e9b6dba2f0258d47bfc964b121bb (diff) |
Change format of choose-tree arrows slightly, from Romain Francoise.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-choose-tree.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c index ab5b5fca999..496d770392d 100644 --- a/usr.bin/tmux/cmd-choose-tree.c +++ b/usr.bin/tmux/cmd-choose-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-tree.c,v 1.7 2012/08/14 08:51:53 nicm Exp $ */ +/* $OpenBSD: cmd-choose-tree.c,v 1.8 2012/09/03 09:01:16 nicm Exp $ */ /* * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> @@ -74,11 +74,14 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct winlink *wl, *wm; struct session *s, *s2; + struct tty *tty; struct window_choose_data *wcd = NULL; const char *ses_template, *win_template; - char *final_win_action, *final_win_template; + char *final_win_action, *cur_win_template; + char *final_win_template_middle; + char *final_win_template_last; const char *ses_action, *win_action; - u_int cur_win, idx_ses, win_ses; + u_int cur_win, idx_ses, win_ses, win_max; u_int wflag, sflag; ses_template = win_template = NULL; @@ -90,6 +93,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) } s = ctx->curclient->session; + tty = &ctx->curclient->tty; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (CMD_RETURN_ERROR); @@ -146,12 +150,14 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) * window template, otherwise just render the windows as a flat list * without any padding. */ - if (wflag && sflag) - xasprintf(&final_win_template, " --> %s", win_template); - else if (wflag) - final_win_template = xstrdup(win_template); - else - final_win_template = NULL; + if (wflag && sflag) { + xasprintf(&final_win_template_middle, " |-> %s", win_template); + xasprintf(&final_win_template_last, " \\-> %s", win_template); + } else if (wflag) { + final_win_template_middle = xstrdup(win_template); + final_win_template_last = xstrdup(win_template); + } else + final_win_template_middle = final_win_template_last = NULL; idx_ses = cur_win = -1; RB_FOREACH(s2, sessions, &sessions) { @@ -169,7 +175,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) } wcd = window_choose_add_session(wl->window->active, - ctx, s2, ses_template, (char *)ses_action, idx_ses); + ctx, s2, ses_template, (char *)ses_action, idx_ses); /* If we're just choosing sessions, skip choosing windows. */ if (sflag && !wflag) { @@ -178,7 +184,9 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) continue; } windows_only: - win_ses = -1; + win_ses = win_max = -1; + RB_FOREACH(wm, winlinks, &s2->windows) + win_max++; RB_FOREACH(wm, winlinks, &s2->windows) { win_ses++; if (sflag && wflag) @@ -197,11 +205,16 @@ windows_only: } xasprintf(&final_win_action, "%s ; %s", win_action, - wcd ? wcd->command : ""); + wcd ? wcd->command : ""); + + if (win_ses != win_max) + cur_win_template = final_win_template_middle; + else + cur_win_template = final_win_template_last; window_choose_add_window(wl->window->active, - ctx, s2, wm, final_win_template, - final_win_action, idx_ses); + ctx, s2, wm, cur_win_template, + final_win_action, idx_ses); free(final_win_action); } @@ -212,7 +225,8 @@ windows_only: if (wflag && !sflag) break; } - free(final_win_template); + free(final_win_template_middle); + free(final_win_template_last); window_choose_ready(wl->window->active, cur_win, cmd_choose_tree_callback, cmd_choose_tree_free); |