aboutsummaryrefslogtreecommitdiff
path: root/status.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-11-19 22:20:04 +0000
committerTiago Cunha <tcunha@gmx.com>2009-11-19 22:20:04 +0000
commitacc331c787f4d85c0909563139f7cc81c54edc55 (patch)
treea60e276b1f7ffffe8f5dec00fac1c721ae4121d2 /status.c
parent8777a809dc06282c74fad56d2b76c9c2770c89d4 (diff)
downloadrtmux-acc331c787f4d85c0909563139f7cc81c54edc55.tar.gz
rtmux-acc331c787f4d85c0909563139f7cc81c54edc55.tar.bz2
rtmux-acc331c787f4d85c0909563139f7cc81c54edc55.zip
Sync OpenBSD patchset 546:
Add a per-client log of status line messages displayed while that client exists. A new message-limit session option sets the maximum number of entries and a command, show-messages, shows the log (bound to ~ by default). This (and prompt history) might be better as a single global log but until there are global options it is easier for them to be per client.
Diffstat (limited to 'status.c')
-rw-r--r--status.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/status.c b/status.c
index 05303fe1..ac3f2631 100644
--- a/status.c
+++ b/status.c
@@ -1,4 +1,4 @@
-/* $Id: status.c,v 1.128 2009-11-18 01:28:43 tcunha Exp $ */
+/* $Id: status.c,v 1.129 2009-11-19 22:20:04 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -566,9 +566,12 @@ status_print(struct session *s, struct winlink *wl, struct grid_cell *gc)
void printflike2
status_message_set(struct client *c, const char *fmt, ...)
{
- struct timeval tv;
- va_list ap;
- int delay;
+ struct timeval tv;
+ struct session *s = c->session;
+ struct message_entry *msg;
+ va_list ap;
+ int delay;
+ u_int i, limit;
status_prompt_clear(c);
status_message_clear(c);
@@ -577,10 +580,25 @@ status_message_set(struct client *c, const char *fmt, ...)
xvasprintf(&c->message_string, fmt, ap);
va_end(ap);
+ ARRAY_EXPAND(&c->message_log, 1);
+ msg = &ARRAY_LAST(&c->message_log);
+ msg->msg_time = time(NULL);
+ msg->msg = xstrdup(c->message_string);
+
+ if (s == NULL)
+ limit = 0;
+ else
+ limit = options_get_number(&s->options, "message-limit");
+ for (i = ARRAY_LENGTH(&c->message_log); i > limit; i--) {
+ msg = &ARRAY_ITEM(&c->message_log, i - 1);
+ xfree(msg->msg);
+ ARRAY_REMOVE(&c->message_log, i - 1);
+ }
+
delay = options_get_number(&c->session->options, "display-time");
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
-
+
evtimer_del(&c->message_timer);
evtimer_set(&c->message_timer, status_message_callback, c);
evtimer_add(&c->message_timer, &tv);