mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-23 14:28:55 +01:00
Change format of choose-tree arrows slightly, from Romain Francoise.
This commit is contained in:
parent
2e43372d0b
commit
a679a4a708
@ -74,11 +74,14 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct winlink *wl, *wm;
|
struct winlink *wl, *wm;
|
||||||
struct session *s, *s2;
|
struct session *s, *s2;
|
||||||
|
struct tty *tty;
|
||||||
struct window_choose_data *wcd = NULL;
|
struct window_choose_data *wcd = NULL;
|
||||||
const char *ses_template, *win_template;
|
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;
|
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;
|
u_int wflag, sflag;
|
||||||
|
|
||||||
ses_template = win_template = NULL;
|
ses_template = win_template = NULL;
|
||||||
@ -90,6 +93,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s = ctx->curclient->session;
|
s = ctx->curclient->session;
|
||||||
|
tty = &ctx->curclient->tty;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
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
|
* window template, otherwise just render the windows as a flat list
|
||||||
* without any padding.
|
* without any padding.
|
||||||
*/
|
*/
|
||||||
if (wflag && sflag)
|
if (wflag && sflag) {
|
||||||
xasprintf(&final_win_template, " --> %s", win_template);
|
xasprintf(&final_win_template_middle, " |-> %s", win_template);
|
||||||
else if (wflag)
|
xasprintf(&final_win_template_last, " \\-> %s", win_template);
|
||||||
final_win_template = xstrdup(win_template);
|
} else if (wflag) {
|
||||||
else
|
final_win_template_middle = xstrdup(win_template);
|
||||||
final_win_template = NULL;
|
final_win_template_last = xstrdup(win_template);
|
||||||
|
} else
|
||||||
|
final_win_template_middle = final_win_template_last = NULL;
|
||||||
|
|
||||||
idx_ses = cur_win = -1;
|
idx_ses = cur_win = -1;
|
||||||
RB_FOREACH(s2, sessions, &sessions) {
|
RB_FOREACH(s2, sessions, &sessions) {
|
||||||
@ -178,7 +184,9 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
windows_only:
|
windows_only:
|
||||||
win_ses = -1;
|
win_ses = win_max = -1;
|
||||||
|
RB_FOREACH(wm, winlinks, &s2->windows)
|
||||||
|
win_max++;
|
||||||
RB_FOREACH(wm, winlinks, &s2->windows) {
|
RB_FOREACH(wm, winlinks, &s2->windows) {
|
||||||
win_ses++;
|
win_ses++;
|
||||||
if (sflag && wflag)
|
if (sflag && wflag)
|
||||||
@ -199,8 +207,13 @@ windows_only:
|
|||||||
xasprintf(&final_win_action, "%s ; %s", win_action,
|
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,
|
window_choose_add_window(wl->window->active,
|
||||||
ctx, s2, wm, final_win_template,
|
ctx, s2, wm, cur_win_template,
|
||||||
final_win_action, idx_ses);
|
final_win_action, idx_ses);
|
||||||
|
|
||||||
free(final_win_action);
|
free(final_win_action);
|
||||||
@ -212,7 +225,8 @@ windows_only:
|
|||||||
if (wflag && !sflag)
|
if (wflag && !sflag)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(final_win_template);
|
free(final_win_template_middle);
|
||||||
|
free(final_win_template_last);
|
||||||
|
|
||||||
window_choose_ready(wl->window->active, cur_win,
|
window_choose_ready(wl->window->active, cur_win,
|
||||||
cmd_choose_tree_callback, cmd_choose_tree_free);
|
cmd_choose_tree_callback, cmd_choose_tree_free);
|
||||||
|
Loading…
Reference in New Issue
Block a user