summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server-client.c31
-rw-r--r--status.c24
-rw-r--r--tmux.h2
3 files changed, 37 insertions, 20 deletions
diff --git a/server-client.c b/server-client.c
index a469cdbc..1e349e38 100644
--- a/server-client.c
+++ b/server-client.c
@@ -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/status.c b/status.c
index 6cc1ee37..a8fe2032 100644
--- a/status.c
+++ b/status.c
@@ -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/tmux.h b/tmux.h
index a2bb7c55..09c980df 100644
--- a/tmux.h
+++ b/tmux.h
@@ -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 *);