summaryrefslogtreecommitdiffstats
path: root/cmd-join-pane.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-join-pane.c')
-rw-r--r--cmd-join-pane.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/cmd-join-pane.c b/cmd-join-pane.c
index cb3fb34..da1ba9a 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -71,10 +71,11 @@ 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, percentage, dst_idx;
+ int size, dst_idx;
int flags;
enum layout_type type;
struct layout_cell *lc;
+ u_int curval = 0;
dst_s = target->s;
dst_wl = target->wl;
@@ -97,24 +98,31 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'h'))
type = LAYOUT_LEFTRIGHT;
- size = -1;
- if (args_has(args, 'l')) {
- if (type == LAYOUT_TOPBOTTOM) {
- size = args_percentage(args, 'l', 0, INT_MAX,
- dst_wp->sy, &cause);
+ /* 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 {
- size = args_percentage(args, 'l', 0, INT_MAX,
- dst_wp->sx, &cause);
- }
- } else if (args_has(args, 'p')) {
- percentage = args_strtonum(args, 'p', 0, 100, &cause);
- if (cause == NULL) {
if (type == LAYOUT_TOPBOTTOM)
- size = (dst_wp->sy * percentage) / 100;
+ curval = dst_wp->sy;
else
- size = (dst_wp->sx * percentage) / 100;
+ 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, 'l', 0, 100, item,
+ &cause);
+ if (cause == NULL)
+ size = curval * size / 100;
+ }
if (cause != NULL) {
cmdq_error(item, "size %s", cause);
free(cause);
@@ -147,6 +155,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
else
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
layout_assign_pane(lc, src_wp, 0);
+ colour_palette_from_option(&src_wp->palette, src_wp->options);
recalculate_sizes();