summaryrefslogtreecommitdiffstats
path: root/cmd-join-pane.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2012-03-03 09:19:40 +0000
committerTiago Cunha <tcunha@gmx.com>2012-03-03 09:19:40 +0000
commite4f1fbd0085f30be0945ff3c8220184b0b473906 (patch)
tree204603b6b0c3ac845fe456260c1fa64d973eeae4 /cmd-join-pane.c
parent89ab14709346ebcb49d43172ff55b15a6512e08f (diff)
Sync OpenBSD patchset 1035:
Add move-pane command (like join-pane but allows the same window). Also -b flag to join-pane and move-pane to place the pane to the left or above. From George Nachman.
Diffstat (limited to 'cmd-join-pane.c')
-rw-r--r--cmd-join-pane.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/cmd-join-pane.c b/cmd-join-pane.c
index cb30687b..c87c5331 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
+ * Copyright (c) 2011 George Nachman <tmux@georgester.com>
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -24,22 +25,34 @@
#include "tmux.h"
/*
- * Join a pane into another (like split/swap/kill).
+ * Join or move a pane into another (like split/swap/kill).
*/
void cmd_join_pane_key_binding(struct cmd *, int);
int cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
+int join_pane(struct cmd *, struct cmd_ctx *, int);
+
const struct cmd_entry cmd_join_pane_entry = {
"join-pane", "joinp",
- "dhvp:l:s:t:", 0, 0,
- "[-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
+ "bdhvp:l:s:t:", 0, 0,
+ "[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
0,
cmd_join_pane_key_binding,
NULL,
cmd_join_pane_exec
};
+const struct cmd_entry cmd_move_pane_entry = {
+ "move-pane", "movep",
+ "bdhvp:l:s:t:", 0, 0,
+ "[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
+ 0,
+ NULL,
+ NULL,
+ cmd_join_pane_exec
+};
+
void
cmd_join_pane_key_binding(struct cmd *self, int key)
{
@@ -57,6 +70,12 @@ cmd_join_pane_key_binding(struct cmd *self, int key)
int
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{
+ return join_pane(self, ctx, self->entry == &cmd_join_pane_entry);
+}
+
+int
+join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
+{
struct args *args = self->args;
struct session *dst_s;
struct winlink *src_wl, *dst_wl;
@@ -78,10 +97,14 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
src_w = src_wl->window;
- if (src_w == dst_w) {
+ if (not_same_window && src_w == dst_w) {
ctx->error(ctx, "can't join a pane to its own window");
return (-1);
}
+ if (!not_same_window && src_wp == dst_wp) {
+ ctx->error(ctx, "source and target panes must be different");
+ return (-1);
+ }
type = LAYOUT_TOPBOTTOM;
if (args_has(args, 'h'))
@@ -107,8 +130,8 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
else
size = (dst_wp->sx * percentage) / 100;
}
-
- if ((lc = layout_split_pane(dst_wp, type, size)) == NULL) {
+ lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
+ if (lc == NULL) {
ctx->error(ctx, "create pane failed: pane too small");
return (-1);
}