aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--layout.c74
-rw-r--r--tmux.c3
3 files changed, 77 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index f6cd2fc7..cc219150 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
18 May 2009
+* main-horizontal layout and main-pane-height option to match vertical.
* New window option main-pane-width to set the width of the large left pane with
main-vertical (was left-vertical) layout.
* Lots of layout cleanup. manual layout is now manual-vertical.
@@ -1269,7 +1270,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.291 2009-05-18 21:58:40 nicm Exp $
+$Id: CHANGES,v 1.292 2009-05-18 22:17:24 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
diff --git a/layout.c b/layout.c
index b3e7e963..7d6e3994 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.13 2009-05-18 21:58:40 nicm Exp $ */
+/* $Id: layout.c,v 1.14 2009-05-18 22:17:24 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,6 +34,7 @@
void layout_active_only_refresh(struct window *, int);
void layout_even_h_refresh(struct window *, int);
void layout_even_v_refresh(struct window *, int);
+void layout_main_h_refresh(struct window *, int);
void layout_main_v_refresh(struct window *, int);
const struct {
@@ -45,6 +46,7 @@ const struct {
{ "active-only", layout_active_only_refresh, NULL },
{ "even-horizontal", layout_even_h_refresh, NULL },
{ "even-vertical", layout_even_v_refresh, NULL },
+ { "main-horizontal", layout_main_h_refresh, NULL },
{ "main-vertical", layout_main_v_refresh, NULL },
};
@@ -299,3 +301,73 @@ layout_main_v_refresh(struct window *w, int active_only)
window_pane_resize(wp, wp->sx, wp->sy + 1);
}
}
+
+void
+layout_main_h_refresh(struct window *w, int active_only)
+{
+ struct window_pane *wp;
+ u_int i, n, mainheight, width, xoff;
+
+ if (active_only)
+ return;
+
+ /* Get number of panes. */
+ n = window_count_panes(w);
+ if (n == 0)
+ return;
+
+ /* Get the main pane height and add one for separator line. */
+ mainheight = options_get_number(&w->options, "main-pane-height") + 1;
+
+ /* Need >1 pane and minimum rows; if fewer, display active only. */
+ if (n == 1 || w->sy < mainheight + PANE_MINIMUM) {
+ layout_active_only_refresh(w, active_only);
+ return;
+ }
+ n--;
+
+ /* How many can we fit, not including first? */
+ if (w->sx / n < PANE_MINIMUM) {
+ width = PANE_MINIMUM;
+ n = w->sx / PANE_MINIMUM;
+ } else
+ width = w->sx / n;
+
+ /* Fit the panes. */
+ i = xoff = 0;
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (wp == TAILQ_FIRST(&w->panes)) {
+ wp->xoff = 0;
+ wp->yoff = 0;
+ window_pane_resize(wp, w->sx, mainheight - 1);
+ wp->flags &= ~PANE_HIDDEN;
+ continue;
+ }
+
+ if (i > n) {
+ wp->flags |= PANE_HIDDEN;
+ continue;
+ }
+ wp->flags &= ~PANE_HIDDEN;
+
+ wp->xoff = xoff;
+ wp->yoff = mainheight;
+ if (i != n - 1)
+ window_pane_resize(wp, width - 1, w->sy - mainheight);
+ else
+ window_pane_resize(wp, width - 1, w->sy - mainheight);
+
+ i++;
+ xoff += width;
+ }
+
+ /* Any space left? */
+ while (xoff++ < w->sx + 1) {
+ wp = TAILQ_LAST(&w->panes, window_panes);
+ while (wp != NULL && wp == TAILQ_FIRST(&w->panes))
+ wp = TAILQ_PREV(wp, window_panes, entry);
+ if (wp == NULL)
+ break;
+ window_pane_resize(wp, wp->sx + 1, wp->sy);
+ }
+}
diff --git a/tmux.c b/tmux.c
index d940f1fb..d96eedf0 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.118 2009-05-18 21:55:53 nicm Exp $ */
+/* $Id: tmux.c,v 1.119 2009-05-18 22:17:24 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -323,6 +323,7 @@ main(int argc, char **argv)
options_set_number(
&global_window_options, "mode-attr", GRID_ATTR_REVERSE);
options_set_number(&global_window_options, "main-pane-width", 81);
+ options_set_number(&global_window_options, "main-pane-height", 24);
options_set_number(&global_window_options, "mode-bg", 3);
options_set_number(&global_window_options, "mode-fg", 0);
options_set_number(&global_window_options, "mode-keys", MODEKEY_EMACS);