summaryrefslogtreecommitdiffstats
path: root/cmd-new-window.c
diff options
context:
space:
mode:
authornicm <nicm>2020-06-13 09:05:53 +0000
committernicm <nicm>2020-06-13 09:05:53 +0000
commit1c78155e70a9f72ed6c191807c2b381cf114b91f (patch)
treed1cf209a0268843216fe440b83a68467045ee244 /cmd-new-window.c
parentd52ac7d027e40b34e7089addc4f905d03d9c1b16 (diff)
Add -b flags to insert a window before (like the existing -a for after)
to break-pane, move-window, new-window. GitHub issue 2261.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r--cmd-new-window.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 722f89b9..0b24474b 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_new_window_entry = {
.name = "new-window",
.alias = "neww",
- .args = { "ac:de:F:kn:Pt:", 0, -1 },
- .usage = "[-adkP] [-c start-directory] [-e environment] [-F format] "
+ .args = { "abc:de:F:kn:Pt:", 0, -1 },
+ .usage = "[-abdkP] [-c start-directory] [-e environment] [-F format] "
"[-n window-name] " CMD_TARGET_WINDOW_USAGE " [command]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
@@ -58,16 +58,20 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s;
struct winlink *wl = target->wl;
- int idx = target->idx;
+ int idx = target->idx, before;
struct winlink *new_wl;
char *cause = NULL, *cp;
const char *template, *add;
struct cmd_find_state fs;
struct args_value *value;
- if (args_has(args, 'a') && (idx = winlink_shuffle_up(s, wl)) == -1) {
- cmdq_error(item, "couldn't get a window index");
- return (CMD_RETURN_ERROR);
+ before = args_has(args, 'b');
+ if (args_has(args, 'a') || before) {
+ idx = winlink_shuffle_up(s, wl, before);
+ if (idx == -1) {
+ cmdq_error(item, "couldn't get a window index");
+ return (CMD_RETURN_ERROR);
+ }
}
memset(&sc, 0, sizeof sc);