diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-07-20 15:42:05 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-07-20 15:42:05 +0000 |
commit | 545893df73034b2729c2f501252f50fcb8eb9f47 (patch) | |
tree | 48f8f96b61397f232666634f6657df7974d0a9cf /layout-manual.c | |
parent | 680f2098f186224aefb78df78c3cdefbf232d315 (diff) | |
download | rtmux-545893df73034b2729c2f501252f50fcb8eb9f47.tar.gz rtmux-545893df73034b2729c2f501252f50fcb8eb9f47.tar.bz2 rtmux-545893df73034b2729c2f501252f50fcb8eb9f47.zip |
Sync OpenBSD patchset 142:
Each window now has a tree of layout cells associated with it. In this tree,
each node is either a horizontal or vertical cell containing a list of other
cells running from left-to-right or top-to-bottom, or a leaf cell which is
associated with a pane.
The major functional changes are:
- panes may now be split arbitrarily both horizontally (splitw -h, C-b %) and
vertically (splitw -v, C-b ");
- panes may be resized both horizontally and vertically (resizep -L/-R/-U/-D,
bound to C-b left/right/up/down and C-b M-left/right/up/down);
- layouts are now applied and then may be modified by resizing or splitting
panes, rather than being fixed and reapplied when the window is resized or
panes are added;
- manual-vertical layout is no longer necessary, and active-only layout is gone
(but may return in future);
- the main-pane layouts now reduce the size of the main pane to fit all panes
if possible.
Thanks to all who tested.
Diffstat (limited to 'layout-manual.c')
-rw-r--r-- | layout-manual.c | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/layout-manual.c b/layout-manual.c deleted file mode 100644 index 9798b8ca..00000000 --- a/layout-manual.c +++ /dev/null @@ -1,172 +0,0 @@ -/* $Id: layout-manual.c,v 1.4 2009-07-15 17:42:44 nicm Exp $ */ - -/* - * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -void layout_manual_v_update_offsets(struct window *); - -void -layout_manual_v_refresh(struct window *w, unused int active_only) -{ - struct window_pane *wp; - u_int npanes, total, height; - int left; - - if (active_only) - return; - - if (TAILQ_EMPTY(&w->panes)) - return; - - /* Check the new size. */ - npanes = window_count_panes(w); - if (w->sy <= PANE_MINIMUM * npanes) { - /* - * Make the first pane the smaller of the minimum and total (it - * must fit to be visible) and the rest the minimum size. - */ - height = PANE_MINIMUM; - if (height > w->sy) - height = w->sy + 1; - TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp == TAILQ_FIRST(&w->panes)) - wp->sy = height - 1; - else - wp->sy = PANE_MINIMUM - 1; - } - /* And increase the first by the rest if possible. */ - if (w->sy >= PANE_MINIMUM) - TAILQ_FIRST(&w->panes)->sy += 1 + w->sy % PANE_MINIMUM; - } else { - /* In theory they will all fit. Find the current total. */ - total = 0; - TAILQ_FOREACH(wp, &w->panes, entry) - total += wp->sy; - total += npanes - 1; - - /* Growing or shrinking? */ - left = w->sy - total; - if (left > 0) { - /* Growing. Expand evenly. */ - while (left > 0) { - TAILQ_FOREACH(wp, &w->panes, entry) { - wp->sy++; - if (--left == 0) - break; - } - } - } else { - /* Shrinking. Reduce evenly down to minimum. */ - while (left < 0) { - TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp->sy <= PANE_MINIMUM - 1) - continue; - wp->sy--; - if (++left == 0) - break; - } - } - } - } - - /* Now do the resize. */ - TAILQ_FOREACH(wp, &w->panes, entry) { - wp->sy--; - window_pane_resize(wp, w->sx, wp->sy + 1); - } - - /* Fill in the offsets. */ - layout_manual_v_update_offsets(w); - - /* Switch the active window if necessary. */ - window_set_active_pane(w, w->active); -} - -void -layout_manual_v_resize(struct window_pane *wp, int adjust) -{ - struct window *w = wp->window; - struct window_pane *wq; - - if (adjust > 0) { - /* - * If this is not the last pane, keep trying to increase size - * and remove it from the next panes. If it is the last, do - * so on the previous pane. - */ - if (TAILQ_NEXT(wp, entry) == NULL) { - if (wp == TAILQ_FIRST(&w->panes)) { - /* Only one pane. */ - return; - } - wp = TAILQ_PREV(wp, window_panes, entry); - } - while (adjust-- > 0) { - wq = wp; - while ((wq = TAILQ_NEXT(wq, entry)) != NULL) { - if (wq->sy <= PANE_MINIMUM) - continue; - window_pane_resize(wq, wq->sx, wq->sy - 1); - break; - } - if (wq == NULL) - break; - window_pane_resize(wp, wp->sx, wp->sy + 1); - } - } else { - adjust = -adjust; - /* - * If this is not the last pane, keep trying to reduce size - * and add to the following pane. If it is the last, do so on - * the previous pane. - */ - wq = TAILQ_NEXT(wp, entry); - if (wq == NULL) { - if (wp == TAILQ_FIRST(&w->panes)) { - /* Only one pane. */ - return; - } - wq = wp; - wp = TAILQ_PREV(wq, window_panes, entry); - } - while (adjust-- > 0) { - if (wp->sy <= PANE_MINIMUM) - break; - window_pane_resize(wq, wq->sx, wq->sy + 1); - window_pane_resize(wp, wp->sx, wp->sy - 1); - } - } - - layout_manual_v_update_offsets(w); -} - -void -layout_manual_v_update_offsets(struct window *w) -{ - struct window_pane *wp; - u_int yoff; - - yoff = 0; - TAILQ_FOREACH(wp, &w->panes, entry) { - wp->xoff = 0; - wp->yoff = yoff; - yoff += wp->sy + 1; - } -} |