mirror of
https://github.com/tmux/tmux.git
synced 2026-10-12 21:54:23 +00:00
Add -E to new-window and respawn-pane and respawn-window to create empty
panes.
This commit is contained in:
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
.name = "new-window",
|
.name = "new-window",
|
||||||
.alias = "neww",
|
.alias = "neww",
|
||||||
|
|
||||||
.args = { "abc:de:F:kn:PSt:", 0, -1, NULL },
|
.args = { "abc:de:EF:kn:PSt:", 0, -1, NULL },
|
||||||
.usage = "[-abdkPS] [-c start-directory] [-e environment] [-F format] "
|
.usage = "[-abdEkPS] [-c start-directory] [-e environment] [-F format] "
|
||||||
"[-n window-name] " CMD_TARGET_WINDOW_USAGE
|
"[-n window-name] " CMD_TARGET_WINDOW_USAGE
|
||||||
" [shell-command [argument ...]]",
|
" [shell-command [argument ...]]",
|
||||||
|
|
||||||
@@ -60,12 +60,19 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
struct client *tc = cmdq_get_target_client(item);
|
struct client *tc = cmdq_get_target_client(item);
|
||||||
struct session *s = target->s;
|
struct session *s = target->s;
|
||||||
struct winlink *wl = target->wl, *new_wl = NULL;
|
struct winlink *wl = target->wl, *new_wl = NULL;
|
||||||
int idx = target->idx, before;
|
int idx = target->idx, before, count = args_count(args);
|
||||||
char *cause = NULL, *cp, *expanded, *wname = NULL;
|
char *cause = NULL, *cp, *expanded, *wname = NULL;
|
||||||
const char *template, *name;
|
const char *template, *name;
|
||||||
struct cmd_find_state fs;
|
struct cmd_find_state fs;
|
||||||
struct args_value *av;
|
struct args_value *av;
|
||||||
|
|
||||||
|
if (args_has(args, 'E') &&
|
||||||
|
count != 0 &&
|
||||||
|
(count != 1 || *args_string(args, 0) != '\0')) {
|
||||||
|
cmdq_error(item, "command cannot be given for empty pane");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If -S and -n are given and -t is not and a single window with this
|
* If -S and -n are given and -t is not and a single window with this
|
||||||
* name already exists, select it.
|
* name already exists, select it.
|
||||||
@@ -134,6 +141,8 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
sc.cwd = args_get(args, 'c');
|
sc.cwd = args_get(args, 'c');
|
||||||
|
|
||||||
sc.flags = 0;
|
sc.flags = 0;
|
||||||
|
if (args_has(args, 'E'))
|
||||||
|
sc.flags |= SPAWN_EMPTY;
|
||||||
if (args_has(args, 'd'))
|
if (args_has(args, 'd'))
|
||||||
sc.flags |= SPAWN_DETACHED;
|
sc.flags |= SPAWN_DETACHED;
|
||||||
if (args_has(args, 'k'))
|
if (args_has(args, 'k'))
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
|||||||
.name = "respawn-pane",
|
.name = "respawn-pane",
|
||||||
.alias = "respawnp",
|
.alias = "respawnp",
|
||||||
|
|
||||||
.args = { "c:e:kt:", 0, -1, NULL },
|
.args = { "c:e:Ekt:", 0, -1, NULL },
|
||||||
.usage = "[-k] [-c start-directory] [-e environment] "
|
.usage = "[-Ek] [-c start-directory] [-e environment] "
|
||||||
CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
|
CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -75,6 +75,8 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
sc.cwd = args_get(args, 'c');
|
sc.cwd = args_get(args, 'c');
|
||||||
|
|
||||||
sc.flags = SPAWN_RESPAWN;
|
sc.flags = SPAWN_RESPAWN;
|
||||||
|
if (args_has(args, 'E'))
|
||||||
|
sc.flags |= SPAWN_EMPTY;
|
||||||
if (args_has(args, 'k'))
|
if (args_has(args, 'k'))
|
||||||
sc.flags |= SPAWN_KILL;
|
sc.flags |= SPAWN_KILL;
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
|||||||
.name = "respawn-window",
|
.name = "respawn-window",
|
||||||
.alias = "respawnw",
|
.alias = "respawnw",
|
||||||
|
|
||||||
.args = { "c:e:kt:", 0, -1, NULL },
|
.args = { "c:e:Ekt:", 0, -1, NULL },
|
||||||
.usage = "[-k] [-c start-directory] [-e environment] "
|
.usage = "[-Ek] [-c start-directory] [-e environment] "
|
||||||
CMD_TARGET_WINDOW_USAGE " [shell-command [argument ...]]",
|
CMD_TARGET_WINDOW_USAGE " [shell-command [argument ...]]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
@@ -74,6 +74,8 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
sc.cwd = args_get(args, 'c');
|
sc.cwd = args_get(args, 'c');
|
||||||
|
|
||||||
sc.flags = SPAWN_RESPAWN;
|
sc.flags = SPAWN_RESPAWN;
|
||||||
|
if (args_has(args, 'E'))
|
||||||
|
sc.flags |= SPAWN_EMPTY;
|
||||||
if (args_has(args, 'k'))
|
if (args_has(args, 'k'))
|
||||||
sc.flags |= SPAWN_KILL;
|
sc.flags |= SPAWN_KILL;
|
||||||
|
|
||||||
|
|||||||
13
spawn.c
13
spawn.c
@@ -266,14 +266,20 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
free(cwd);
|
free(cwd);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (sc->wp0->fd != -1) {
|
if (sc->wp0->event != NULL) {
|
||||||
bufferevent_free(sc->wp0->event);
|
bufferevent_free(sc->wp0->event);
|
||||||
|
sc->wp0->event = NULL;
|
||||||
|
}
|
||||||
|
if (sc->wp0->fd != -1) {
|
||||||
close(sc->wp0->fd);
|
close(sc->wp0->fd);
|
||||||
|
sc->wp0->fd = -1;
|
||||||
}
|
}
|
||||||
window_pane_reset_mode_all(sc->wp0);
|
window_pane_reset_mode_all(sc->wp0);
|
||||||
screen_reinit(&sc->wp0->base);
|
screen_reinit(&sc->wp0->base);
|
||||||
input_free(sc->wp0->ictx);
|
if (sc->wp0->ictx != NULL) {
|
||||||
sc->wp0->ictx = NULL;
|
input_free(sc->wp0->ictx);
|
||||||
|
sc->wp0->ictx = NULL;
|
||||||
|
}
|
||||||
new_wp = sc->wp0;
|
new_wp = sc->wp0;
|
||||||
new_wp->flags &= ~(PANE_STATUSREADY|PANE_STATUSDRAWN);
|
new_wp->flags &= ~(PANE_STATUSREADY|PANE_STATUSDRAWN);
|
||||||
} else {
|
} else {
|
||||||
@@ -389,6 +395,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
new_wp->base.mode |= MODE_CRLF;
|
new_wp->base.mode |= MODE_CRLF;
|
||||||
goto complete;
|
goto complete;
|
||||||
}
|
}
|
||||||
|
new_wp->flags &= ~PANE_EMPTY;
|
||||||
|
|
||||||
/* Store current working directory and change to new one. */
|
/* Store current working directory and change to new one. */
|
||||||
if (getcwd(path, sizeof path) != NULL) {
|
if (getcwd(path, sizeof path) != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user