summaryrefslogtreecommitdiffstats
path: root/cmd-show-messages.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2020-05-06 13:43:22 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2020-05-06 13:43:22 +0100
commit7a95e9bf7ec80c7b87dda73749e59f359371d78a (patch)
treea28ae9e721c1d4d08be4d942dd2ea08d92bc7006 /cmd-show-messages.c
parentc80fc6bf9e44baaad1e6f4a4c83ec47823e96c1b (diff)
Change message log to be per server rather than per client and include every
command that is run.
Diffstat (limited to 'cmd-show-messages.c')
-rw-r--r--cmd-show-messages.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/cmd-show-messages.c b/cmd-show-messages.c
index 02fdb9cd..d2f8289f 100644
--- a/cmd-show-messages.c
+++ b/cmd-show-messages.c
@@ -18,16 +18,19 @@
#include <sys/types.h>
+#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include <unistd.h>
#include "tmux.h"
/*
- * Show client message log.
+ * Show message log.
*/
+#define SHOW_MESSAGES_TEMPLATE \
+ "#{t/p:message_time}: #{message_text}"
+
static enum cmd_retval cmd_show_messages_exec(struct cmd *,
struct cmdq_item *);
@@ -71,10 +74,10 @@ static enum cmd_retval
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
- struct client *tc = cmdq_get_target_client(item);
struct message_entry *msg;
- char *tim;
+ char *s;
int done, blank;
+ struct format_tree *ft;
done = blank = 0;
if (args_has(args, 'T')) {
@@ -88,11 +91,17 @@ cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
if (done)
return (CMD_RETURN_NORMAL);
- TAILQ_FOREACH(msg, &tc->message_log, entry) {
- tim = ctime(&msg->msg_time);
- *strchr(tim, '\n') = '\0';
- cmdq_print(item, "%s %s", tim, msg->msg);
+ ft = format_create_from_target(item);
+ TAILQ_FOREACH_REVERSE(msg, &message_log, message_list, entry) {
+ format_add(ft, "message_text", "%s", msg->msg);
+ format_add(ft, "message_number", "%u", msg->msg_num);
+ format_add_tv(ft, "message_time", &msg->msg_time);
+
+ s = format_expand(ft, SHOW_MESSAGES_TEMPLATE);
+ cmdq_print(item, "%s", s);
+ free(s);
}
+ format_free(ft);
return (CMD_RETURN_NORMAL);
}