Nicholas Marriott <nicholas.marri...@gmail.com> writes:

> The problem is that you need to turn ACS on and off, it's not as simple
> as just using qqqq and so on. There is currently no way to tell the
> window-choose code that a section of an entry should be displayed with
> ACS on.

Ah, ok. Yeah, that sounds harder to fix.

In the meantime, here's a version with a backslash for the ASCII tree:

diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index 7132017..5b484fe 100644
--- a/cmd-choose-tree.c
+++ b/cmd-choose-tree.c
@@ -76,11 +76,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;
@@ -92,6 +95,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);
@@ -148,12 +152,25 @@ 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) {
+               if (tty->flags & TTY_UTF8) {
+                       xasprintf(&final_win_template_middle, "%s%s %s",
+                               tty_acs_get(tty, 't'), tty_acs_get(tty, 'q'),
+                               win_template);
+                       xasprintf(&final_win_template_last, "%s%s %s",
+                               tty_acs_get(tty, 'm'), tty_acs_get(tty, 'q'),
+                               win_template);
+               } else {
+                       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) {
@@ -180,7 +197,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)
@@ -201,8 +220,13 @@ windows_only:
                        xasprintf(&final_win_action, "%s ; %s", win_action,
                                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,
+                               ctx, s2, wm, cur_win_template,
                                final_win_action, idx_ses);
 
                        free(final_win_action);
@@ -214,7 +238,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);

------------------------------------------------------------------------------
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

Reply via email to