mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		
							
								
								
									
										18
									
								
								arguments.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								arguments.c
									
									
									
									
									
								
							@@ -20,6 +20,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -77,7 +78,6 @@ struct args *
 | 
				
			|||||||
args_parse(const char *template, int argc, char **argv)
 | 
					args_parse(const char *template, int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct args	*args;
 | 
						struct args	*args;
 | 
				
			||||||
	char		*ptr;
 | 
					 | 
				
			||||||
	int		 opt;
 | 
						int		 opt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	args = xcalloc(1, sizeof *args);
 | 
						args = xcalloc(1, sizeof *args);
 | 
				
			||||||
@@ -88,7 +88,7 @@ args_parse(const char *template, int argc, char **argv)
 | 
				
			|||||||
	while ((opt = getopt(argc, argv, template)) != -1) {
 | 
						while ((opt = getopt(argc, argv, template)) != -1) {
 | 
				
			||||||
		if (opt < 0)
 | 
							if (opt < 0)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (opt == '?' || (ptr = strchr(template, opt)) == NULL) {
 | 
							if (opt == '?' || strchr(template, opt) == NULL) {
 | 
				
			||||||
			args_free(args);
 | 
								args_free(args);
 | 
				
			||||||
			return (NULL);
 | 
								return (NULL);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -204,19 +204,15 @@ args_set(struct args *args, u_char ch, const char *value)
 | 
				
			|||||||
	/* Replace existing argument. */
 | 
						/* Replace existing argument. */
 | 
				
			||||||
	if ((entry = args_find(args, ch)) != NULL) {
 | 
						if ((entry = args_find(args, ch)) != NULL) {
 | 
				
			||||||
		free(entry->value);
 | 
							free(entry->value);
 | 
				
			||||||
		if (value != NULL)
 | 
							entry->value = NULL;
 | 
				
			||||||
			entry->value = xstrdup(value);
 | 
						} else {
 | 
				
			||||||
		else
 | 
							entry = xcalloc(1, sizeof *entry);
 | 
				
			||||||
			entry->value = NULL;
 | 
							entry->flag = ch;
 | 
				
			||||||
		return;
 | 
							RB_INSERT(args_tree, &args->tree, entry);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entry = xcalloc(1, sizeof *entry);
 | 
					 | 
				
			||||||
	entry->flag = ch;
 | 
					 | 
				
			||||||
	if (value != NULL)
 | 
						if (value != NULL)
 | 
				
			||||||
		entry->value = xstrdup(value);
 | 
							entry->value = xstrdup(value);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	RB_INSERT(args_tree, &args->tree, entry);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Get argument value. Will be NULL if it isn't present. */
 | 
					/* Get argument value. Will be NULL if it isn't present. */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								client.c
									
									
									
									
									
								
							@@ -118,10 +118,15 @@ retry:
 | 
				
			|||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		xasprintf(&lockfile, "%s.lock", path);
 | 
							xasprintf(&lockfile, "%s.lock", path);
 | 
				
			||||||
		if ((lockfd = client_get_lock(lockfile)) == -1)
 | 
							if ((lockfd = client_get_lock(lockfile)) == -1) {
 | 
				
			||||||
 | 
								free(lockfile);
 | 
				
			||||||
			goto retry;
 | 
								goto retry;
 | 
				
			||||||
		if (unlink(path) != 0 && errno != ENOENT)
 | 
							}
 | 
				
			||||||
 | 
							if (unlink(path) != 0 && errno != ENOENT) {
 | 
				
			||||||
 | 
								free(lockfile);
 | 
				
			||||||
 | 
								close(lockfd);
 | 
				
			||||||
			return (-1);
 | 
								return (-1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		fd = server_start(lockfd, lockfile);
 | 
							fd = server_start(lockfd, lockfile);
 | 
				
			||||||
		free(lockfile);
 | 
							free(lockfile);
 | 
				
			||||||
		close(lockfd);
 | 
							close(lockfd);
 | 
				
			||||||
@@ -232,7 +237,8 @@ client_main(int argc, char **argv, int flags)
 | 
				
			|||||||
	/* Initialise the client socket and start the server. */
 | 
						/* Initialise the client socket and start the server. */
 | 
				
			||||||
	fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
 | 
						fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
 | 
				
			||||||
	if (fd == -1) {
 | 
						if (fd == -1) {
 | 
				
			||||||
		fprintf(stderr, "failed to connect to server\n");
 | 
							fprintf(stderr, "failed to connect to server: %s\n",
 | 
				
			||||||
 | 
							    strerror(errno));
 | 
				
			||||||
		return (1);
 | 
							return (1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,6 +47,9 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct session		*s;
 | 
						struct session		*s;
 | 
				
			||||||
	struct client		*c;
 | 
						struct client		*c;
 | 
				
			||||||
 | 
						struct winlink		*wl = NULL;
 | 
				
			||||||
 | 
						struct window		*w = NULL;
 | 
				
			||||||
 | 
						struct window_pane	*wp = NULL;
 | 
				
			||||||
	const char		*update;
 | 
						const char		*update;
 | 
				
			||||||
	char			*cause;
 | 
						char			*cause;
 | 
				
			||||||
	u_int			 i;
 | 
						u_int			 i;
 | 
				
			||||||
@@ -59,12 +62,31 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
 | 
				
			|||||||
		return (CMD_RETURN_ERROR);
 | 
							return (CMD_RETURN_ERROR);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
						if (tflag == NULL) {
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
							if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
				
			||||||
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
						} else if (tflag[strcspn(tflag, ":.")] != '\0') {
 | 
				
			||||||
 | 
							if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL)
 | 
				
			||||||
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
				
			||||||
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
							w = cmd_lookup_windowid(tflag);
 | 
				
			||||||
 | 
							if (w == NULL && (wp = cmd_lookup_paneid(tflag)) != NULL)
 | 
				
			||||||
 | 
								w = wp->window;
 | 
				
			||||||
 | 
							if (w != NULL)
 | 
				
			||||||
 | 
								wl = winlink_find_by_window(&s->windows, w);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmdq->client == NULL)
 | 
						if (cmdq->client == NULL)
 | 
				
			||||||
		return (CMD_RETURN_NORMAL);
 | 
							return (CMD_RETURN_NORMAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (wl != NULL) {
 | 
				
			||||||
 | 
							if (wp != NULL)
 | 
				
			||||||
 | 
								window_set_active_pane(wp->window, wp);
 | 
				
			||||||
 | 
							session_set_current(s, wl);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmdq->client->session != NULL) {
 | 
						if (cmdq->client->session != NULL) {
 | 
				
			||||||
		if (dflag) {
 | 
							if (dflag) {
 | 
				
			||||||
			/*
 | 
								/*
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -107,13 +107,16 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
		cp = format_expand(ft, args_get(args, 'c'));
 | 
							cp = format_expand(ft, args_get(args, 'c'));
 | 
				
			||||||
		format_free(ft);
 | 
							format_free(ft);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fd = open(cp, O_RDONLY|O_DIRECTORY);
 | 
							if (cp != NULL && *cp != '\0') {
 | 
				
			||||||
		free(cp);
 | 
								fd = open(cp, O_RDONLY|O_DIRECTORY);
 | 
				
			||||||
		if (fd == -1) {
 | 
								free(cp);
 | 
				
			||||||
			cmdq_error(cmdq, "bad working directory: %s",
 | 
								if (fd == -1) {
 | 
				
			||||||
			    strerror(errno));
 | 
									cmdq_error(cmdq, "bad working directory: %s",
 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
									    strerror(errno));
 | 
				
			||||||
		}
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else if (cp != NULL)
 | 
				
			||||||
 | 
								free(cp);
 | 
				
			||||||
		cwd = fd;
 | 
							cwd = fd;
 | 
				
			||||||
	} else if (c != NULL && c->session == NULL)
 | 
						} else if (c != NULL && c->session == NULL)
 | 
				
			||||||
		cwd = c->cwd;
 | 
							cwd = c->cwd;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -82,6 +82,37 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	detached = args_has(args, 'd');
 | 
						detached = args_has(args, 'd');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (args->argc == 0)
 | 
				
			||||||
 | 
							cmd = options_get_string(&s->options, "default-command");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							cmd = args->argv[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (args_has(args, 'c')) {
 | 
				
			||||||
 | 
							ft = format_create();
 | 
				
			||||||
 | 
							if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
 | 
				
			||||||
 | 
								format_client(ft, c);
 | 
				
			||||||
 | 
							format_session(ft, s);
 | 
				
			||||||
 | 
							format_winlink(ft, s, s->curw);
 | 
				
			||||||
 | 
							format_window_pane(ft, s->curw->window->active);
 | 
				
			||||||
 | 
							cp = format_expand(ft, args_get(args, 'c'));
 | 
				
			||||||
 | 
							format_free(ft);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (cp != NULL && *cp != '\0') {
 | 
				
			||||||
 | 
								fd = open(cp, O_RDONLY|O_DIRECTORY);
 | 
				
			||||||
 | 
								free(cp);
 | 
				
			||||||
 | 
								if (fd == -1) {
 | 
				
			||||||
 | 
									cmdq_error(cmdq, "bad working directory: %s",
 | 
				
			||||||
 | 
									    strerror(errno));
 | 
				
			||||||
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else if (cp != NULL)
 | 
				
			||||||
 | 
								free(cp);
 | 
				
			||||||
 | 
							cwd = fd;
 | 
				
			||||||
 | 
						} else if (cmdq->client != NULL && cmdq->client->session == NULL)
 | 
				
			||||||
 | 
							cwd = cmdq->client->cwd;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							cwd = s->cwd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl = NULL;
 | 
						wl = NULL;
 | 
				
			||||||
	if (idx != -1)
 | 
						if (idx != -1)
 | 
				
			||||||
		wl = winlink_find_by_index(&s->windows, idx);
 | 
							wl = winlink_find_by_index(&s->windows, idx);
 | 
				
			||||||
@@ -102,34 +133,6 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (args->argc == 0)
 | 
					 | 
				
			||||||
		cmd = options_get_string(&s->options, "default-command");
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		cmd = args->argv[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (args_has(args, 'c')) {
 | 
					 | 
				
			||||||
		ft = format_create();
 | 
					 | 
				
			||||||
		if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
 | 
					 | 
				
			||||||
			format_client(ft, c);
 | 
					 | 
				
			||||||
		format_session(ft, s);
 | 
					 | 
				
			||||||
		format_winlink(ft, s, s->curw);
 | 
					 | 
				
			||||||
		format_window_pane(ft, s->curw->window->active);
 | 
					 | 
				
			||||||
		cp = format_expand(ft, args_get(args, 'c'));
 | 
					 | 
				
			||||||
		format_free(ft);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		fd = open(cp, O_RDONLY|O_DIRECTORY);
 | 
					 | 
				
			||||||
		free(cp);
 | 
					 | 
				
			||||||
		if (fd == -1) {
 | 
					 | 
				
			||||||
			cmdq_error(cmdq, "bad working directory: %s",
 | 
					 | 
				
			||||||
			    strerror(errno));
 | 
					 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		cwd = fd;
 | 
					 | 
				
			||||||
	} else if (cmdq->client != NULL && cmdq->client->session == NULL)
 | 
					 | 
				
			||||||
		cwd = cmdq->client->cwd;
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		cwd = s->cwd;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (idx == -1)
 | 
						if (idx == -1)
 | 
				
			||||||
		idx = -1 - options_get_number(&s->options, "base-index");
 | 
							idx = -1 - options_get_number(&s->options, "base-index");
 | 
				
			||||||
	wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
 | 
						wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,9 +69,7 @@ cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
 | 
				
			|||||||
	if (c == NULL)
 | 
						if (c == NULL)
 | 
				
			||||||
		/* nothing */;
 | 
							/* nothing */;
 | 
				
			||||||
	else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
 | 
						else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
 | 
				
			||||||
		va_start(ap, fmt);
 | 
					 | 
				
			||||||
		evbuffer_add_vprintf(c->stdout_data, fmt, ap);
 | 
							evbuffer_add_vprintf(c->stdout_data, fmt, ap);
 | 
				
			||||||
		va_end(ap);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		evbuffer_add(c->stdout_data, "\n", 1);
 | 
							evbuffer_add(c->stdout_data, "\n", 1);
 | 
				
			||||||
		server_push_stdout(c);
 | 
							server_push_stdout(c);
 | 
				
			||||||
@@ -104,9 +102,7 @@ cmdq_info(struct cmd_q *cmdq, const char *fmt, ...)
 | 
				
			|||||||
	if (c == NULL)
 | 
						if (c == NULL)
 | 
				
			||||||
		/* nothing */;
 | 
							/* nothing */;
 | 
				
			||||||
	else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
 | 
						else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
 | 
				
			||||||
		va_start(ap, fmt);
 | 
					 | 
				
			||||||
		evbuffer_add_vprintf(c->stdout_data, fmt, ap);
 | 
							evbuffer_add_vprintf(c->stdout_data, fmt, ap);
 | 
				
			||||||
		va_end(ap);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		evbuffer_add(c->stdout_data, "\n", 1);
 | 
							evbuffer_add(c->stdout_data, "\n", 1);
 | 
				
			||||||
		server_push_stdout(c);
 | 
							server_push_stdout(c);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,13 +94,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
		cp = format_expand(ft, args_get(args, 'c'));
 | 
							cp = format_expand(ft, args_get(args, 'c'));
 | 
				
			||||||
		format_free(ft);
 | 
							format_free(ft);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fd = open(cp, O_RDONLY|O_DIRECTORY);
 | 
							if (cp != NULL && *cp != '\0') {
 | 
				
			||||||
		free(cp);
 | 
								fd = open(cp, O_RDONLY|O_DIRECTORY);
 | 
				
			||||||
		if (fd == -1) {
 | 
								free(cp);
 | 
				
			||||||
			cmdq_error(cmdq, "bad working directory: %s",
 | 
								if (fd == -1) {
 | 
				
			||||||
			    strerror(errno));
 | 
									cmdq_error(cmdq, "bad working directory: %s",
 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
									    strerror(errno));
 | 
				
			||||||
		}
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else if (cp != NULL)
 | 
				
			||||||
 | 
								free(cp);
 | 
				
			||||||
		cwd = fd;
 | 
							cwd = fd;
 | 
				
			||||||
	} else if (cmdq->client != NULL && cmdq->client->session == NULL)
 | 
						} else if (cmdq->client != NULL && cmdq->client->session == NULL)
 | 
				
			||||||
		cwd = cmdq->client->cwd;
 | 
							cwd = cmdq->client->cwd;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,9 +59,13 @@ cmd_switch_client_key_binding(struct cmd *self, int key)
 | 
				
			|||||||
enum cmd_retval
 | 
					enum cmd_retval
 | 
				
			||||||
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
					cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct args	*args = self->args;
 | 
						struct args		*args = self->args;
 | 
				
			||||||
	struct client	*c;
 | 
						struct client		*c;
 | 
				
			||||||
	struct session	*s;
 | 
						struct session		*s;
 | 
				
			||||||
 | 
						struct winlink		*wl = NULL;
 | 
				
			||||||
 | 
						struct window 		*w = NULL;
 | 
				
			||||||
 | 
						struct window_pane	*wp = NULL;
 | 
				
			||||||
 | 
						const char		*tflag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL)
 | 
						if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL)
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
							return (CMD_RETURN_ERROR);
 | 
				
			||||||
@@ -76,7 +80,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s = NULL;
 | 
						tflag = args_get(args, 't');
 | 
				
			||||||
	if (args_has(args, 'n')) {
 | 
						if (args_has(args, 'n')) {
 | 
				
			||||||
		if ((s = session_next_session(c->session)) == NULL) {
 | 
							if ((s = session_next_session(c->session)) == NULL) {
 | 
				
			||||||
			cmdq_error(cmdq, "can't find next session");
 | 
								cmdq_error(cmdq, "can't find next session");
 | 
				
			||||||
@@ -94,10 +98,33 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
				
			|||||||
			cmdq_error(cmdq, "can't find last session");
 | 
								cmdq_error(cmdq, "can't find last session");
 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else
 | 
						} else {
 | 
				
			||||||
		s = cmd_find_session(cmdq, args_get(args, 't'), 0);
 | 
							if (tflag == NULL) {
 | 
				
			||||||
	if (s == NULL)
 | 
								if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
							} else if (tflag[strcspn(tflag, ":.")] != '\0') {
 | 
				
			||||||
 | 
								if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL)
 | 
				
			||||||
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
 | 
				
			||||||
 | 
									return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
								w = cmd_lookup_windowid(tflag);
 | 
				
			||||||
 | 
								if (w == NULL &&
 | 
				
			||||||
 | 
								    (wp = cmd_lookup_paneid(tflag)) != NULL)
 | 
				
			||||||
 | 
									w = wp->window;
 | 
				
			||||||
 | 
								if (w != NULL)
 | 
				
			||||||
 | 
									wl = winlink_find_by_window(&s->windows, w);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (cmdq->client == NULL)
 | 
				
			||||||
 | 
								return (CMD_RETURN_NORMAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (wl != NULL) {
 | 
				
			||||||
 | 
								if (wp != NULL)
 | 
				
			||||||
 | 
									window_set_active_pane(wp->window, wp);
 | 
				
			||||||
 | 
								session_set_current(s, wl);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (c->session != NULL)
 | 
						if (c->session != NULL)
 | 
				
			||||||
		c->last_session = c->session;
 | 
							c->last_session = c->session;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								cmd.c
									
									
									
									
									
								
							@@ -125,9 +125,7 @@ struct session	*cmd_lookup_session(const char *, int *);
 | 
				
			|||||||
struct session	*cmd_lookup_session_id(const char *);
 | 
					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 window_pane *cmd_lookup_paneid(const char *);
 | 
					 | 
				
			||||||
struct winlink	*cmd_lookup_winlink_windowid(struct session *, const char *);
 | 
					struct winlink	*cmd_lookup_winlink_windowid(struct session *, const char *);
 | 
				
			||||||
struct window	*cmd_lookup_windowid(const char *);
 | 
					 | 
				
			||||||
struct session	*cmd_window_session(struct cmd_q *, struct window *,
 | 
					struct session	*cmd_window_session(struct cmd_q *, struct window *,
 | 
				
			||||||
		    struct winlink **);
 | 
							    struct winlink **);
 | 
				
			||||||
struct winlink	*cmd_find_window_offset(const char *, struct session *, int *);
 | 
					struct winlink	*cmd_find_window_offset(const char *, struct session *, int *);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								format.c
									
									
									
									
									
								
							@@ -321,6 +321,13 @@ format_expand(struct format_tree *ft, const char *fmt)
 | 
				
			|||||||
				break;
 | 
									break;
 | 
				
			||||||
			fmt += n + 1;
 | 
								fmt += n + 1;
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
							case '#':
 | 
				
			||||||
 | 
								while (len - off < 2) {
 | 
				
			||||||
 | 
									buf = xrealloc(buf, 2, len);
 | 
				
			||||||
 | 
									len *= 2;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								buf[off++] = '#';
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			s = NULL;
 | 
								s = NULL;
 | 
				
			||||||
			if (ch >= 'A' && ch <= 'Z')
 | 
								if (ch >= 'A' && ch <= 'Z')
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								grid.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								grid.c
									
									
									
									
									
								
							@@ -124,7 +124,7 @@ grid_compare(struct grid *ga, struct grid *gb)
 | 
				
			|||||||
	struct grid_cell	*gca, *gcb;
 | 
						struct grid_cell	*gca, *gcb;
 | 
				
			||||||
	u_int			 xx, yy;
 | 
						u_int			 xx, yy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ga->sx != gb->sx || ga->sy != ga->sy)
 | 
						if (ga->sx != gb->sx || ga->sy != gb->sy)
 | 
				
			||||||
		return (1);
 | 
							return (1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (yy = 0; yy < ga->sy; yy++) {
 | 
						for (yy = 0; yy < ga->sy; yy++) {
 | 
				
			||||||
@@ -644,7 +644,7 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx,
 | 
				
			|||||||
        if (trim) {
 | 
					        if (trim) {
 | 
				
			||||||
		while (off > 0 && buf[off - 1] == ' ')
 | 
							while (off > 0 && buf[off - 1] == ' ')
 | 
				
			||||||
			off--;
 | 
								off--;
 | 
				
			||||||
        }
 | 
						}
 | 
				
			||||||
	buf[off] = '\0';
 | 
						buf[off] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (buf);
 | 
						return (buf);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,7 +26,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Option handling; each option has a name, type and value and is stored in
 | 
					 * Option handling; each option has a name, type and value and is stored in
 | 
				
			||||||
 * a splay tree.
 | 
					 * a red-black tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RB_GENERATE(options_tree, options_entry, entry, options_cmp);
 | 
					RB_GENERATE(options_tree, options_entry, entry, options_cmp);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								screen.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								screen.c
									
									
									
									
									
								
							@@ -111,12 +111,8 @@ screen_set_cursor_colour(struct screen *s, const char *colour_string)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
screen_set_title(struct screen *s, const char *title)
 | 
					screen_set_title(struct screen *s, const char *title)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char	tmp[BUFSIZ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	strlcpy(tmp, title, sizeof tmp);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	free(s->title);
 | 
						free(s->title);
 | 
				
			||||||
	s->title = xstrdup(tmp);
 | 
						s->title = xstrdup(title);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Resize screen. */
 | 
					/* Resize screen. */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.1
									
									
									
									
									
								
							@@ -3015,6 +3015,9 @@ for example
 | 
				
			|||||||
.Ql #{session_name} .
 | 
					.Ql #{session_name} .
 | 
				
			||||||
Some variables also have an shorter alias such as
 | 
					Some variables also have an shorter alias such as
 | 
				
			||||||
.Ql #S .
 | 
					.Ql #S .
 | 
				
			||||||
 | 
					.Ql ##
 | 
				
			||||||
 | 
					is replaced by a single
 | 
				
			||||||
 | 
					.Ql # .
 | 
				
			||||||
Conditionals are also accepted by prefixing with
 | 
					Conditionals are also accepted by prefixing with
 | 
				
			||||||
.Ql \&?
 | 
					.Ql \&?
 | 
				
			||||||
and separating two alternatives with a comma;
 | 
					and separating two alternatives with a comma;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								tmux.c
									
									
									
									
									
								
							@@ -205,8 +205,9 @@ int
 | 
				
			|||||||
main(int argc, char **argv)
 | 
					main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct passwd	*pw;
 | 
						struct passwd	*pw;
 | 
				
			||||||
	char		*s, *path, *label, *home, **var, tmp[MAXPATHLEN];
 | 
						char		*s, *path, *label, **var, tmp[MAXPATHLEN];
 | 
				
			||||||
	char		 in[256];
 | 
						char		 in[256];
 | 
				
			||||||
 | 
						const char	*home;
 | 
				
			||||||
	long long	 pid;
 | 
						long long	 pid;
 | 
				
			||||||
	int	 	 opt, flags, quiet, keys, session;
 | 
						int	 	 opt, flags, quiet, keys, session;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -331,11 +332,15 @@ main(int argc, char **argv)
 | 
				
			|||||||
			pw = getpwuid(getuid());
 | 
								pw = getpwuid(getuid());
 | 
				
			||||||
			if (pw != NULL)
 | 
								if (pw != NULL)
 | 
				
			||||||
				home = pw->pw_dir;
 | 
									home = pw->pw_dir;
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									home = NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		xasprintf(&cfg_file, "%s/.tmux.conf", home);
 | 
							if (home != NULL) {
 | 
				
			||||||
		if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
 | 
								xasprintf(&cfg_file, "%s/.tmux.conf", home);
 | 
				
			||||||
			free(cfg_file);
 | 
								if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
 | 
				
			||||||
			cfg_file = NULL;
 | 
									free(cfg_file);
 | 
				
			||||||
 | 
									cfg_file = NULL;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -367,7 +372,11 @@ main(int argc, char **argv)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	free(label);
 | 
						free(label);
 | 
				
			||||||
	strlcpy(socket_path, path, sizeof socket_path);
 | 
					
 | 
				
			||||||
 | 
						if (strlcpy(socket_path, path, sizeof socket_path) >= sizeof socket_path) {
 | 
				
			||||||
 | 
							fprintf(stderr, "socket path too long: %s\n", path);
 | 
				
			||||||
 | 
							exit(1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	free(path);
 | 
						free(path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_SETPROCTITLE
 | 
					#ifdef HAVE_SETPROCTITLE
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1732,6 +1732,8 @@ 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;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										64
									
								
								tty-acs.c
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								tty-acs.c
									
									
									
									
									
								
							@@ -30,38 +30,38 @@ struct tty_acs_entry {
 | 
				
			|||||||
	const char	*string;
 | 
						const char	*string;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
const struct tty_acs_entry tty_acs_table[] = {
 | 
					const struct tty_acs_entry tty_acs_table[] = {
 | 
				
			||||||
	{ '+', "\342\206\222" },
 | 
						{ '+', "\342\206\222" },	/* arrow pointing right */
 | 
				
			||||||
	{ ',', "\342\206\220" },
 | 
						{ ',', "\342\206\220" },	/* arrow pointing left */
 | 
				
			||||||
	{ '-', "\342\206\221" },
 | 
						{ '-', "\342\206\221" },	/* arrow pointing up */
 | 
				
			||||||
	{ '.', "\342\206\223" },
 | 
						{ '.', "\342\206\223" },	/* arrow pointing down */
 | 
				
			||||||
	{ '0', "\342\226\256" },
 | 
						{ '0', "\342\226\256" },	/* solid square block */
 | 
				
			||||||
	{ '`', "\342\227\206" },
 | 
						{ '`', "\342\227\206" },	/* diamond */
 | 
				
			||||||
	{ 'a', "\342\226\222" },
 | 
						{ 'a', "\342\226\222" },	/* checker board (stipple) */
 | 
				
			||||||
	{ 'f', "\302\260" },
 | 
						{ 'f', "\302\260" },		/* degree symbol */
 | 
				
			||||||
	{ 'g', "\302\261" },
 | 
						{ 'g', "\302\261" },		/* plus/minus */
 | 
				
			||||||
	{ 'h', "\342\226\222" },
 | 
						{ 'h', "\342\226\222" },	/* board of squares */
 | 
				
			||||||
	{ 'i', "\342\230\203" },
 | 
						{ 'i', "\342\230\203" },	/* lantern symbol */
 | 
				
			||||||
	{ 'j', "\342\224\230" },
 | 
						{ 'j', "\342\224\230" },	/* lower right corner */
 | 
				
			||||||
	{ 'k', "\342\224\220" },
 | 
						{ 'k', "\342\224\220" },	/* upper right corner */
 | 
				
			||||||
	{ 'l', "\342\224\214" },
 | 
						{ 'l', "\342\224\214" },	/* upper left corner */
 | 
				
			||||||
	{ 'm', "\342\224\224" },
 | 
						{ 'm', "\342\224\224" },	/* lower left corner */
 | 
				
			||||||
	{ 'n', "\342\224\274" },
 | 
						{ 'n', "\342\224\274" },	/* large plus or crossover */
 | 
				
			||||||
	{ 'o', "\342\216\272" },
 | 
						{ 'o', "\342\216\272" },	/* scan line 1 */
 | 
				
			||||||
	{ 'p', "\342\216\273" },
 | 
						{ 'p', "\342\216\273" },	/* scan line 3 */
 | 
				
			||||||
	{ 'q', "\342\224\200" },
 | 
						{ 'q', "\342\224\200" },	/* horizontal line */
 | 
				
			||||||
	{ 'r', "\342\216\274" },
 | 
						{ 'r', "\342\216\274" },	/* scan line 7 */
 | 
				
			||||||
	{ 's', "\342\216\275" },
 | 
						{ 's', "\342\216\275" },	/* scan line 9 */
 | 
				
			||||||
	{ 't', "\342\224\234" },
 | 
						{ 't', "\342\224\234" },	/* tee pointing right */
 | 
				
			||||||
	{ 'u', "\342\224\244" },
 | 
						{ 'u', "\342\224\244" },	/* tee pointing left */
 | 
				
			||||||
	{ 'v', "\342\224\264" },
 | 
						{ 'v', "\342\224\264" },	/* tee pointing up */
 | 
				
			||||||
	{ 'w', "\342\224\254" },
 | 
						{ 'w', "\342\224\254" },	/* tee pointing down */
 | 
				
			||||||
	{ 'x', "\342\224\202" },
 | 
						{ 'x', "\342\224\202" },	/* vertical line */
 | 
				
			||||||
	{ 'y', "\342\211\244" },
 | 
						{ 'y', "\342\211\244" },	/* less-than-or-equal-to */
 | 
				
			||||||
	{ 'z', "\342\211\245" },
 | 
						{ 'z', "\342\211\245" },	/* greater-than-or-equal-to */
 | 
				
			||||||
	{ '{', "\317\200" },
 | 
						{ '{', "\317\200" },   		/* greek pi */
 | 
				
			||||||
	{ '|', "\342\211\240" },
 | 
						{ '|', "\342\211\240" },	/* not-equal */
 | 
				
			||||||
	{ '}', "\302\243" },
 | 
						{ '}', "\302\243" },		/* UK pound sign */
 | 
				
			||||||
	{ '~', "\302\267" }
 | 
						{ '~', "\302\267" }		/* bullet */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -345,8 +345,7 @@ window_choose_collapse(struct window_pane *wp, struct session *s)
 | 
				
			|||||||
	 * assign the actual result we want to render and copy the new one over
 | 
						 * assign the actual result we want to render and copy the new one over
 | 
				
			||||||
	 * the top of it.
 | 
						 * the top of it.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&data->list); i++)
 | 
						for (i = 0; i < ARRAY_LENGTH(&data->list); i++) {
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		item = &ARRAY_ITEM(&data->list, i);
 | 
							item = &ARRAY_ITEM(&data->list, i);
 | 
				
			||||||
		wcd = item->wcd;
 | 
							wcd = item->wcd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1030,7 +1030,7 @@ window_copy_search_up(struct window_pane *wp, const char *searchstr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cis = 1;
 | 
						cis = 1;
 | 
				
			||||||
	for (ptr = searchstr; *ptr != '\0'; ptr++) {
 | 
						for (ptr = searchstr; *ptr != '\0'; ptr++) {
 | 
				
			||||||
		if (*ptr != tolower(*ptr)) {
 | 
							if (*ptr != tolower((u_char)*ptr)) {
 | 
				
			||||||
			cis = 0;
 | 
								cis = 0;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -1097,7 +1097,7 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cis = 1;
 | 
						cis = 1;
 | 
				
			||||||
	for (ptr = searchstr; *ptr != '\0'; ptr++) {
 | 
						for (ptr = searchstr; *ptr != '\0'; ptr++) {
 | 
				
			||||||
		if (*ptr != tolower(*ptr)) {
 | 
							if (*ptr != tolower((u_char)*ptr)) {
 | 
				
			||||||
			cis = 0;
 | 
								cis = 0;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user