mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		
							
								
								
									
										33
									
								
								cfg.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								cfg.c
									
									
									
									
									
								
							@@ -29,7 +29,8 @@
 | 
				
			|||||||
struct cmd_q		*cfg_cmd_q;
 | 
					struct cmd_q		*cfg_cmd_q;
 | 
				
			||||||
int			 cfg_finished;
 | 
					int			 cfg_finished;
 | 
				
			||||||
int			 cfg_references;
 | 
					int			 cfg_references;
 | 
				
			||||||
ARRAY_DECL (, char *)	 cfg_causes = ARRAY_INITIALIZER;
 | 
					char**			 cfg_causes;
 | 
				
			||||||
 | 
					u_int			 cfg_ncauses;
 | 
				
			||||||
struct client		*cfg_client;
 | 
					struct client		*cfg_client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
@@ -121,40 +122,42 @@ cfg_add_cause(const char* fmt, ...)
 | 
				
			|||||||
	xvasprintf(&msg, fmt, ap);
 | 
						xvasprintf(&msg, fmt, ap);
 | 
				
			||||||
	va_end (ap);
 | 
						va_end (ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ARRAY_ADD(&cfg_causes, msg);
 | 
						cfg_ncauses++;
 | 
				
			||||||
 | 
						cfg_causes = xreallocarray(cfg_causes, cfg_ncauses, sizeof *cfg_causes);
 | 
				
			||||||
 | 
						cfg_causes[cfg_ncauses - 1] = msg;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
cfg_print_causes(struct cmd_q *cmdq)
 | 
					cfg_print_causes(struct cmd_q *cmdq)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char	*cause;
 | 
					 | 
				
			||||||
	u_int	 i;
 | 
						u_int	 i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
 | 
						for (i = 0; i < cfg_ncauses; i++) {
 | 
				
			||||||
		cause = ARRAY_ITEM(&cfg_causes, i);
 | 
							cmdq_print(cmdq, "%s", cfg_causes[i]);
 | 
				
			||||||
		cmdq_print(cmdq, "%s", cause);
 | 
							free(cfg_causes[i]);
 | 
				
			||||||
		free(cause);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ARRAY_FREE(&cfg_causes);
 | 
					
 | 
				
			||||||
 | 
						free(cfg_causes);
 | 
				
			||||||
 | 
						cfg_causes = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
cfg_show_causes(struct session *s)
 | 
					cfg_show_causes(struct session *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window_pane	*wp;
 | 
						struct window_pane	*wp;
 | 
				
			||||||
	char			*cause;
 | 
					 | 
				
			||||||
	u_int			 i;
 | 
						u_int			 i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (s == NULL || ARRAY_EMPTY(&cfg_causes))
 | 
						if (s == NULL || cfg_ncauses == 0)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	wp = s->curw->window->active;
 | 
						wp = s->curw->window->active;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window_pane_set_mode(wp, &window_copy_mode);
 | 
						window_pane_set_mode(wp, &window_copy_mode);
 | 
				
			||||||
	window_copy_init_for_output(wp);
 | 
						window_copy_init_for_output(wp);
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
 | 
						for (i = 0; i < cfg_ncauses; i++) {
 | 
				
			||||||
		cause = ARRAY_ITEM(&cfg_causes, i);
 | 
							window_copy_add(wp, "%s", cfg_causes[i]);
 | 
				
			||||||
		window_copy_add(wp, "%s", cause);
 | 
							free(cfg_causes[i]);
 | 
				
			||||||
		free(cause);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ARRAY_FREE(&cfg_causes);
 | 
					
 | 
				
			||||||
 | 
						free(cfg_causes);
 | 
				
			||||||
 | 
						cfg_causes = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,9 +69,12 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
 | 
				
			|||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
							if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
		w = cmd_lookup_windowid(tflag);
 | 
							w = window_find_by_id_str(tflag);
 | 
				
			||||||
		if (w == NULL && (wp = cmd_lookup_paneid(tflag)) != NULL)
 | 
							if (w == NULL) {
 | 
				
			||||||
 | 
								wp = window_pane_find_by_id_str(tflag);
 | 
				
			||||||
 | 
								if (wp != NULL)
 | 
				
			||||||
				w = wp->window;
 | 
									w = wp->window;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (w != NULL)
 | 
							if (w != NULL)
 | 
				
			||||||
			wl = winlink_find_by_window(&s->windows, w);
 | 
								wl = winlink_find_by_window(&s->windows, w);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,7 +129,6 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
	struct client		*c;
 | 
						struct client		*c;
 | 
				
			||||||
	struct message_entry	*msg;
 | 
						struct message_entry	*msg;
 | 
				
			||||||
	char			*tim;
 | 
						char			*tim;
 | 
				
			||||||
	u_int			 i;
 | 
					 | 
				
			||||||
	int			 done;
 | 
						int			 done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	done = 0;
 | 
						done = 0;
 | 
				
			||||||
@@ -155,9 +154,7 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
	if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
 | 
						if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
							return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
 | 
						TAILQ_FOREACH(msg, &c->message_log, entry) {
 | 
				
			||||||
		msg = &ARRAY_ITEM(&c->message_log, i);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		tim = ctime(&msg->msg_time);
 | 
							tim = ctime(&msg->msg_time);
 | 
				
			||||||
		*strchr(tim, '\n') = '\0';
 | 
							*strchr(tim, '\n') = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,10 +99,12 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
								if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
				
			||||||
				return (CMD_RETURN_ERROR);
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
			w = cmd_lookup_windowid(tflag);
 | 
								w = window_find_by_id_str(tflag);
 | 
				
			||||||
			if (w == NULL &&
 | 
								if (w == NULL) {
 | 
				
			||||||
			    (wp = cmd_lookup_paneid(tflag)) != NULL)
 | 
									wp = window_pane_find_by_id_str(tflag);
 | 
				
			||||||
 | 
									if (wp != NULL)
 | 
				
			||||||
					w = wp->window;
 | 
										w = wp->window;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			if (w != NULL)
 | 
								if (w != NULL)
 | 
				
			||||||
				wl = winlink_find_by_window(&s->windows, w);
 | 
									wl = winlink_find_by_window(&s->windows, w);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										61
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								cmd.c
									
									
									
									
									
								
							@@ -116,6 +116,7 @@ const struct cmd_entry *cmd_table[] = {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ARRAY_DECL(client_list, struct client *);
 | 
					ARRAY_DECL(client_list, struct client *);
 | 
				
			||||||
 | 
					ARRAY_DECL(sessionslist, struct session *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int		 cmd_session_better(struct session *, struct session *, int);
 | 
					int		 cmd_session_better(struct session *, struct session *, int);
 | 
				
			||||||
struct session	*cmd_choose_session_list(struct sessionslist *);
 | 
					struct session	*cmd_choose_session_list(struct sessionslist *);
 | 
				
			||||||
@@ -123,7 +124,6 @@ struct session	*cmd_choose_session(int);
 | 
				
			|||||||
struct client	*cmd_choose_client(struct client_list *);
 | 
					struct client	*cmd_choose_client(struct client_list *);
 | 
				
			||||||
struct client	*cmd_lookup_client(const char *);
 | 
					struct client	*cmd_lookup_client(const char *);
 | 
				
			||||||
struct session	*cmd_lookup_session(struct cmd_q *, const char *, int *);
 | 
					struct session	*cmd_lookup_session(struct cmd_q *, const char *, int *);
 | 
				
			||||||
struct session	*cmd_lookup_session_id(const char *);
 | 
					 | 
				
			||||||
struct winlink	*cmd_lookup_window(struct session *, const char *, int *);
 | 
					struct winlink	*cmd_lookup_window(struct session *, const char *, int *);
 | 
				
			||||||
int		 cmd_lookup_index(struct session *, const char *, int *);
 | 
					int		 cmd_lookup_index(struct session *, const char *, int *);
 | 
				
			||||||
struct winlink	*cmd_lookup_winlink_windowid(struct session *, const char *);
 | 
					struct winlink	*cmd_lookup_winlink_windowid(struct session *, const char *);
 | 
				
			||||||
@@ -638,21 +638,6 @@ cmd_lookup_client(const char *name)
 | 
				
			|||||||
	return (NULL);
 | 
						return (NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Find the target session or report an error and return NULL. */
 | 
					 | 
				
			||||||
struct session *
 | 
					 | 
				
			||||||
cmd_lookup_session_id(const char *arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char	*endptr;
 | 
					 | 
				
			||||||
	long	 id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (arg[0] != '$')
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	id = strtol(arg + 1, &endptr, 10);
 | 
					 | 
				
			||||||
	if (arg[1] != '\0' && *endptr == '\0')
 | 
					 | 
				
			||||||
		return (session_find_by_id(id));
 | 
					 | 
				
			||||||
	return (NULL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Lookup a session by name. If no session is found, NULL is returned. */
 | 
					/* Lookup a session by name. If no session is found, NULL is returned. */
 | 
				
			||||||
struct session *
 | 
					struct session *
 | 
				
			||||||
cmd_lookup_session(struct cmd_q *cmdq, const char *name, int *ambiguous)
 | 
					cmd_lookup_session(struct cmd_q *cmdq, const char *name, int *ambiguous)
 | 
				
			||||||
@@ -664,13 +649,13 @@ cmd_lookup_session(struct cmd_q *cmdq, const char *name, int *ambiguous)
 | 
				
			|||||||
	*ambiguous = 0;
 | 
						*ambiguous = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Look for $id first. */
 | 
						/* Look for $id first. */
 | 
				
			||||||
	if ((s = cmd_lookup_session_id(name)) != NULL)
 | 
						if ((s = session_find_by_id_str(name)) != NULL)
 | 
				
			||||||
		return (s);
 | 
							return (s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Try as pane or window id. */
 | 
						/* Try as pane or window id. */
 | 
				
			||||||
	if ((wp = cmd_lookup_paneid(name)) != NULL)
 | 
						if ((wp = window_pane_find_by_id_str(name)) != NULL)
 | 
				
			||||||
		return (cmd_window_session(cmdq, wp->window, NULL));
 | 
							return (cmd_window_session(cmdq, wp->window, NULL));
 | 
				
			||||||
	if ((w = cmd_lookup_windowid(name)) != NULL)
 | 
						if ((w = window_find_by_id_str(name)) != NULL)
 | 
				
			||||||
		return (cmd_window_session(cmdq, w, NULL));
 | 
							return (cmd_window_session(cmdq, w, NULL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
@@ -721,12 +706,12 @@ cmd_lookup_window(struct session *s, const char *name, int *ambiguous)
 | 
				
			|||||||
	    return (wl);
 | 
						    return (wl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Lookup as pane or window id. */
 | 
						/* Lookup as pane or window id. */
 | 
				
			||||||
	if ((wp = cmd_lookup_paneid(name)) != NULL) {
 | 
						if ((wp = window_pane_find_by_id_str(name)) != NULL) {
 | 
				
			||||||
		wl = winlink_find_by_window(&s->windows, wp->window);
 | 
							wl = winlink_find_by_window(&s->windows, wp->window);
 | 
				
			||||||
		if (wl != NULL)
 | 
							if (wl != NULL)
 | 
				
			||||||
			return (wl);
 | 
								return (wl);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if ((w = cmd_lookup_windowid(name)) != NULL) {
 | 
						if ((w = window_find_by_id_str(name)) != NULL) {
 | 
				
			||||||
		wl = winlink_find_by_window(&s->windows, w);
 | 
							wl = winlink_find_by_window(&s->windows, w);
 | 
				
			||||||
		if (wl != NULL)
 | 
							if (wl != NULL)
 | 
				
			||||||
			return (wl);
 | 
								return (wl);
 | 
				
			||||||
@@ -794,22 +779,6 @@ cmd_lookup_index(struct session *s, const char *name, int *ambiguous)
 | 
				
			|||||||
	return (-1);
 | 
						return (-1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Lookup pane id. An initial % means a pane id. */
 | 
					 | 
				
			||||||
struct window_pane *
 | 
					 | 
				
			||||||
cmd_lookup_paneid(const char *arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	const char	*errstr;
 | 
					 | 
				
			||||||
	u_int		 paneid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (*arg != '%')
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	paneid = strtonum(arg + 1, 0, UINT_MAX, &errstr);
 | 
					 | 
				
			||||||
	if (errstr != NULL)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	return (window_pane_find_by_id(paneid));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Lookup window id in a session. An initial @ means a window id. */
 | 
					/* Lookup window id in a session. An initial @ means a window id. */
 | 
				
			||||||
struct winlink *
 | 
					struct winlink *
 | 
				
			||||||
cmd_lookup_winlink_windowid(struct session *s, const char *arg)
 | 
					cmd_lookup_winlink_windowid(struct session *s, const char *arg)
 | 
				
			||||||
@@ -826,22 +795,6 @@ cmd_lookup_winlink_windowid(struct session *s, const char *arg)
 | 
				
			|||||||
	return (winlink_find_by_window_id(&s->windows, windowid));
 | 
						return (winlink_find_by_window_id(&s->windows, windowid));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Lookup window id. An initial @ means a window id. */
 | 
					 | 
				
			||||||
struct window *
 | 
					 | 
				
			||||||
cmd_lookup_windowid(const char *arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	const char	*errstr;
 | 
					 | 
				
			||||||
	u_int		 windowid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (*arg != '@')
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	windowid = strtonum(arg + 1, 0, UINT_MAX, &errstr);
 | 
					 | 
				
			||||||
	if (errstr != NULL)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	return (window_find_by_id(windowid));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Find session and winlink for window. */
 | 
					/* Find session and winlink for window. */
 | 
				
			||||||
struct session *
 | 
					struct session *
 | 
				
			||||||
cmd_window_session(struct cmd_q *cmdq, struct window *w, struct winlink **wlp)
 | 
					cmd_window_session(struct cmd_q *cmdq, struct window *w, struct winlink **wlp)
 | 
				
			||||||
@@ -1251,7 +1204,7 @@ cmd_find_pane(struct cmd_q *cmdq,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Lookup as pane id. */
 | 
						/* Lookup as pane id. */
 | 
				
			||||||
	if ((*wpp = cmd_lookup_paneid(arg)) != NULL) {
 | 
						if ((*wpp = window_pane_find_by_id_str(arg)) != NULL) {
 | 
				
			||||||
		s = cmd_window_session(cmdq, (*wpp)->window, &wl);
 | 
							s = cmd_window_session(cmdq, (*wpp)->window, &wl);
 | 
				
			||||||
		if (sp != NULL)
 | 
							if (sp != NULL)
 | 
				
			||||||
			*sp = s;
 | 
								*sp = s;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -93,7 +93,7 @@ server_client_create(int fd)
 | 
				
			|||||||
	RB_INIT(&c->status_old);
 | 
						RB_INIT(&c->status_old);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c->message_string = NULL;
 | 
						c->message_string = NULL;
 | 
				
			||||||
	ARRAY_INIT(&c->message_log);
 | 
						TAILQ_INIT(&c->message_log);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c->prompt_string = NULL;
 | 
						c->prompt_string = NULL;
 | 
				
			||||||
	c->prompt_buffer = NULL;
 | 
						c->prompt_buffer = NULL;
 | 
				
			||||||
@@ -137,8 +137,7 @@ server_client_open(struct client *c, char **cause)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
server_client_lost(struct client *c)
 | 
					server_client_lost(struct client *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct message_entry	*msg;
 | 
						struct message_entry	*msg, *msg1;
 | 
				
			||||||
	u_int			 i;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TAILQ_REMOVE(&clients, c, entry);
 | 
						TAILQ_REMOVE(&clients, c, entry);
 | 
				
			||||||
	log_debug("lost client %d", c->ibuf.fd);
 | 
						log_debug("lost client %d", c->ibuf.fd);
 | 
				
			||||||
@@ -174,11 +173,11 @@ server_client_lost(struct client *c)
 | 
				
			|||||||
	free(c->message_string);
 | 
						free(c->message_string);
 | 
				
			||||||
	if (event_initialized(&c->message_timer))
 | 
						if (event_initialized(&c->message_timer))
 | 
				
			||||||
		evtimer_del(&c->message_timer);
 | 
							evtimer_del(&c->message_timer);
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
 | 
						TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
 | 
				
			||||||
		msg = &ARRAY_ITEM(&c->message_log, i);
 | 
					 | 
				
			||||||
		free(msg->msg);
 | 
							free(msg->msg);
 | 
				
			||||||
 | 
							TAILQ_REMOVE(&c->message_log, msg, entry);
 | 
				
			||||||
 | 
							free(msg);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ARRAY_FREE(&c->message_log);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free(c->prompt_string);
 | 
						free(c->prompt_string);
 | 
				
			||||||
	free(c->prompt_buffer);
 | 
						free(c->prompt_buffer);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								session.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								session.c
									
									
									
									
									
								
							@@ -69,6 +69,22 @@ session_find(const char *name)
 | 
				
			|||||||
	return (RB_FIND(sessions, &sessions, &s));
 | 
						return (RB_FIND(sessions, &sessions, &s));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Find session by id parsed from a string. */
 | 
				
			||||||
 | 
					struct session *
 | 
				
			||||||
 | 
					session_find_by_id_str(const char *s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char	*errstr;
 | 
				
			||||||
 | 
						u_int		 id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (*s != '$')
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						id = strtonum(s + 1, 0, UINT_MAX, &errstr);
 | 
				
			||||||
 | 
						if (errstr != NULL)
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
						return (session_find_by_id(id));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Find session by id. */
 | 
					/* Find session by id. */
 | 
				
			||||||
struct session *
 | 
					struct session *
 | 
				
			||||||
session_find_by_id(u_int id)
 | 
					session_find_by_id(u_int id)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								status.c
									
									
									
									
									
								
							@@ -636,10 +636,12 @@ void
 | 
				
			|||||||
status_message_set(struct client *c, const char *fmt, ...)
 | 
					status_message_set(struct client *c, const char *fmt, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct timeval		 tv;
 | 
						struct timeval		 tv;
 | 
				
			||||||
	struct message_entry	*msg;
 | 
						struct message_entry	*msg, *msg1;
 | 
				
			||||||
	va_list			 ap;
 | 
						va_list			 ap;
 | 
				
			||||||
	int			 delay;
 | 
						int			 delay;
 | 
				
			||||||
	u_int			 i, limit;
 | 
						u_int			 first, limit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						limit = options_get_number(&global_options, "message-limit");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	status_prompt_clear(c);
 | 
						status_prompt_clear(c);
 | 
				
			||||||
	status_message_clear(c);
 | 
						status_message_clear(c);
 | 
				
			||||||
@@ -648,19 +650,19 @@ status_message_set(struct client *c, const char *fmt, ...)
 | 
				
			|||||||
	xvasprintf(&c->message_string, fmt, ap);
 | 
						xvasprintf(&c->message_string, fmt, ap);
 | 
				
			||||||
	va_end(ap);
 | 
						va_end(ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ARRAY_EXPAND(&c->message_log, 1);
 | 
						msg = xcalloc(1, sizeof *msg);
 | 
				
			||||||
	msg = &ARRAY_LAST(&c->message_log);
 | 
					 | 
				
			||||||
	msg->msg_time = time(NULL);
 | 
						msg->msg_time = time(NULL);
 | 
				
			||||||
 | 
						msg->msg_num = c->message_next++;
 | 
				
			||||||
	msg->msg = xstrdup(c->message_string);
 | 
						msg->msg = xstrdup(c->message_string);
 | 
				
			||||||
 | 
						TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	limit = options_get_number(&global_options, "message-limit");
 | 
						first = c->message_next - limit;
 | 
				
			||||||
	if (ARRAY_LENGTH(&c->message_log) > limit) {
 | 
						TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
 | 
				
			||||||
		limit = ARRAY_LENGTH(&c->message_log) - limit;
 | 
							if (msg->msg_num >= first)
 | 
				
			||||||
		for (i = 0; i < limit; i++) {
 | 
								continue;
 | 
				
			||||||
			msg = &ARRAY_FIRST(&c->message_log);
 | 
					 | 
				
			||||||
		free(msg->msg);
 | 
							free(msg->msg);
 | 
				
			||||||
			ARRAY_REMOVE(&c->message_log, 0);
 | 
							TAILQ_REMOVE(&c->message_log, msg, entry);
 | 
				
			||||||
		}
 | 
							free(msg);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	delay = options_get_number(&c->session->options, "display-time");
 | 
						delay = options_get_number(&c->session->options, "display-time");
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								tmux.h
									
									
									
									
									
								
							@@ -948,7 +948,6 @@ struct window_pane {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
TAILQ_HEAD(window_panes, window_pane);
 | 
					TAILQ_HEAD(window_panes, window_pane);
 | 
				
			||||||
RB_HEAD(window_pane_tree, window_pane);
 | 
					RB_HEAD(window_pane_tree, window_pane);
 | 
				
			||||||
ARRAY_DECL(window_pane_list, struct window_pane *);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Window structure. */
 | 
					/* Window structure. */
 | 
				
			||||||
struct window {
 | 
					struct window {
 | 
				
			||||||
@@ -1099,7 +1098,6 @@ struct session {
 | 
				
			|||||||
	RB_ENTRY(session)    entry;
 | 
						RB_ENTRY(session)    entry;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
RB_HEAD(sessions, session);
 | 
					RB_HEAD(sessions, session);
 | 
				
			||||||
ARRAY_DECL(sessionslist, struct session *);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* TTY information. */
 | 
					/* TTY information. */
 | 
				
			||||||
struct tty_key {
 | 
					struct tty_key {
 | 
				
			||||||
@@ -1253,7 +1251,9 @@ struct tty_ctx {
 | 
				
			|||||||
/* Saved message entry. */
 | 
					/* Saved message entry. */
 | 
				
			||||||
struct message_entry {
 | 
					struct message_entry {
 | 
				
			||||||
	char   *msg;
 | 
						char   *msg;
 | 
				
			||||||
 | 
						u_int	msg_num;
 | 
				
			||||||
	time_t	msg_time;
 | 
						time_t	msg_time;
 | 
				
			||||||
 | 
						TAILQ_ENTRY(message_entry) entry;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Status output data from a job. */
 | 
					/* Status output data from a job. */
 | 
				
			||||||
@@ -1325,7 +1325,8 @@ struct client {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	char		*message_string;
 | 
						char		*message_string;
 | 
				
			||||||
	struct event	 message_timer;
 | 
						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_string;
 | 
				
			||||||
	char		*prompt_buffer;
 | 
						char		*prompt_buffer;
 | 
				
			||||||
@@ -1764,8 +1765,6 @@ int		 cmd_find_index(struct cmd_q *, const char *,
 | 
				
			|||||||
struct winlink	*cmd_find_pane(struct cmd_q *, const char *, struct session **,
 | 
					struct winlink	*cmd_find_pane(struct cmd_q *, const char *, struct session **,
 | 
				
			||||||
		     struct window_pane **);
 | 
							     struct window_pane **);
 | 
				
			||||||
char		*cmd_template_replace(const char *, const char *, int);
 | 
					char		*cmd_template_replace(const char *, const char *, int);
 | 
				
			||||||
struct window	*cmd_lookup_windowid(const char *);
 | 
					 | 
				
			||||||
struct window_pane *cmd_lookup_paneid(const char *);
 | 
					 | 
				
			||||||
extern const struct cmd_entry *cmd_table[];
 | 
					extern const struct cmd_entry *cmd_table[];
 | 
				
			||||||
extern const struct cmd_entry cmd_attach_session_entry;
 | 
					extern const struct cmd_entry cmd_attach_session_entry;
 | 
				
			||||||
extern const struct cmd_entry cmd_bind_key_entry;
 | 
					extern const struct cmd_entry cmd_bind_key_entry;
 | 
				
			||||||
@@ -2145,6 +2144,7 @@ struct winlink	*winlink_previous_by_number(struct winlink *, struct session *,
 | 
				
			|||||||
		     int);
 | 
							     int);
 | 
				
			||||||
void		 winlink_stack_push(struct winlink_stack *, struct winlink *);
 | 
					void		 winlink_stack_push(struct winlink_stack *, struct winlink *);
 | 
				
			||||||
void		 winlink_stack_remove(struct winlink_stack *, struct winlink *);
 | 
					void		 winlink_stack_remove(struct winlink_stack *, struct winlink *);
 | 
				
			||||||
 | 
					struct window	*window_find_by_id_str(const char *);
 | 
				
			||||||
struct window	*window_find_by_id(u_int);
 | 
					struct window	*window_find_by_id(u_int);
 | 
				
			||||||
struct window	*window_create1(u_int, u_int);
 | 
					struct window	*window_create1(u_int, u_int);
 | 
				
			||||||
struct window	*window_create(const char *, int, char **, const char *,
 | 
					struct window	*window_create(const char *, int, char **, const char *,
 | 
				
			||||||
@@ -2170,6 +2170,7 @@ struct window_pane *window_pane_previous_by_number(struct window *,
 | 
				
			|||||||
int		 window_pane_index(struct window_pane *, u_int *);
 | 
					int		 window_pane_index(struct window_pane *, u_int *);
 | 
				
			||||||
u_int		 window_count_panes(struct window *);
 | 
					u_int		 window_count_panes(struct window *);
 | 
				
			||||||
void		 window_destroy_panes(struct window *);
 | 
					void		 window_destroy_panes(struct window *);
 | 
				
			||||||
 | 
					struct window_pane *window_pane_find_by_id_str(const char *);
 | 
				
			||||||
struct window_pane *window_pane_find_by_id(u_int);
 | 
					struct window_pane *window_pane_find_by_id(u_int);
 | 
				
			||||||
struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
 | 
					struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
 | 
				
			||||||
void		 window_pane_destroy(struct window_pane *);
 | 
					void		 window_pane_destroy(struct window_pane *);
 | 
				
			||||||
@@ -2307,6 +2308,7 @@ int	session_cmp(struct session *, struct session *);
 | 
				
			|||||||
RB_PROTOTYPE(sessions, session, entry, session_cmp);
 | 
					RB_PROTOTYPE(sessions, session, entry, session_cmp);
 | 
				
			||||||
int		 session_alive(struct session *);
 | 
					int		 session_alive(struct session *);
 | 
				
			||||||
struct session	*session_find(const char *);
 | 
					struct session	*session_find(const char *);
 | 
				
			||||||
 | 
					struct session	*session_find_by_id_str(const char *);
 | 
				
			||||||
struct session	*session_find_by_id(u_int);
 | 
					struct session	*session_find_by_id(u_int);
 | 
				
			||||||
struct session	*session_create(const char *, int, char **, const char *,
 | 
					struct session	*session_create(const char *, int, char **, const char *,
 | 
				
			||||||
		     int, struct environ *, struct termios *, int, u_int,
 | 
							     int, struct environ *, struct termios *, int, u_int,
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tty.c
									
									
									
									
									
								
							@@ -220,7 +220,7 @@ tty_start_tty(struct tty *tty)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	tty_putcode(tty, TTYC_CNORM);
 | 
						tty_putcode(tty, TTYC_CNORM);
 | 
				
			||||||
	if (tty_term_has(tty->term, TTYC_KMOUS))
 | 
						if (tty_term_has(tty->term, TTYC_KMOUS))
 | 
				
			||||||
		tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l");
 | 
							tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (tty_term_has(tty->term, TTYC_XT)) {
 | 
						if (tty_term_has(tty->term, TTYC_XT)) {
 | 
				
			||||||
		if (options_get_number(&global_options, "focus-events")) {
 | 
							if (options_get_number(&global_options, "focus-events")) {
 | 
				
			||||||
@@ -294,7 +294,7 @@ tty_stop_tty(struct tty *tty)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
 | 
						tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
 | 
				
			||||||
	if (tty_term_has(tty->term, TTYC_KMOUS))
 | 
						if (tty_term_has(tty->term, TTYC_KMOUS))
 | 
				
			||||||
		tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l");
 | 
							tty_raw(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (tty_term_has(tty->term, TTYC_XT)) {
 | 
						if (tty_term_has(tty->term, TTYC_XT)) {
 | 
				
			||||||
		if (tty->flags & TTY_FOCUS) {
 | 
							if (tty->flags & TTY_FOCUS) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										33
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								window.c
									
									
									
									
									
								
							@@ -48,6 +48,8 @@
 | 
				
			|||||||
 * it reaches zero.
 | 
					 * it reaches zero.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ARRAY_DECL(window_pane_list, struct window_pane *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Global window list. */
 | 
					/* Global window list. */
 | 
				
			||||||
struct windows windows;
 | 
					struct windows windows;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -252,6 +254,21 @@ winlink_stack_remove(struct winlink_stack *stack, struct winlink *wl)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct window *
 | 
				
			||||||
 | 
					window_find_by_id_str(const char* s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char	*errstr;
 | 
				
			||||||
 | 
						u_int		 id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (*s != '@')
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						id = strtonum(s + 1, 0, UINT_MAX, &errstr);
 | 
				
			||||||
 | 
						if (errstr != NULL)
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
						return (window_find_by_id(id));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct window *
 | 
					struct window *
 | 
				
			||||||
window_find_by_id(u_int id)
 | 
					window_find_by_id(u_int id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -652,7 +669,21 @@ window_printable_flags(struct session *s, struct winlink *wl)
 | 
				
			|||||||
	return (xstrdup(flags));
 | 
						return (xstrdup(flags));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Find pane in global tree by id. */
 | 
					struct window_pane *
 | 
				
			||||||
 | 
					window_pane_find_by_id_str(const char *s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char	*errstr;
 | 
				
			||||||
 | 
						u_int		 id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (*s != '%')
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						id = strtonum(s + 1, 0, UINT_MAX, &errstr);
 | 
				
			||||||
 | 
						if (errstr != NULL)
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
						return (window_pane_find_by_id(id));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct window_pane *
 | 
					struct window_pane *
 | 
				
			||||||
window_pane_find_by_id(u_int id)
 | 
					window_pane_find_by_id(u_int id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user