summaryrefslogtreecommitdiffstats
path: root/cmd-split-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-03-04 20:50:53 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-03-04 20:50:53 +0000
commit03dca66ae207e5b2d98a9cd337d472ea26bb95c6 (patch)
tree0d87f73acc1acad782211849fd4c97a061315ea2 /cmd-split-window.c
parent178a20718c007a254611d4f02c4c6f3ca7184d8d (diff)
Add -F format to new-window and split-window to use with the -P flag,
from George Nachman.
Diffstat (limited to 'cmd-split-window.c')
-rw-r--r--cmd-split-window.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 3c7878f0..5addd107 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -33,9 +33,9 @@ int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_split_window_entry = {
"split-window", "splitw",
- "c:dl:hp:Pt:v", 0, 1,
- "[-dhvP] [-c start-directory] [-p percentage|-l size] [-t target-pane] "
- "[command]",
+ "c:dF:l:hp:Pt:v", 0, 1,
+ "[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
+ "[-t target-pane] [command]",
0,
cmd_split_window_key_binding,
NULL,
@@ -59,12 +59,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct window *w;
struct window_pane *wp, *new_wp = NULL;
struct environ env;
- const char *cmd, *cwd, *shell;
+ const char *cmd, *cwd, *shell;
char *cause, *new_cause;
- u_int hlimit, paneidx;
+ u_int hlimit;
int size, percentage;
enum layout_type type;
struct layout_cell *lc;
+ const char *template;
+ struct client *c;
+ struct format_tree *ft;
+ char *cp;
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
return (-1);
@@ -135,9 +139,22 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
environ_free(&env);
if (args_has(args, 'P')) {
- if (window_pane_index(new_wp, &paneidx) != 0)
- fatalx("index not found");
- ctx->print(ctx, "%s:%u.%u", s->name, wl->idx, paneidx);
+ template = "#{session_name}:#{window_index}.#{pane_index}";
+ if (args_has(args, 'F'))
+ template = args_get(args, 'F');
+
+ ft = format_create();
+ if ((c = cmd_find_client(ctx, NULL)) != NULL)
+ format_client(ft, c);
+ format_session(ft, s);
+ format_winlink(ft, s, wl);
+ format_window_pane(ft, new_wp);
+
+ cp = format_expand(ft, template);
+ ctx->print(ctx, "%s", cp);
+ free(cp);
+
+ format_free(ft);
}
return (0);