mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-14 15:58:27 +02:00
Sync OpenBSD patchset 1035:
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.
This commit is contained in:
33
layout.c
33
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");
|
||||
|
Reference in New Issue
Block a user