summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/server-client.c33
-rw-r--r--usr.bin/tmux/status.c26
-rw-r--r--usr.bin/tmux/tmux.h4
3 files changed, 40 insertions, 23 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index d3412f30d35..90eae6956dc 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.211 2017/02/08 15:49:29 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.212 2017/02/09 12:09:33 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1624,3 +1624,34 @@ server_client_push_stderr(struct client *c)
log_debug("%s: client %p, queued", __func__, c);
}
}
+
+/* Add to client message log. */
+void
+server_client_add_message(struct client *c, const char *fmt, ...)
+{
+ struct message_entry *msg, *msg1;
+ char *s;
+ va_list ap;
+ u_int limit;
+
+ va_start(ap, fmt);
+ xvasprintf(&s, fmt, ap);
+ va_end(ap);
+
+ log_debug("%s: message %s", c->tty.path, s);
+
+ msg = xcalloc(1, sizeof *msg);
+ msg->msg_time = time(NULL);
+ msg->msg_num = c->message_next++;
+ msg->msg = s;
+ TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
+
+ limit = options_get_number(global_options, "message-limit");
+ TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
+ if (msg->msg_num + limit >= c->message_next)
+ break;
+ free(msg->msg);
+ TAILQ_REMOVE(&c->message_log, msg, entry);
+ free(msg);
+ }
+}
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 1630d1b3930..bd948b9ea7b 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.161 2017/02/03 21:01:02 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.162 2017/02/09 12:09:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -562,13 +562,9 @@ status_print(struct client *c, struct winlink *wl, time_t t,
void
status_message_set(struct client *c, const char *fmt, ...)
{
- struct timeval tv;
- struct message_entry *msg, *msg1;
- va_list ap;
- int delay;
- u_int limit;
-
- limit = options_get_number(global_options, "message-limit");
+ struct timeval tv;
+ va_list ap;
+ int delay;
status_message_clear(c);
@@ -576,19 +572,7 @@ status_message_set(struct client *c, const char *fmt, ...)
xvasprintf(&c->message_string, fmt, ap);
va_end(ap);
- msg = xcalloc(1, sizeof *msg);
- msg->msg_time = time(NULL);
- msg->msg_num = c->message_next++;
- msg->msg = xstrdup(c->message_string);
- TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
-
- TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
- if (msg->msg_num + limit >= c->message_next)
- break;
- free(msg->msg);
- TAILQ_REMOVE(&c->message_log, msg, entry);
- free(msg);
- }
+ server_client_add_message(c, "%s", c->message_string);
delay = options_get_number(c->session->options, "display-time");
if (delay > 0) {
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 90532e4ecd8..456e0ccd9f7 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.723 2017/02/08 23:53:03 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.724 2017/02/09 12:09:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1828,6 +1828,8 @@ void server_client_exec(struct client *, const char *);
void server_client_loop(void);
void server_client_push_stdout(struct client *);
void server_client_push_stderr(struct client *);
+void printflike(2, 3) server_client_add_message(struct client *, const char *,
+ ...);
/* server-fn.c */
void server_fill_environ(struct session *, struct environ *);