summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/status.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-02-06 17:11:40 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-02-06 17:11:40 +0000
commitdfc5d64b8e5c5cd2dff1791503dd818ecf924be1 (patch)
tree0664d73861c5604a3dcea7bc791f50bf4ab9ef8e /usr.bin/tmux/status.c
parentcdc6bb8060137b0027903c59e1e00006b3368e81 (diff)
Add format_expand_time and use it instead of status_replace where
command execution is not needed.
Diffstat (limited to 'usr.bin/tmux/status.c')
-rw-r--r--usr.bin/tmux/status.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index f031a8e10d8..a05639854bb 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.121 2015/02/05 10:29:43 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.122 2015/02/06 17:11:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -760,14 +760,20 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
int (*callbackfn)(void *, const char *), void (*freefn)(void *),
void *data, int flags)
{
- int keys;
+ struct format_tree *ft;
+ int keys;
+ time_t t;
+
+ ft = format_create();
+ format_defaults(ft, c, NULL, NULL, NULL);
+ t = time(NULL);
status_message_clear(c);
status_prompt_clear(c);
- c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0);
+ c->prompt_string = format_expand_time(ft, msg, time(NULL));
- c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0);
+ c->prompt_buffer = format_expand_time(ft, input, time(NULL));
c->prompt_index = strlen(c->prompt_buffer);
c->prompt_callbackfn = callbackfn;
@@ -786,6 +792,8 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS;
+
+ format_free(ft);
}
/* Remove status line prompt. */
@@ -814,16 +822,25 @@ status_prompt_clear(struct client *c)
void
status_prompt_update(struct client *c, const char *msg, const char *input)
{
+ struct format_tree *ft;
+ time_t t;
+
+ ft = format_create();
+ format_defaults(ft, c, NULL, NULL, NULL);
+ t = time(NULL);
+
free(c->prompt_string);
- c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0);
+ c->prompt_string = format_expand_time(ft, msg, time(NULL));
free(c->prompt_buffer);
- c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0);
+ c->prompt_buffer = format_expand_time(ft, input, time(NULL));
c->prompt_index = strlen(c->prompt_buffer);
c->prompt_hindex = 0;
c->flags |= CLIENT_STATUS;
+
+ format_free(ft);
}
/* Draw client prompt on status line of present else on last line. */