summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/layout.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-03-22 10:37:39 +0000
committernicm <nicm@openbsd.org>2013-03-22 10:37:39 +0000
commit3cfcdd3623f61b7a1113a4502de4bf664bcc0586 (patch)
tree3b8de751327970e3cd48355c235b9f5261b61bf1 /usr.bin/tmux/layout.c
parentImplement DECAWM (SM/RM 7) using existing MODE_WRAP flag. (diff)
downloadwireguard-openbsd-3cfcdd3623f61b7a1113a4502de4bf664bcc0586.tar.xz
wireguard-openbsd-3cfcdd3623f61b7a1113a4502de4bf664bcc0586.zip
Add resize-pane -x and -y for absolute pane size (much requested).
Diffstat (limited to 'usr.bin/tmux/layout.c')
-rw-r--r--usr.bin/tmux/layout.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c
index 68b1a7df836..fe494fa7f9d 100644
--- a/usr.bin/tmux/layout.c
+++ b/usr.bin/tmux/layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout.c,v 1.16 2013/01/17 00:11:22 nicm Exp $ */
+/* $OpenBSD: layout.c,v 1.17 2013/03/22 10:37:39 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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)