Change message log to be per server rather than per client and include every

command that is run.
This commit is contained in:
Nicholas Marriott
2020-05-06 13:43:22 +01:00
parent c80fc6bf9e
commit 7a95e9bf7e
9 changed files with 92 additions and 76 deletions

View File

@ -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);
}