summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-03-03 08:31:18 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-03-03 08:31:18 +0000
commit07ac16807f85d7bd5e7c7570f2b11250c65b6228 (patch)
tree8409a155ccc48f26d4ebf7c5fe5ba45fdf4e44fa /layout.c
parent4d9ccd322909334b896d6a0420ea747898799385 (diff)
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 'layout.c')
-rw-r--r--layout.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/layout.c b/layout.c
index 429e103e..1050efc4 100644
--- a/layout.c
+++ b/layout.c
@@ -616,9 +616,10 @@ layout_assign_pane(struct layout_cell *lc, struct window_pane *wp)
* 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)
+layout_split_pane(
+ struct window_pane *wp, enum layout_type type, int size, int insert_before)
{
- struct layout_cell *lc, *lcparent, *lcnew;
+ struct layout_cell *lc, *lcparent, *lcnew, *lc1, *lc2;
u_int sx, sy, xoff, yoff, size1, size2;
lc = wp->layout_cell;
@@ -650,8 +651,12 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size)
*/
/* Create the new child cell. */
- lcnew = layout_create_cell(lc->parent);
- TAILQ_INSERT_AFTER(&lc->parent->cells, lc, lcnew, entry);
+ lcparent = lc->parent;
+ lcnew = layout_create_cell(lcparent);
+ if (insert_before)
+ TAILQ_INSERT_BEFORE(lc, lcnew, entry);
+ else
+ TAILQ_INSERT_AFTER(&lcparent->cells, lc, lcnew, entry);
} else {
/*
* Otherwise create a new parent and insert it.
@@ -672,7 +677,17 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size)
/* Create the new child cell. */
lcnew = layout_create_cell(lcparent);
- TAILQ_INSERT_TAIL(&lcparent->cells, lcnew, entry);
+ if (insert_before)
+ TAILQ_INSERT_HEAD(&lcparent->cells, lcnew, entry);
+ else
+ TAILQ_INSERT_TAIL(&lcparent->cells, lcnew, entry);
+ }
+ if (insert_before) {
+ lc1 = lcnew;
+ lc2 = lc;
+ } else {
+ lc1 = lc;
+ lc2 = lcnew;
}
/* Set new cell sizes. size is the target size or -1 for middle split,
@@ -689,8 +704,8 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size)
else if (size2 > sx - 2)
size2 = sx - 2;
size1 = sx - 1 - size2;
- layout_set_size(lc, size1, sy, xoff, yoff);
- layout_set_size(lcnew, size2, sy, xoff + lc->sx + 1, yoff);
+ layout_set_size(lc1, size1, sy, xoff, yoff);
+ layout_set_size(lc2, size2, sy, xoff + lc1->sx + 1, yoff);
break;
case LAYOUT_TOPBOTTOM:
if (size < 0)
@@ -702,8 +717,8 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size)
else if (size2 > sy - 2)
size2 = sy - 2;
size1 = sy - 1 - size2;
- layout_set_size(lc, sx, size1, xoff, yoff);
- layout_set_size(lcnew, sx, size2, xoff, yoff + lc->sy + 1);
+ layout_set_size(lc1, sx, size1, xoff, yoff);
+ layout_set_size(lc2, sx, size2, xoff, yoff + lc1->sy + 1);
break;
default:
fatalx("bad layout type");