diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2013-03-22 10:37:39 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2013-03-22 10:37:39 +0000 |
commit | f0efa576e002e77dc6363e0a5bc41d0c0649c946 (patch) | |
tree | 19a401bcc41eb34271b9bdf85f608c4172bf8e20 /layout.c | |
parent | ad5df9bc2f00b3de89e1c2bd6714022cf99aacda (diff) | |
download | rtmux-f0efa576e002e77dc6363e0a5bc41d0c0649c946.tar.gz rtmux-f0efa576e002e77dc6363e0a5bc41d0c0649c946.tar.bz2 rtmux-f0efa576e002e77dc6363e0a5bc41d0c0649c946.zip |
Add resize-pane -x and -y for absolute pane size (much requested).
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) |