From: nicm Date: Fri, 13 Aug 2021 19:55:11 +0000 (+0000) Subject: Fill in some other bits on new panes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5edeef37ad50e509fd6495c234c8d4d562e33f82;p=openbsd Fill in some other bits on new panes. --- diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c index db67647ef36..df0774240ac 100644 --- a/usr.bin/tmux/job.c +++ b/usr.bin/tmux/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.61 2021/08/13 19:27:25 nicm Exp $ */ +/* $OpenBSD: job.c,v 1.62 2021/08/13 19:55:11 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -52,6 +52,7 @@ struct job { char *cmd; pid_t pid; + char tty[TTY_NAME_MAX]; int status; int fd; @@ -81,7 +82,7 @@ job_run(const char *cmd, int argc, char **argv, struct session *s, const char *home; sigset_t set, oldset; 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 @@ -96,7 +97,7 @@ job_run(const char *cmd, int argc, char **argv, struct session *s, memset(&ws, 0, sizeof ws); ws.ws_col = sx; ws.ws_row = sy; - pid = fdforkpty(ptm_fd, &master, NULL, NULL, &ws); + pid = fdforkpty(ptm_fd, &master, tty, NULL, &ws); } else { if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0) goto fail; @@ -170,6 +171,7 @@ job_run(const char *cmd, int argc, char **argv, struct session *s, else job->cmd = cmd_stringify_argv(argc, argv); job->pid = pid; + strlcpy(job->tty, tty, sizeof job->tty); job->status = 0; LIST_INSERT_HEAD(&all_jobs, job, entry); @@ -203,12 +205,17 @@ fail: /* Take job's file descriptor and free the job. */ int -job_transfer(struct job *job) +job_transfer(struct job *job, pid_t *pid, char *tty, size_t ttylen) { int fd = job->fd; 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); free(job->cmd); diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c index dfe486694eb..56e7c46d965 100644 --- a/usr.bin/tmux/popup.c +++ b/usr.bin/tmux/popup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popup.c,v 1.29 2021/08/13 19:27:25 nicm Exp $ */ +/* $OpenBSD: popup.c,v 1.30 2021/08/13 19:55:11 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott @@ -78,8 +78,8 @@ static const struct menu_item popup_menu_items[] = { { "Fill Space", 'F', NULL }, { "Centre", 'C', NULL }, { "", KEYC_NONE, NULL }, - { "Make Pane (H)", 'h', NULL }, - { "Make Pane (V)", 'v', NULL }, + { "To Horizontal Pane", 'h', NULL }, + { "To Vertical Pane", 'v', 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 window_pane *wp = w->active, *new_wp; u_int hlimit; + const char *shell; 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); 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; + screen_set_title(&pd->s, new_wp->base.title); screen_free(&new_wp->base); memcpy(&new_wp->base, &pd->s, sizeof wp->base); screen_resize(&new_wp->base, new_wp->sx, new_wp->sy, 1); 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_set_active_pane(w, new_wp, 1); + new_wp->flags |= PANE_CHANGED; pd->close = 1; } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 865ca1e82c9..e7878436f33 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1121 2021/08/13 19:27:25 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1122 2021/08/13 19:55:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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, void *, int, int, int); 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_check_died(pid_t, int); int job_get_status(struct job *);