diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-18 17:00:35 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-18 17:00:35 +0000 |
commit | e4bb87032eb851338aa77bceb3e4581da3281a1d (patch) | |
tree | 2f3d1e4231f7e644615113753f1aec7f286d992b /layout.c | |
parent | a6c4c2cca0d44e0cec9d4a0cc041290a263826fb (diff) | |
download | rtmux-e4bb87032eb851338aa77bceb3e4581da3281a1d.tar.gz rtmux-e4bb87032eb851338aa77bceb3e4581da3281a1d.tar.bz2 rtmux-e4bb87032eb851338aa77bceb3e4581da3281a1d.zip |
Add resize-pane -x and -y for absolute pane size.
Diffstat (limited to 'layout.c')
-rw-r--r-- | layout.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -443,6 +443,39 @@ layout_resize(struct window *w, u_int sx, u_int sy) layout_fix_panes(w, sx, sy); } +/* Resize a pane to an absolute size. */ +void +layout_resize_pane_to(struct window_pane *wp, enum layout_type type, + u_int new_size) +{ + struct layout_cell *lc, *lcparent; + int change, size; + + lc = wp->layout_cell; + + /* Find next parent of the same type. */ + lcparent = lc->parent; + while (lcparent != NULL && lcparent->type != type) { + lc = lcparent; + lcparent = lc->parent; + } + if (lcparent == NULL) + return; + + /* Work out the size adjustment. */ + if (type == LAYOUT_LEFTRIGHT) + size = lc->sx; + else + size = lc->sy; + if (lc == TAILQ_LAST(&lcparent->cells, layout_cells)) + change = size - new_size; + else + change = new_size - size; + + /* Resize the pane. */ + layout_resize_pane(wp, type, change); +} + /* Resize a single pane within the layout. */ void layout_resize_pane(struct window_pane *wp, enum layout_type type, int change) @@ -486,6 +519,7 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change) notify_window_layout_changed(wp->window); } +/* Resize pane based on mouse events. */ void layout_resize_pane_mouse(struct client *c) { @@ -534,6 +568,7 @@ layout_resize_pane_mouse(struct client *c) m->flags &= ~MOUSE_RESIZE_PANE; } +/* Helper function to grow pane. */ int layout_resize_pane_grow( struct layout_cell *lc, enum layout_type type, int needed) @@ -574,6 +609,7 @@ layout_resize_pane_grow( return (size); } +/* Helper function to shrink pane. */ int layout_resize_pane_shrink( struct layout_cell *lc, enum layout_type type, int needed) |