summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2013-03-21 16:25:08 +0000
committerNicholas Marriott <nicm@openbsd.org>2013-03-21 16:25:08 +0000
commitdd46c95e23e546dfe5ad66e8200d87b739c15db2 (patch)
tree0299a2e98c6534ad0dcd422d165997767d0b7848 /status.c
parent4920306486122f3e6c1afd69518dbbdb40fbff5b (diff)
Aargh. Spaces -> tabs.
Diffstat (limited to 'status.c')
-rw-r--r--status.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/status.c b/status.c
index dd4c737c..d9545218 100644
--- a/status.c
+++ b/status.c
@@ -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) ||
@@ -444,8 +437,7 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl,
case 'P':
if (window_pane_index(wp, &idx) != 0)
fatalx("index not found");
- xsnprintf(
- tmp, sizeof tmp, "%u", idx);
+ xsnprintf(tmp, sizeof tmp, "%u", idx);
ptr = tmp;
goto do_replace;
case 'S':
@@ -468,6 +460,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 +502,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, *expanded;
+ 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 +537,14 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
}
*optr = '\0';
- return (xstrdup(out));
+ ft = format_create();
+ format_client(ft, c);
+ format_session(ft, s);
+ format_winlink(ft, s, wl);
+ format_window_pane(ft, wp);
+ expanded = format_expand(ft, out);
+ format_free(ft);
+ return (expanded);
}
/* Figure out job name and get its result, starting it off if necessary. */