-a option to kill all except current pane. From Tiago Cunha, thanks!

This commit is contained in:
Nicholas Marriott
2009-10-24 10:12:39 +00:00
parent c2b8f3b55a
commit df818c1b69
2 changed files with 26 additions and 6 deletions

View File

@ -30,8 +30,8 @@ int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_kill_pane_entry = {
"kill-pane", "killp",
CMD_TARGET_PANE_USAGE,
0, 0,
"[-a] " CMD_TARGET_PANE_USAGE,
0, CMD_CHFLAG('a'),
cmd_target_init,
cmd_target_parse,
cmd_kill_pane_exec,
@ -44,7 +44,7 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_target_data *data = self->data;
struct winlink *wl;
struct window_pane *wp;
struct window_pane *loopwp, *nextwp, *wp;
if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL)
return (-1);
@ -56,8 +56,21 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
return (0);
}
layout_close_pane(wp);
window_remove_pane(wl->window, wp);
if (data->chflags & CMD_CHFLAG('a')) {
loopwp = TAILQ_FIRST(&wl->window->panes);
while (loopwp != NULL) {
nextwp = TAILQ_NEXT(loopwp, entry);
if (loopwp != wp) {
layout_close_pane(loopwp);
window_remove_pane(wl->window, loopwp);
}
loopwp = nextwp;
}
} else {
layout_close_pane(wp);
window_remove_pane(wl->window, wp);
}
server_redraw_window(wl->window);
return (0);
}