-/* $OpenBSD: cmd-show-messages.c,v 1.10 2014/10/20 22:29:25 nicm Exp $ */
+/* $OpenBSD: cmd-show-messages.c,v 1.11 2015/04/25 18:33:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
struct client *c;
struct message_entry *msg;
char *tim;
- u_int i;
int done;
done = 0;
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
return (CMD_RETURN_ERROR);
- for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
- msg = &ARRAY_ITEM(&c->message_log, i);
-
+ TAILQ_FOREACH(msg, &c->message_log, entry) {
tim = ctime(&msg->msg_time);
*strchr(tim, '\n') = '\0';
-/* $OpenBSD: cmd.c,v 1.102 2015/04/25 18:09:28 nicm Exp $ */
+/* $OpenBSD: cmd.c,v 1.103 2015/04/25 18:33:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
};
ARRAY_DECL(client_list, struct client *);
+ARRAY_DECL(sessionslist, struct session *);
int cmd_session_better(struct session *, struct session *, int);
struct session *cmd_choose_session_list(struct sessionslist *);
-/* $OpenBSD: server-client.c,v 1.135 2015/04/24 23:17:11 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.136 2015/04/25 18:33:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
RB_INIT(&c->status_old);
c->message_string = NULL;
- ARRAY_INIT(&c->message_log);
+ TAILQ_INIT(&c->message_log);
c->prompt_string = NULL;
c->prompt_buffer = NULL;
void
server_client_lost(struct client *c)
{
- struct message_entry *msg;
- u_int i;
+ struct message_entry *msg, *msg1;
TAILQ_REMOVE(&clients, c, entry);
log_debug("lost client %d", c->ibuf.fd);
free(c->message_string);
if (event_initialized(&c->message_timer))
evtimer_del(&c->message_timer);
- for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
- msg = &ARRAY_ITEM(&c->message_log, i);
+ TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
free(msg->msg);
+ TAILQ_REMOVE(&c->message_log, msg, entry);
+ free(msg);
}
- ARRAY_FREE(&c->message_log);
free(c->prompt_string);
free(c->prompt_buffer);
-/* $OpenBSD: status.c,v 1.126 2015/04/24 22:19:36 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.127 2015/04/25 18:33:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
status_message_set(struct client *c, const char *fmt, ...)
{
struct timeval tv;
- struct message_entry *msg;
+ struct message_entry *msg, *msg1;
va_list ap;
int delay;
- u_int i, limit;
+ u_int first, limit;
+
+ limit = options_get_number(&global_options, "message-limit");
status_prompt_clear(c);
status_message_clear(c);
xvasprintf(&c->message_string, fmt, ap);
va_end(ap);
- ARRAY_EXPAND(&c->message_log, 1);
- msg = &ARRAY_LAST(&c->message_log);
+ 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);
- limit = options_get_number(&global_options, "message-limit");
- if (ARRAY_LENGTH(&c->message_log) > limit) {
- limit = ARRAY_LENGTH(&c->message_log) - limit;
- for (i = 0; i < limit; i++) {
- msg = &ARRAY_FIRST(&c->message_log);
- free(msg->msg);
- ARRAY_REMOVE(&c->message_log, 0);
- }
+ first = c->message_next - limit;
+ TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
+ if (msg->msg_num >= first)
+ continue;
+ free(msg->msg);
+ TAILQ_REMOVE(&c->message_log, msg, entry);
+ free(msg);
}
delay = options_get_number(&c->session->options, "display-time");
-/* $OpenBSD: tmux.h,v 1.500 2015/04/25 18:09:28 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.501 2015/04/25 18:33:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
};
TAILQ_HEAD(window_panes, window_pane);
RB_HEAD(window_pane_tree, window_pane);
-ARRAY_DECL(window_pane_list, struct window_pane *);
/* Window structure. */
struct window {
RB_ENTRY(session) entry;
};
RB_HEAD(sessions, session);
-ARRAY_DECL(sessionslist, struct session *);
/* TTY information. */
struct tty_key {
/* Saved message entry. */
struct message_entry {
char *msg;
+ u_int msg_num;
time_t msg_time;
+ TAILQ_ENTRY(message_entry) entry;
};
/* Status output data from a job. */
char *message_string;
struct event message_timer;
- ARRAY_DECL(, struct message_entry) message_log;
+ u_int message_next;
+ TAILQ_HEAD(, message_entry) message_log;
char *prompt_string;
char *prompt_buffer;
-/* $OpenBSD: window.c,v 1.123 2015/04/25 18:09:28 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.124 2015/04/25 18:33:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* it reaches zero.
*/
+ARRAY_DECL(window_pane_list, struct window_pane *);
+
/* Global window list. */
struct windows windows;