diff options
author | 2013-03-21 16:13:24 +0000 | |
---|---|---|
committer | 2013-03-21 16:13:24 +0000 | |
commit | 16a56a596ef5eb1a0789bab5ef99fd4f242d9403 (patch) | |
tree | 9f9bddb9cee5b7eef3d198ce67116fc5bd4cdf5a /usr.bin/tmux | |
parent | Show alias in lscm output. (diff) | |
download | wireguard-openbsd-16a56a596ef5eb1a0789bab5ef99fd4f242d9403.tar.xz wireguard-openbsd-16a56a596ef5eb1a0789bab5ef99fd4f242d9403.zip |
Allow formats in status options.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/format.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 32 |
2 files changed, 23 insertions, 14 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 42ed32f32f1..7568199ca41 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.12 2013/02/05 11:01:45 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.13 2013/03/21 16:13:24 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -251,10 +251,11 @@ format_expand(struct format_tree *ft, const char *fmt) continue; } } - while (len - off < 2) { + while (len - off < 3) { buf = xrealloc(buf, 2, len); len *= 2; } + buf[off++] = '#'; buf[off++] = ch; continue; } diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index 441bf35dda8..84bbad89a6c 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.95 2012/11/27 13:52:23 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.96 2013/03/21 16:13:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -393,13 +393,6 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl, long limit; u_int idx; - if (s == NULL) - s = c->session; - if (wl == NULL) - wl = s->curw; - if (wp == NULL) - wp = wl->window->active; - errno = 0; limit = strtol(*iptr, &endptr, 10); if ((limit == 0 && errno != EINVAL) || @@ -468,6 +461,9 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl, */ ch = ']'; goto skip_to; + case '{': + ptr = (char *) "#{"; + goto do_replace; case '#': *(*optr)++ = '#'; break; @@ -507,13 +503,21 @@ char * status_replace(struct client *c, struct session *s, struct winlink *wl, struct window_pane *wp, const char *fmt, time_t t, int jobsflag) { - static char out[BUFSIZ]; - char in[BUFSIZ], ch, *iptr, *optr; - size_t len; + static char out[BUFSIZ]; + char in[BUFSIZ], ch, *iptr, *optr; + size_t len; + struct format_tree *ft; if (fmt == NULL) return (xstrdup("")); + if (s == NULL) + s = c->session; + if (wl == NULL) + wl = s->curw; + if (wp == NULL) + wp = wl->window->active; + len = strftime(in, sizeof in, fmt, localtime(&t)); in[len] = '\0'; @@ -534,7 +538,11 @@ status_replace(struct client *c, struct session *s, struct winlink *wl, } *optr = '\0'; - return (xstrdup(out)); + ft = format_create(); + format_session(ft, s); + format_winlink(ft, s, wl); + format_window_pane(ft, wp); + return (format_expand(ft, out)); } /* Figure out job name and get its result, starting it off if necessary. */ |