=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-join-pane.c,v retrieving revision 1.7 retrieving revision 1.8 diff -c -r1.7 -r1.8 *** src/usr.bin/tmux/cmd-join-pane.c 2011/01/23 15:49:10 1.7 --- src/usr.bin/tmux/cmd-join-pane.c 2012/03/03 08:31:18 1.8 *************** *** 1,6 **** ! /* $OpenBSD: cmd-join-pane.c,v 1.7 2011/01/23 15:49:10 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott * * Permission to use, copy, modify, and distribute this software for any --- 1,7 ---- ! /* $OpenBSD: cmd-join-pane.c,v 1.8 2012/03/03 08:31:18 nicm Exp $ */ /* + * Copyright (c) 2011 George Nachman * Copyright (c) 2009 Nicholas Marriott * * Permission to use, copy, modify, and distribute this software for any *************** *** 25,46 **** #include "tmux.h" /* ! * Join 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 *); 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]", 0, cmd_join_pane_key_binding, NULL, cmd_join_pane_exec }; void cmd_join_pane_key_binding(struct cmd *self, int key) { --- 26,59 ---- #include "tmux.h" /* ! * 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", ! "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) { *************** *** 58,63 **** --- 71,82 ---- 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; *************** *** 79,88 **** return (-1); src_w = src_wl->window; ! if (src_w == dst_w) { ctx->error(ctx, "can't join a pane to its own window"); return (-1); } type = LAYOUT_TOPBOTTOM; if (args_has(args, 'h')) --- 98,111 ---- return (-1); src_w = src_wl->window; ! 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')) *************** *** 108,115 **** else size = (dst_wp->sx * percentage) / 100; } ! ! if ((lc = layout_split_pane(dst_wp, type, size)) == NULL) { ctx->error(ctx, "create pane failed: pane too small"); return (-1); } --- 131,138 ---- else size = (dst_wp->sx * percentage) / 100; } ! 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); }