diff options
author | Tiago Cunha <tcunha@gmx.com> | 2012-03-07 13:39:29 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2012-03-07 13:39:29 +0000 |
commit | 3d98adaf917f0ae8d03db8ab822833068407f8ea (patch) | |
tree | 85a99b15c11547fd4657a53d86a2c29e3dd07a1c /cmd-new-window.c | |
parent | cf11809cd45ecd2d1998d2404ff91ab747b89307 (diff) |
Sync OpenBSD patchset 1041:
Add -F format to new-window and split-window to use with the -P flag,
from George Nachman.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r-- | cmd-new-window.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c index 4dbe114d..96e3c7db 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -30,9 +30,9 @@ int cmd_new_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_new_window_entry = { "new-window", "neww", - "ac:dkn:Pt:", 0, 1, - "[-adk] [-c start-directory] [-n window-name] [-t target-window] " - "[command]", + "ac:dF:kn:Pt:", 0, 1, + "[-adkP] [-c start-directory] [-F format] [-n window-name] " + "[-t target-window] [command]", 0, NULL, NULL, @@ -42,12 +42,16 @@ const struct cmd_entry cmd_new_window_entry = { int cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct args *args = self->args; - struct session *s; - struct winlink *wl; - const char *cmd, *cwd; - char *cause; - int idx, last, detached; + struct args *args = self->args; + struct session *s; + struct winlink *wl; + struct client *c; + const char *cmd, *cwd; + const char *template; + char *cause; + int idx, last, detached; + struct format_tree *ft; + char *cp; if (args_has(args, 'a')) { wl = cmd_find_window(ctx, args_get(args, 't'), &s); @@ -116,7 +120,23 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) } else server_status_session_group(s); - if (args_has(args, 'P')) - ctx->print(ctx, "%s:%u", s->name, wl->idx); + if (args_has(args, 'P')) { + template = "#{session_name}:#{window_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); + + cp = format_expand(ft, template); + ctx->print(ctx, "%s", cp); + free(cp); + + format_free(ft); + } + return (0); } |