This teaches the choose/list commands to use -F.
---
 trunk/cmd-choose-client.c |   26 ++++++++++++++++++--------
 trunk/cmd-list-clients.c  |    9 ++-------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/trunk/cmd-choose-client.c b/trunk/cmd-choose-client.c
index 730474d..8ddcedf 100644
--- a/trunk/cmd-choose-client.c
+++ b/trunk/cmd-choose-client.c
@@ -33,8 +33,8 @@ void  cmd_choose_client_free(void *);
 
 const struct cmd_entry cmd_choose_client_entry = {
        "choose-client", NULL,
-       "t:", 0, 1,
-       CMD_TARGET_WINDOW_USAGE " [template]",
+       "t:F:", 0, 1,
+       CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
        0,
        NULL,
        NULL,
@@ -51,8 +51,11 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
 {
        struct args                     *args = self->args;
        struct cmd_choose_client_data   *cdata;
+       struct format_tree              *ft;
        struct winlink                  *wl;
        struct client                   *c;
+       char                            *line;
+       const char                      *template;
        u_int                            i, idx, cur;
 
        if (ctx->curclient == NULL) {
@@ -66,6 +69,9 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
        if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
                return (0);
 
+       if ((template = args_get(args, 'F')) == NULL)
+               template = DEFAULT_CLIENT_TEMPLATE;
+
        cur = idx = 0;
        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
                c = ARRAY_ITEM(&clients, i);
@@ -75,12 +81,16 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx 
*ctx)
                        cur = idx;
                idx++;
 
-               window_choose_add(wl->window->active, i,
-                   "%s: %s [%ux%u %s]%s%s", c->tty.path,
-                   c->session->name, c->tty.sx, c->tty.sy,
-                   c->tty.termname,
-                   c->tty.flags & TTY_UTF8 ? " (utf8)" : "",
-                   c->flags & CLIENT_READONLY ? " (ro)" : "");
+               ft = format_create();
+               format_add(ft, "line", "%u", i);
+               format_session(ft, c->session);
+               format_client(ft, c);
+
+               line = format_expand(ft, template);
+               window_choose_add(wl->window->active, i, "%s", line);
+               xfree(line);
+
+               format_free(ft);
        }
 
        cdata = xmalloc(sizeof *cdata);
diff --git a/trunk/cmd-list-clients.c b/trunk/cmd-list-clients.c
index e5a8e34..1319090 100644
--- a/trunk/cmd-list-clients.c
+++ b/trunk/cmd-list-clients.c
@@ -58,13 +58,8 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
        } else
                s = NULL;
 
-       template = args_get(args, 'F');
-       if (template == NULL) {
-               template = "#{client_tty}: #{session_name} "
-                   "[#{client_width}x#{client_height} #{client_termname}]"
-                   "#{?client_utf8, (utf8),}"
-                   "#{?client_readonly, (ro),}";
-       }
+       if ((template = args_get(args, 'F')) == NULL)
+               template = DEFAULT_CLIENT_TEMPLATE;
 
        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
                c = ARRAY_ITEM(&clients, i);
-- 
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

Reply via email to