summaryrefslogtreecommitdiffstats
authornicm <nicm>2009-07-18 11:07:14 (GMT)
committer nicm <nicm>2009-07-18 11:07:14 (GMT)
commit9c98af1bb2c882287e9d64ad583d08f2de0c4686 (patch) (side-by-side diff)
tree159807a0c9dd6abc79393976c1b49d38ffe81431
parent6d232f8301e9f31f6670919c5fdd62937d611fb2 (diff)
downloadtmux-old-9c98af1bb2c882287e9d64ad583d08f2de0c4686.zip
tmux-old-9c98af1bb2c882287e9d64ad583d08f2de0c4686.tar.gz
tmux-old-9c98af1bb2c882287e9d64ad583d08f2de0c4686.tar.bz2
Make it so using kill-pane to destroy the last pane in a window destroys the
window instead of being an error.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cmd-kill-pane.c5
-rw-r--r--cmd-kill-window.c28
-rw-r--r--server-fn.c33
-rw-r--r--tmux.11
-rw-r--r--tmux.h1
5 files changed, 39 insertions, 29 deletions
diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c
index c2beca1..bca9c21 100644
--- a/cmd-kill-pane.c
+++ b/cmd-kill-pane.c
@@ -61,8 +61,9 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
}
if (window_count_panes(wl->window) == 1) {
- ctx->error(ctx, "can't kill pane: %d", data->pane);
- return (-1);
+ /* Only one pane, kill the window. */
+ server_kill_window(wl->window);
+ return (0);
}
window_remove_pane(wl->window, wp);
diff --git a/cmd-kill-window.c b/cmd-kill-window.c
index 1497037..a7ffba1 100644
--- a/cmd-kill-window.c
+++ b/cmd-kill-window.c
@@ -44,37 +44,11 @@ cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_target_data *data = self->data;
struct winlink *wl;
- struct window *w;
- struct session *s;
- struct client *c;
- u_int i, j;
- int destroyed;
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
return (-1);
- w = wl->window;
- for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
- s = ARRAY_ITEM(&sessions, i);
- if (s == NULL || !session_has(s, w))
- continue;
- if ((wl = winlink_find_by_window(&s->windows, w)) == NULL)
- continue;
-
- destroyed = session_detach(s, wl);
- for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
- c = ARRAY_ITEM(&clients, j);
- if (c == NULL || c->session != s)
- continue;
-
- if (destroyed) {
- c->session = NULL;
- server_write_client(c, MSG_EXIT, NULL, 0);
- } else
- server_redraw_client(c);
- }
- }
- recalculate_sizes();
+ server_kill_window(wl->window);
return (0);
}
diff --git a/server-fn.c b/server-fn.c
index 1dbc931..db80445 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -228,3 +228,36 @@ wrong:
return (-1);
}
+
+void
+server_kill_window(struct window *w)
+{
+ struct session *s;
+ struct winlink *wl;
+ struct client *c;
+ u_int i, j;
+ int destroyed;
+
+
+ for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
+ s = ARRAY_ITEM(&sessions, i);
+ if (s == NULL || !session_has(s, w))
+ continue;
+ if ((wl = winlink_find_by_window(&s->windows, w)) == NULL)
+ continue;
+
+ destroyed = session_detach(s, wl);
+ for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
+ c = ARRAY_ITEM(&clients, j);
+ if (c == NULL || c->session != s)
+ continue;
+
+ if (destroyed) {
+ c->session = NULL;
+ server_write_client(c, MSG_EXIT, NULL, 0);
+ } else
+ server_redraw_client(c);
+ }
+ }
+ recalculate_sizes();
+}
diff --git a/tmux.1 b/tmux.1
index 0013985..df9d910 100644
--- a/tmux.1
+++ b/tmux.1
@@ -768,6 +768,7 @@ returns success.
.Xc
.D1 (alias: Ic killp )
Destroy the given pane.
+If no panes remain in the containing window, it is also destroyed.
.It Xo Ic kill-server
.Xc
Kill the
diff --git a/tmux.h b/tmux.h
index 09f0aee..91fed2e 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1283,6 +1283,7 @@ void server_redraw_window(struct window *);
void server_status_window(struct window *);
void server_lock(void);
int server_unlock(const char *);
+void server_kill_window(struct window *);
/* status.c */
int status_redraw(struct client *);