version 1.12, 2009/12/03 22:50:10 |
version 1.13, 2011/01/04 00:42:47 |
|
|
|
|
const struct cmd_entry cmd_respawn_window_entry = { |
const struct cmd_entry cmd_respawn_window_entry = { |
"respawn-window", "respawnw", |
"respawn-window", "respawnw", |
|
"kt:", 0, 1, |
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]", |
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]", |
CMD_ARG01, "k", |
0, |
cmd_target_init, |
NULL, |
cmd_target_parse, |
NULL, |
cmd_respawn_window_exec, |
cmd_respawn_window_exec |
cmd_target_free, |
|
cmd_target_print |
|
}; |
}; |
|
|
int |
int |
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct cmd_target_data *data = self->data; |
struct args *args = self->args; |
struct winlink *wl; |
struct winlink *wl; |
struct window *w; |
struct window *w; |
struct window_pane *wp; |
struct window_pane *wp; |
struct session *s; |
struct session *s; |
struct environ env; |
struct environ env; |
|
const char *cmd; |
char *cause; |
char *cause; |
|
|
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL) |
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL) |
return (-1); |
return (-1); |
w = wl->window; |
w = wl->window; |
|
|
if (!cmd_check_flag(data->chflags, 'k')) { |
if (!args_has(self->args, 'k')) { |
TAILQ_FOREACH(wp, &w->panes, entry) { |
TAILQ_FOREACH(wp, &w->panes, entry) { |
if (wp->fd == -1) |
if (wp->fd == -1) |
continue; |
continue; |
|
|
window_destroy_panes(w); |
window_destroy_panes(w); |
TAILQ_INSERT_HEAD(&w->panes, wp, entry); |
TAILQ_INSERT_HEAD(&w->panes, wp, entry); |
window_pane_resize(wp, w->sx, w->sy); |
window_pane_resize(wp, w->sx, w->sy); |
if (window_pane_spawn( |
if (args->argc != 0) |
wp, data->arg, NULL, NULL, &env, s->tio, &cause) != 0) { |
cmd = args->argv[0]; |
|
else |
|
cmd = NULL; |
|
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { |
ctx->error(ctx, "respawn window failed: %s", cause); |
ctx->error(ctx, "respawn window failed: %s", cause); |
xfree(cause); |
xfree(cause); |
environ_free(&env); |
environ_free(&env); |