diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-03-14 21:31:44 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-03-14 21:31:44 +0000 |
commit | 9c3dc4cb4c4b5ab09503f1b71fa829a415daa492 (patch) | |
tree | 9cdc87020545d73f9d73a5a1471844510838cbb8 /usr.bin/tmux/format.c | |
parent | 46ca82aed1a61bbac2eca7c7aea205783c73877f (diff) |
Add T format modifier like E but also do strftime(3).
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r-- | usr.bin/tmux/format.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index aa66a091737..575bf30c6e9 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.174 2019/03/14 21:27:26 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.175 2019/03/14 21:31:43 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -95,9 +95,10 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2) #define FORMAT_QUOTE 0x8 #define FORMAT_LITERAL 0x10 #define FORMAT_EXPAND 0x20 -#define FORMAT_SESSIONS 0x40 -#define FORMAT_WINDOWS 0x80 -#define FORMAT_PANES 0x100 +#define FORMAT_EXPANDTIME 0x40 +#define FORMAT_SESSIONS 0x80 +#define FORMAT_WINDOWS 0x100 +#define FORMAT_PANES 0x200 /* Entry in format tree. */ struct format_entry { @@ -1001,7 +1002,7 @@ format_build_modifiers(struct format_tree *ft, const char **s, u_int *count) /* * Modifiers are a ; separated list of the forms: - * l,m,C,b,d,t,q + * l,m,C,b,d,t,q,E,T,S,W,P * =a * =/a * =/a/ @@ -1018,7 +1019,7 @@ format_build_modifiers(struct format_tree *ft, const char **s, u_int *count) cp++; /* Check single character modifiers with no arguments. */ - if (strchr("lmCbdtqESWP", cp[0]) != NULL && + if (strchr("lmCbdtqETSWP", cp[0]) != NULL && format_is_end(cp[1])) { format_add_modifier(&list, count, cp, 1, NULL, 0); cp++; @@ -1305,6 +1306,9 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, case 'E': modifiers |= FORMAT_EXPAND; break; + case 'T': + modifiers |= FORMAT_EXPANDTIME; + break; case 'S': modifiers |= FORMAT_SESSIONS; break; @@ -1432,6 +1436,11 @@ done: free(value); value = new; } + else if (modifiers & FORMAT_EXPANDTIME) { + new = format_expand_time(ft, value, 0); + free(value); + value = new; + } /* Perform substitution if any. */ if (sub != NULL) { |