summaryrefslogtreecommitdiffstats
path: root/cmd-new-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-21 22:21:49 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-21 22:21:49 +0000
commit9acc26711d180e45ff827d8b88b4adbf20fab949 (patch)
treee1f0e0005dbc09a33941f0354048d784673e57f1 /cmd-new-window.c
parent19987feaaab86e19533ca59a8ae0ff535f23db75 (diff)
new-window -k.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r--cmd-new-window.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c
index f9dec3ee..921a47d6 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-window.c,v 1.29 2009-01-19 18:23:40 nicm Exp $ */
+/* $Id: cmd-new-window.c,v 1.30 2009-01-21 22:21:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -39,11 +39,12 @@ struct cmd_new_window_data {
char *name;
char *cmd;
int flag_detached;
+ int flag_kill;
};
const struct cmd_entry cmd_new_window_entry = {
"new-window", "neww",
- "[-d] [-n window-name] [-t target-window] [command]",
+ "[-dk] [-n window-name] [-t target-window] [command]",
0,
cmd_new_window_init,
cmd_new_window_parse,
@@ -64,6 +65,7 @@ cmd_new_window_init(struct cmd *self, unused int arg)
data->name = NULL;
data->cmd = NULL;
data->flag_detached = 0;
+ data->flag_kill = 0;
}
int
@@ -75,11 +77,14 @@ cmd_new_window_parse(struct cmd *self, int argc, char **argv, char **cause)
self->entry->init(self, 0);
data = self->data;
- while ((opt = getopt(argc, argv, "dt:n:")) != -1) {
+ while ((opt = getopt(argc, argv, "dkt:n:")) != -1) {
switch (opt) {
case 'd':
data->flag_detached = 1;
break;
+ case 'k':
+ data->flag_kill = 1;
+ break;
case 't':
if (data->target == NULL)
data->target = xstrdup(optarg);
@@ -134,6 +139,27 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}
+ wl = NULL;
+ if (idx != -1)
+ wl = winlink_find_by_index(&s->windows, idx);
+ if (wl != NULL) {
+ if (data->flag_kill) {
+ /*
+ * Can't use session_detach as it will destroy session
+ * if this makes it empty.
+ */
+ session_alert_cancel(s, wl);
+ winlink_stack_remove(&s->lastw, wl);
+ winlink_remove(&s->windows, wl);
+
+ /* Force select/redraw if current. */
+ if (wl == s->curw) {
+ data->flag_detached = 0;
+ s->curw = NULL;
+ }
+ }
+ }
+
cmd = data->cmd;
if (cmd == NULL)
cmd = options_get_string(&s->options, "default-command");