mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Fill in some other bits on new panes.
This commit is contained in:
		
							
								
								
									
										13
									
								
								job.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								job.c
									
									
									
									
									
								
							@@ -52,6 +52,7 @@ struct job {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	char			*cmd;
 | 
						char			*cmd;
 | 
				
			||||||
	pid_t			 pid;
 | 
						pid_t			 pid;
 | 
				
			||||||
 | 
						char		         tty[TTY_NAME_MAX];
 | 
				
			||||||
	int			 status;
 | 
						int			 status;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int			 fd;
 | 
						int			 fd;
 | 
				
			||||||
@@ -81,7 +82,7 @@ job_run(const char *cmd, int argc, char **argv, struct session *s,
 | 
				
			|||||||
	const char	 *home;
 | 
						const char	 *home;
 | 
				
			||||||
	sigset_t	  set, oldset;
 | 
						sigset_t	  set, oldset;
 | 
				
			||||||
	struct winsize	  ws;
 | 
						struct winsize	  ws;
 | 
				
			||||||
	char		**argvp;
 | 
						char		**argvp, tty[TTY_NAME_MAX];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Do not set TERM during .tmux.conf, it is nice to be able to use
 | 
						 * Do not set TERM during .tmux.conf, it is nice to be able to use
 | 
				
			||||||
@@ -96,7 +97,7 @@ job_run(const char *cmd, int argc, char **argv, struct session *s,
 | 
				
			|||||||
		memset(&ws, 0, sizeof ws);
 | 
							memset(&ws, 0, sizeof ws);
 | 
				
			||||||
		ws.ws_col = sx;
 | 
							ws.ws_col = sx;
 | 
				
			||||||
		ws.ws_row = sy;
 | 
							ws.ws_row = sy;
 | 
				
			||||||
		pid = fdforkpty(ptm_fd, &master, NULL, NULL, &ws);
 | 
							pid = fdforkpty(ptm_fd, &master, tty, NULL, &ws);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
 | 
							if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
 | 
				
			||||||
			goto fail;
 | 
								goto fail;
 | 
				
			||||||
@@ -170,6 +171,7 @@ job_run(const char *cmd, int argc, char **argv, struct session *s,
 | 
				
			|||||||
	else
 | 
						else
 | 
				
			||||||
		job->cmd = cmd_stringify_argv(argc, argv);
 | 
							job->cmd = cmd_stringify_argv(argc, argv);
 | 
				
			||||||
	job->pid = pid;
 | 
						job->pid = pid;
 | 
				
			||||||
 | 
						strlcpy(job->tty, tty, sizeof job->tty);
 | 
				
			||||||
	job->status = 0;
 | 
						job->status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LIST_INSERT_HEAD(&all_jobs, job, entry);
 | 
						LIST_INSERT_HEAD(&all_jobs, job, entry);
 | 
				
			||||||
@@ -203,12 +205,17 @@ fail:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Take job's file descriptor and free the job. */
 | 
					/* Take job's file descriptor and free the job. */
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
job_transfer(struct job *job)
 | 
					job_transfer(struct job *job, pid_t *pid, char *tty, size_t ttylen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int	fd = job->fd;
 | 
						int	fd = job->fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log_debug("transfer job %p: %s", job, job->cmd);
 | 
						log_debug("transfer job %p: %s", job, job->cmd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (pid != NULL)
 | 
				
			||||||
 | 
							*pid = job->pid;
 | 
				
			||||||
 | 
						if (tty != NULL)
 | 
				
			||||||
 | 
							strlcpy(tty, job->tty, ttylen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LIST_REMOVE(job, entry);
 | 
						LIST_REMOVE(job, entry);
 | 
				
			||||||
	free(job->cmd);
 | 
						free(job->cmd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								popup.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								popup.c
									
									
									
									
									
								
							@@ -78,8 +78,8 @@ static const struct menu_item popup_menu_items[] = {
 | 
				
			|||||||
	{ "Fill Space", 'F', NULL },
 | 
						{ "Fill Space", 'F', NULL },
 | 
				
			||||||
	{ "Centre", 'C', NULL },
 | 
						{ "Centre", 'C', NULL },
 | 
				
			||||||
	{ "", KEYC_NONE, NULL },
 | 
						{ "", KEYC_NONE, NULL },
 | 
				
			||||||
	{ "Make Pane (H)", 'h', NULL },
 | 
						{ "To Horizontal Pane", 'h', NULL },
 | 
				
			||||||
	{ "Make Pane (V)", 'v', NULL },
 | 
						{ "To Vertical Pane", 'v', NULL },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ NULL, KEYC_NONE, NULL }
 | 
						{ NULL, KEYC_NONE, NULL }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -299,6 +299,7 @@ popup_make_pane(struct popup_data *pd, enum layout_type type)
 | 
				
			|||||||
	struct layout_cell	*lc;
 | 
						struct layout_cell	*lc;
 | 
				
			||||||
	struct window_pane	*wp = w->active, *new_wp;
 | 
						struct window_pane	*wp = w->active, *new_wp;
 | 
				
			||||||
	u_int			 hlimit;
 | 
						u_int			 hlimit;
 | 
				
			||||||
 | 
						const char		*shell;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window_unzoom(w);
 | 
						window_unzoom(w);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -307,16 +308,24 @@ popup_make_pane(struct popup_data *pd, enum layout_type type)
 | 
				
			|||||||
	new_wp = window_add_pane(wp->window, NULL, hlimit, 0);
 | 
						new_wp = window_add_pane(wp->window, NULL, hlimit, 0);
 | 
				
			||||||
	layout_assign_pane(lc, new_wp, 0);
 | 
						layout_assign_pane(lc, new_wp, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	new_wp->fd = job_transfer(pd->job);
 | 
						new_wp->fd = job_transfer(pd->job, &new_wp->pid, new_wp->tty,
 | 
				
			||||||
 | 
						    sizeof new_wp->tty);
 | 
				
			||||||
	pd->job = NULL;
 | 
						pd->job = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						screen_set_title(&pd->s, new_wp->base.title);
 | 
				
			||||||
	screen_free(&new_wp->base);
 | 
						screen_free(&new_wp->base);
 | 
				
			||||||
	memcpy(&new_wp->base, &pd->s, sizeof wp->base);
 | 
						memcpy(&new_wp->base, &pd->s, sizeof wp->base);
 | 
				
			||||||
	screen_resize(&new_wp->base, new_wp->sx, new_wp->sy, 1);
 | 
						screen_resize(&new_wp->base, new_wp->sx, new_wp->sy, 1);
 | 
				
			||||||
	screen_init(&pd->s, 1, 1, 0);
 | 
						screen_init(&pd->s, 1, 1, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						shell = options_get_string(s->options, "default-shell");
 | 
				
			||||||
 | 
						if (!checkshell(shell))
 | 
				
			||||||
 | 
							shell = _PATH_BSHELL;
 | 
				
			||||||
 | 
						new_wp->shell = xstrdup(shell);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window_pane_set_event(new_wp);
 | 
						window_pane_set_event(new_wp);
 | 
				
			||||||
	window_set_active_pane(w, new_wp, 1);
 | 
						window_set_active_pane(w, new_wp, 1);
 | 
				
			||||||
 | 
						new_wp->flags |= PANE_CHANGED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pd->close = 1;
 | 
						pd->close = 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							@@ -2042,7 +2042,7 @@ struct job	*job_run(const char *, int, char **, struct session *,
 | 
				
			|||||||
		     const char *, job_update_cb, job_complete_cb, job_free_cb,
 | 
							     const char *, job_update_cb, job_complete_cb, job_free_cb,
 | 
				
			||||||
		     void *, int, int, int);
 | 
							     void *, int, int, int);
 | 
				
			||||||
void		 job_free(struct job *);
 | 
					void		 job_free(struct job *);
 | 
				
			||||||
int		 job_transfer(struct job *);
 | 
					int		 job_transfer(struct job *, pid_t *, char *, size_t);
 | 
				
			||||||
void		 job_resize(struct job *, u_int, u_int);
 | 
					void		 job_resize(struct job *, u_int, u_int);
 | 
				
			||||||
void		 job_check_died(pid_t, int);
 | 
					void		 job_check_died(pid_t, int);
 | 
				
			||||||
int		 job_get_status(struct job *);
 | 
					int		 job_get_status(struct job *);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user