diff --git a/cmd-join-pane.c b/cmd-join-pane.c index 8444a230..c1e879b6 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -71,11 +71,8 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) struct window *src_w, *dst_w; struct window_pane *src_wp, *dst_wp; char *cause = NULL; - int size, dst_idx; - int flags; - enum layout_type type; + int flags = 0, dst_idx; struct layout_cell *lc; - u_int curval = 0; dst_s = target->s; dst_wl = target->wl; @@ -94,53 +91,13 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_ERROR); } - type = LAYOUT_TOPBOTTOM; - if (args_has(args, 'h')) - type = LAYOUT_LEFTRIGHT; - - /* If the 'p' flag is dropped then this bit can be moved into 'l'. */ - if (args_has(args, 'l') || args_has(args, 'p')) { - if (args_has(args, 'f')) { - if (type == LAYOUT_TOPBOTTOM) - curval = dst_w->sy; - else - curval = dst_w->sx; - } else { - if (type == LAYOUT_TOPBOTTOM) - curval = dst_wp->sy; - else - curval = dst_wp->sx; - } - } - - size = -1; - if (args_has(args, 'l')) { - size = args_percentage_and_expand(args, 'l', 0, INT_MAX, curval, - item, &cause); - } else if (args_has(args, 'p')) { - size = args_strtonum_and_expand(args, 'p', 0, 100, item, - &cause); - if (cause == NULL) - size = curval * size / 100; - } + lc = layout_get_tiled_cell(item, args, dst_w, dst_wp, flags, &cause); if (cause != NULL) { - cmdq_error(item, "size %s", cause); + cmdq_error(item, "%s", cause); free(cause); return (CMD_RETURN_ERROR); } - flags = 0; - if (args_has(args, 'b')) - flags |= SPAWN_BEFORE; - if (args_has(args, 'f')) - flags |= SPAWN_FULLSIZE; - - lc = layout_split_pane(dst_wp, type, size, flags); - if (lc == NULL) { - cmdq_error(item, "create pane failed: pane too small"); - return (CMD_RETURN_ERROR); - } - layout_close_pane(src_wp); server_client_remove_pane(src_wp); diff --git a/cmd-split-window.c b/cmd-split-window.c index 7dd42abb..bee29dc7 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -108,7 +108,8 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) else lc = layout_get_tiled_cell(item, args, w, wp, flags, &cause); if (cause != NULL) { - cmdq_error(item, "could not create cell: %s", cause); + cmdq_error(item, "%s", cause); + free(cause); return (CMD_RETURN_ERROR); }