From 462a11301aaf06dab52b06a9c52ed12d99537c5f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 7 Jan 2010 19:47:10 +0000 Subject: [PATCH] Change split-window to accept a pane target (it should be split-pane but renaming the command would be annoying). --- cmd-split-window.c | 18 +++++++++--------- tmux.1 | 9 +++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cmd-split-window.c b/cmd-split-window.c index 6a9c4c9f..2941e2bf 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -45,7 +45,7 @@ struct cmd_split_window_data { const struct cmd_entry cmd_split_window_entry = { "split-window", "splitw", - "[-dhv] [-p percentage|-l size] [-t target-window] [command]", + "[-dhv] [-p percentage|-l size] [-t target-pane] [command]", 0, "", cmd_split_window_init, cmd_split_window_parse, @@ -149,7 +149,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) struct session *s; struct winlink *wl; struct window *w; - struct window_pane *wp; + struct window_pane *wp, *new_wp; struct environ env; char *cmd, *cwd, *cause; const char *shell; @@ -157,7 +157,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) int size; enum layout_type type; - if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL) + if ((wl = cmd_find_pane(ctx, data->target, &s, &wp)) == NULL) return (-1); w = wl->window; @@ -193,10 +193,10 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (*shell == '\0' || areshell(shell)) shell = _PATH_BSHELL; - wp = window_add_pane(w, hlimit); - if (window_pane_spawn(wp, cmd, shell, cwd, &env, s->tio, &cause) != 0) + new_wp = window_add_pane(w, hlimit); + if (window_pane_spawn(new_wp, cmd, shell, cwd, &env, s->tio, &cause) != 0) goto error; - if (layout_split_pane(w->active, type, size, wp) != 0) { + if (layout_split_pane(wp, type, size, new_wp) != 0) { cause = xstrdup("pane too small"); goto error; } @@ -204,7 +204,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) server_redraw_window(w); if (!data->flag_detached) { - window_set_active_pane(w, wp); + window_set_active_pane(w, new_wp); session_select(s, wl->idx); server_redraw_session(s); } else @@ -215,8 +215,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) error: environ_free(&env); - if (wp != NULL) - window_remove_pane(w, wp); + if (new_wp != NULL) + window_remove_pane(w, new_wp); ctx->error(ctx, "create pane failed: %s", cause); xfree(cause); return (-1); diff --git a/tmux.1 b/tmux.1 index 41b28d46..7f091c60 100644 --- a/tmux.1 +++ b/tmux.1 @@ -984,11 +984,12 @@ Select the window at .Oo Fl l .Ar size | .Fl p Ar percentage Oc -.Op Fl t Ar target-window +.Op Fl t Ar target-pane .Op Ar command .Xc .D1 (alias: splitw ) -Creates a new pane by splitting the active pane: +Create a new pane by splitting +.Ar target-pane : .Fl h does a horizontal split and .Fl v @@ -999,9 +1000,9 @@ The .Fl l and .Fl p -options specify the size of the new window in lines (for vertical split) or in +options specify the size of the new pane in lines (for vertical split) or in cells (for horizontal split), or as a percentage, respectively. -All other options have the same meaning as in the +All other options have the same meaning as for the .Ic new-window command. .It Xo Ic swap-pane