This will core if you give it -F w/o -t.

Also, looking at it again: since jobsflag is 0 to status_replace so it
won't run jobs, a format is enough I think (it will replace #W etc too).

Perhaps this... I left -F to match the other formats but maybe it's
unnecessary.

Index: cmd-display-message.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-display-message.c,v
retrieving revision 1.10
diff -u -p -r1.10 cmd-display-message.c
--- cmd-display-message.c       6 Apr 2011 11:36:26 -0000       1.10
+++ cmd-display-message.c       21 Feb 2012 09:13:28 -0000
@@ -30,8 +30,8 @@ int   cmd_display_message_exec(struct cmd 
 
 const struct cmd_entry cmd_display_message_entry = {
        "display-message", "display",
-       "c:pt:", 0, 1,
-       "[-p] [-c target-client] [-t target-pane] [message]",
+       "c:pt:F:", 0, 1,
+       "[-p] [-c target-client] [-t target-pane] [-F format] [message]",
        0,
        NULL,
        NULL,
@@ -48,26 +48,39 @@ cmd_display_message_exec(struct cmd *sel
        struct window_pane      *wp;
        const char              *template;
        char                    *msg;
+       struct format_tree      *ft;
+       char                     out[BUFSIZ];
+       time_t                   t;
 
        if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
-               return (-1);
+           return (-1);
 
-       if (args_has(args, 't') != 0) {
+       if (args_has(args, 't')) {
                wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
                if (wl == NULL)
                        return (-1);
        } else {
-               s = NULL;
-               wl = NULL;
-               wp = NULL;
+               wl = cmd_find_pane(ctx, NULL, &s, &wp);
+               if (wl == NULL)
+                       return (-1);
        }
 
-       if (args->argc == 0)
-               template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)";
-       else
+       template = args_get(args, 'F');
+       if (args->argc != 0)
                template = args->argv[0];
+       if (template == NULL)
+               template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)";
+
+       ft = format_create();
+       format_client(ft, c);
+       format_session(ft, s);
+       format_winlink(ft, s, wl);
+       format_window_pane(ft, wp);
+
+       t = time(NULL);
+       strftime(out, sizeof out, template, localtime(&t));
 
-       msg = status_replace(c, s, wl, wp, template, time(NULL), 0);
+       msg = format_expand(ft, out);
        if (args_has(self->args, 'p'))
                ctx->print(ctx, "%s", msg);
        else






On Sun, Feb 05, 2012 at 10:06:04PM -0800, George Nachman wrote:
> As we discussed earlier, this patch adds -F format to display-message.
> If -F is passed then that format is used in preference to the
> 'message' argument.
> 
> Index: tmux.1
> ===================================================================
> --- tmux.1    (revision 2697)
> +++ tmux.1    (working copy)
> @@ -2648,6 +2648,7 @@
>  .El
>  .Sh FORMATS
>  The
> +.Ic display-message ,
>  .Ic list-clients ,
>  .Ic list-sessions ,
>  .Ic list-windows
> @@ -2979,6 +2980,7 @@
>  .Op Fl p
>  .Op Fl c Ar target-client
>  .Op Fl t Ar target-pane
> +.Op Fl F format
>  .Op Ar message
>  .Xc
>  .D1 (alias: Ic display )
> @@ -2988,9 +2990,16 @@
>  is given, the output is printed to stdout, otherwise it is displayed in the
>  .Ar target-client
>  status line.
> -The format of
> +If
> +.Fl F
> +is given, then
> +.Ar format
> +defines the message as described in the
> +.Sx FORMATS
> +section.
> +Otherwise,
>  .Ar message
> -is as for
> +defines the message. Its format is as for
>  .Ic status-left ,
>  with the exception that #() are not handled; information is taken from
>  .Ar target-pane
> Index: cmd-display-message.c
> ===================================================================
> --- cmd-display-message.c     (revision 2697)
> +++ cmd-display-message.c     (working copy)
> @@ -30,8 +30,8 @@
> 
>  const struct cmd_entry cmd_display_message_entry = {
>       "display-message", "display",
> -     "c:pt:", 0, 1,
> -     "[-p] [-c target-client] [-t target-pane] [message]",
> +     "c:pt:F:", 0, 1,
> +     "[-p] [-c target-client] [-t target-pane] [-F format] [message]",
>       0,
>       NULL,
>       NULL,
> @@ -48,6 +48,7 @@
>       struct window_pane      *wp;
>       const char              *template;
>       char                    *msg;
> +     struct format_tree      *ft;
> 
>       if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
>               return (-1);
> @@ -62,12 +63,22 @@
>               wp = NULL;
>       }
> 
> -     if (args->argc == 0)
> -             template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)";
> -     else
> -             template = args->argv[0];
> +     template = args_get(args, 'F');
> +     if (template != NULL) {
> +             ft = format_create();
> +             format_session(ft, s);
> +             format_winlink(ft, s, wl);
> +             format_window_pane(ft, wp);
> 
> -     msg = status_replace(c, s, wl, wp, template, time(NULL), 0);
> +             msg = format_expand(ft, template);
> +     } else {
> +             if (args->argc == 0)
> +                     template = "[#S] #I:#W, current pane #P - (%H:%M 
> %d-%b-%y)";
> +             else
> +                     template = args->argv[0];
> +
> +             msg = status_replace(c, s, wl, wp, template, time(NULL), 0);
> +     }
>       if (args_has(self->args, 'p'))
>               ctx->print(ctx, "%s", msg);
>       else
> 
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to