summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-06-17 19:56:09 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-06-17 19:56:09 +0000
commitd1ffb859264992edbd10d918575f2740e8b5696a (patch)
treece3aace50c330b4114d248e6336adf36a6120d82 /usr.bin
parentbc3669b12019c9b8147189abbae5629db39350e2 (diff)
Change break-pane to take target and source panes (-t and -s) in line
with other commands, from Thomas Adam.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-break-pane.c21
-rw-r--r--usr.bin/tmux/tmux.110
2 files changed, 20 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c
index 194fc0ce83c..51f4415003b 100644
--- a/usr.bin/tmux/cmd-break-pane.c
+++ b/usr.bin/tmux/cmd-break-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-break-pane.c,v 1.26 2015/02/05 10:29:43 nicm Exp $ */
+/* $OpenBSD: cmd-break-pane.c,v 1.27 2015/06/17 19:56:08 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,8 +32,8 @@ enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_break_pane_entry = {
"break-pane", "breakp",
- "dPF:t:", 0, 0,
- "[-dP] [-F format] " CMD_TARGET_PANE_USAGE,
+ "dPF:s:t:", 0, 0,
+ "[-dP] [-F format] " CMD_SRCDST_PANE_USAGE,
0,
cmd_break_pane_exec
};
@@ -48,13 +48,19 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
struct window *w;
char *name;
char *cause;
- int base_idx;
+ int idx;
struct format_tree *ft;
const char *template;
char *cp;
- if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
+ if ((wl = cmd_find_pane(cmdq, args_get(args, 's'), &s, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &s)) == -2)
+ return (CMD_RETURN_ERROR);
+ if (idx != -1 && winlink_find_by_index(&s->windows, idx) != NULL) {
+ cmdq_error(cmdq, "index %d already in use", idx);
+ return (CMD_RETURN_ERROR);
+ }
if (window_count_panes(wl->window) == 1) {
cmdq_error(cmdq, "can't break with only one pane");
@@ -76,8 +82,9 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
free(name);
layout_init(w, wp);
- base_idx = options_get_number(&s->options, "base-index");
- wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
+ if (idx == -1)
+ idx = -1 - options_get_number(&s->options, "base-index");
+ wl = session_attach(s, w, idx, &cause); /* can't fail */
if (!args_has(self->args, 'd'))
session_select(s, wl->idx);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 9e5e0b484b8..fd934480e9a 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.439 2015/06/17 16:50:28 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.440 2015/06/17 19:56:08 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -1233,12 +1233,14 @@ Commands related to windows and panes are as follows:
.It Xo Ic break-pane
.Op Fl dP
.Op Fl F Ar format
-.Op Fl t Ar target-pane
+.Op Fl s Ar src-pane
+.Op Fl t Ar dst-pane
.Xc
.D1 (alias: Ic breakp )
Break
-.Ar target-pane
-off from its containing window to make it the only pane in a new window.
+.Ar src-pane
+off from its containing window to make it the only pane in
+.Ar dst-window .
If
.Fl d
is given, the new window does not become the current window.