diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-14 07:23:37 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-14 07:23:37 +0000 |
commit | 08e5c1c4518f4d635bb5c58074562c57d973cbfd (patch) | |
tree | 8cb406938ac37561c42b7f0e157af1d87e35a37d /usr.bin/tmux/layout-manual.c | |
parent | 850a2a1d17bed108de44a31023b1af6161303f25 (diff) |
Get rid of the PANE_HIDDEN flag in favour of a function, and moving the
decision for whether or not a pane should be drawn out of the layout code and
into the redraw code.
This is needed for the new layout design, getting it in now to make that easier
to work on.
Diffstat (limited to 'usr.bin/tmux/layout-manual.c')
-rw-r--r-- | usr.bin/tmux/layout-manual.c | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/usr.bin/tmux/layout-manual.c b/usr.bin/tmux/layout-manual.c index 66d472d620b..c2ee82c3cb2 100644 --- a/usr.bin/tmux/layout-manual.c +++ b/usr.bin/tmux/layout-manual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout-manual.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: layout-manual.c,v 1.2 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,7 +26,7 @@ void layout_manual_v_refresh(struct window *w, unused int active_only) { struct window_pane *wp; - u_int npanes, canfit, total; + u_int npanes, total, height; int left; if (active_only) @@ -35,34 +35,25 @@ layout_manual_v_refresh(struct window *w, unused int active_only) if (TAILQ_EMPTY(&w->panes)) return; - /* Clear hidden flags. */ - TAILQ_FOREACH(wp, &w->panes, entry) - wp->flags &= ~PANE_HIDDEN; - /* Check the new size. */ npanes = window_count_panes(w); if (w->sy <= PANE_MINIMUM * npanes) { - /* How many can we fit? */ - canfit = w->sy / PANE_MINIMUM; - if (canfit == 0) { - /* None. Just use this size for the first. */ - TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp == TAILQ_FIRST(&w->panes)) - wp->sy = w->sy; - else - wp->flags |= PANE_HIDDEN; - } - } else { - /* >=1, set minimum for them all. */ - TAILQ_FOREACH(wp, &w->panes, entry) { - if (canfit-- > 0) - wp->sy = PANE_MINIMUM - 1; - else - wp->flags |= PANE_HIDDEN; - } - /* And increase the first by the rest. */ - TAILQ_FIRST(&w->panes)->sy += 1 + w->sy % PANE_MINIMUM; + /* + * 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; @@ -174,8 +165,6 @@ layout_manual_v_update_offsets(struct window *w) yoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp->flags & PANE_HIDDEN) - continue; wp->xoff = 0; wp->yoff = yoff; yoff += wp->sy + 1; |