summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-01-07 20:52:18 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-01-07 20:52:18 +0000
commit6a45fab608a7430757db38c3bf3ab67a042b7abb (patch)
treefe089bdfa8df3cb1768cc5445e229543405c44f5 /layout.c
parent519c6fc7e760dcd608d24dfeb9dc947c6331685b (diff)
New command, join-pane, to split and move an existing pane into the space (like
splitw then movep, or the reverse of breakp).
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/layout.c b/layout.c
index 7835e3f9..2d7fd596 100644
--- a/layout.c
+++ b/layout.c
@@ -485,10 +485,20 @@ layout_resize_pane_shrink(
return (size);
}
-/* Split a pane into two. size is a hint, or -1 for default half/half split. */
-int
-layout_split_pane(struct window_pane *wp,
- enum layout_type type, int size, struct window_pane *new_wp)
+/* Assign window pane to newly split cell. */
+void
+layout_assign_pane(struct layout_cell *lc, struct window_pane *wp)
+{
+ layout_make_leaf(lc, wp);
+ layout_fix_panes(wp->window, wp->window->sx, wp->window->sy);
+}
+
+/*
+ * Split a pane into two. size is a hint, or -1 for default half/half
+ * split. This must be followed by layout_assign_pane before much else happens!
+ **/
+struct layout_cell *
+layout_split_pane(struct window_pane *wp, enum layout_type type, int size)
{
struct layout_cell *lc, *lcparent, *lcnew;
u_int sx, sy, xoff, yoff, size1, size2;
@@ -505,11 +515,11 @@ layout_split_pane(struct window_pane *wp,
switch (type) {
case LAYOUT_LEFTRIGHT:
if (sx < PANE_MINIMUM * 2 + 1)
- return (-1);
+ return (NULL);
break;
case LAYOUT_TOPBOTTOM:
if (sy < PANE_MINIMUM * 2 + 1)
- return (-1);
+ return (NULL);
break;
default:
fatalx("bad layout type");
@@ -583,12 +593,8 @@ layout_split_pane(struct window_pane *wp,
/* Assign the panes. */
layout_make_leaf(lc, wp);
- layout_make_leaf(lcnew, new_wp);
-
- /* Fix pane offsets and sizes. */
- layout_fix_panes(wp->window, wp->window->sx, wp->window->sy);
- return (0);
+ return (lcnew);
}
/* Destroy the layout associated with a pane and redistribute the space. */