aboutsummaryrefslogtreecommitdiff
path: root/status.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-11-18 13:16:33 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-11-18 13:16:33 +0000
commit8db145da1ed40d471e9ecff0e788ced26a43fc92 (patch)
treefdb41dfba63f5cb24ad9607c1e28abb58179f27c /status.c
parent68f5c9c72da0c4430733de2094fbb8bc4d1e0474 (diff)
downloadrtmux-8db145da1ed40d471e9ecff0e788ced26a43fc92.tar.gz
rtmux-8db145da1ed40d471e9ecff0e788ced26a43fc92.tar.bz2
rtmux-8db145da1ed40d471e9ecff0e788ced26a43fc92.zip
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.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/status.c b/status.c
index c030e777..a5716d1a 100644
--- a/status.c
+++ b/status.c
@@ -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);