In the built-in layouts, distribute the panes more evenly. Set the

default value of main-pane-width to 80, rather than 81. By Micah Cowan.
This commit is contained in:
Nicholas Marriott 2010-12-08 19:57:03 +00:00
parent e26a351865
commit 1f18523565
2 changed files with 43 additions and 44 deletions

View File

@ -135,10 +135,9 @@ layout_set_even_h(struct window *w)
return; return;
/* How many can we fit? */ /* How many can we fit? */
if (w->sx / n < PANE_MINIMUM + 1) width = (w->sx - (n - 1)) / n;
width = PANE_MINIMUM + 1; if (width < PANE_MINIMUM)
else width = PANE_MINIMUM;
width = w->sx / n;
/* Free the old root and construct a new. */ /* Free the old root and construct a new. */
layout_free(w); layout_free(w);
@ -151,12 +150,12 @@ layout_set_even_h(struct window *w)
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
/* Create child cell. */ /* Create child cell. */
lcnew = layout_create_cell(lc); lcnew = layout_create_cell(lc);
layout_set_size(lcnew, width - 1, w->sy, xoff, 0); layout_set_size(lcnew, width, w->sy, xoff, 0);
layout_make_leaf(lcnew, wp); layout_make_leaf(lcnew, wp);
TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry);
i++; i++;
xoff += width; xoff += width + 1;
} }
/* Allocate any remaining space. */ /* Allocate any remaining space. */
@ -189,10 +188,9 @@ layout_set_even_v(struct window *w)
return; return;
/* How many can we fit? */ /* How many can we fit? */
if (w->sy / n < PANE_MINIMUM + 1) height = (w->sy - (n - 1)) / n;
height = PANE_MINIMUM + 1; if (height < PANE_MINIMUM)
else height = PANE_MINIMUM;
height = w->sy / n;
/* Free the old root and construct a new. */ /* Free the old root and construct a new. */
layout_free(w); layout_free(w);
@ -205,12 +203,12 @@ layout_set_even_v(struct window *w)
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
/* Create child cell. */ /* Create child cell. */
lcnew = layout_create_cell(lc); lcnew = layout_create_cell(lc);
layout_set_size(lcnew, w->sx, height - 1, 0, yoff); layout_set_size(lcnew, w->sx, height, 0, yoff);
layout_make_leaf(lcnew, wp); layout_make_leaf(lcnew, wp);
TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry);
i++; i++;
yoff += height; yoff += height + 1;
} }
/* Allocate any remaining space. */ /* Allocate any remaining space. */
@ -244,13 +242,13 @@ layout_set_main_h(struct window *w)
return; return;
n--; /* take off main pane */ n--; /* take off main pane */
/* How many rows and columns will be needed? */ /* How many rows and columns will be needed, not counting main? */
columns = w->sx / (PANE_MINIMUM + 1); /* maximum columns */ columns = (w->sx + 1) / (PANE_MINIMUM + 1); /* maximum columns */
if (columns == 0) if (columns == 0)
columns = 1; columns = 1;
rows = 1 + (n - 1) / columns; rows = 1 + (n - 1) / columns;
columns = 1 + (n - 1) / rows; columns = 1 + (n - 1) / rows;
width = w->sx / columns; width = (w->sx - (n - 1)) / columns;
/* Get the main pane height and add one for separator line. */ /* Get the main pane height and add one for separator line. */
mainheight = options_get_number(&w->options, "main-pane-height") + 1; mainheight = options_get_number(&w->options, "main-pane-height") + 1;
@ -264,14 +262,14 @@ layout_set_main_h(struct window *w)
mainheight = PANE_MINIMUM + 2; mainheight = PANE_MINIMUM + 2;
else else
mainheight = w->sy - totalrows; mainheight = w->sy - totalrows;
height = PANE_MINIMUM + 1; height = PANE_MINIMUM;
} else } else
height = (w->sy - mainheight) / rows; height = (w->sy - mainheight - (rows - 1)) / rows;
/* Free old tree and create a new root. */ /* Free old tree and create a new root. */
layout_free(w); layout_free(w);
lc = w->layout_root = layout_create_cell(NULL); lc = w->layout_root = layout_create_cell(NULL);
layout_set_size(lc, w->sx, mainheight + rows * height, 0, 0); layout_set_size(lc, w->sx, mainheight + rows * (height + 1) - 1, 0, 0);
layout_make_node(lc, LAYOUT_TOPBOTTOM); layout_make_node(lc, LAYOUT_TOPBOTTOM);
/* Create the main pane. */ /* Create the main pane. */
@ -289,7 +287,7 @@ layout_set_main_h(struct window *w)
/* Create the new row. */ /* Create the new row. */
lcrow = layout_create_cell(lc); lcrow = layout_create_cell(lc);
layout_set_size(lcrow, w->sx, height - 1, 0, 0); layout_set_size(lcrow, w->sx, height, 0, 0);
TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry); TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry);
/* If only one column, just use the row directly. */ /* If only one column, just use the row directly. */
@ -304,7 +302,7 @@ layout_set_main_h(struct window *w)
for (i = 0; i < columns; i++) { for (i = 0; i < columns; i++) {
/* Create and add a pane cell. */ /* Create and add a pane cell. */
lcchild = layout_create_cell(lcrow); lcchild = layout_create_cell(lcrow);
layout_set_size(lcchild, width - 1, height - 1, 0, 0); layout_set_size(lcchild, width, height, 0, 0);
layout_make_leaf(lcchild, wp); layout_make_leaf(lcchild, wp);
TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry);
@ -316,7 +314,7 @@ layout_set_main_h(struct window *w)
/* Adjust the row to fit the full width if necessary. */ /* Adjust the row to fit the full width if necessary. */
if (i == columns) if (i == columns)
i--; i--;
used = ((i + 1) * width) - 1; used = ((i + 1) * (width + 1)) - 1;
if (w->sx <= used) if (w->sx <= used)
continue; continue;
lcchild = TAILQ_LAST(&lcrow->cells, layout_cells); lcchild = TAILQ_LAST(&lcrow->cells, layout_cells);
@ -324,7 +322,7 @@ layout_set_main_h(struct window *w)
} }
/* Adjust the last row height to fit if necessary. */ /* Adjust the last row height to fit if necessary. */
used = mainheight + (rows * height) - 1; used = mainheight + (rows * height) + rows - 1;
if (w->sy > used) { if (w->sy > used) {
lcrow = TAILQ_LAST(&lc->cells, layout_cells); lcrow = TAILQ_LAST(&lc->cells, layout_cells);
layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used); layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used);
@ -355,13 +353,13 @@ layout_set_main_v(struct window *w)
return; return;
n--; /* take off main pane */ n--; /* take off main pane */
/* How many rows and columns will be needed? */ /* How many rows and columns will be needed, not counting main? */
rows = w->sy / (PANE_MINIMUM + 1); /* maximum rows */ rows = (w->sy + 1) / (PANE_MINIMUM + 1); /* maximum rows */
if (rows == 0) if (rows == 0)
rows = 1; rows = 1;
columns = 1 + (n - 1) / rows; columns = 1 + (n - 1) / rows;
rows = 1 + (n - 1) / columns; rows = 1 + (n - 1) / columns;
height = w->sy / rows; height = (w->sy - (n - 1)) / rows;
/* Get the main pane width and add one for separator line. */ /* Get the main pane width and add one for separator line. */
mainwidth = options_get_number(&w->options, "main-pane-width") + 1; mainwidth = options_get_number(&w->options, "main-pane-width") + 1;
@ -375,14 +373,14 @@ layout_set_main_v(struct window *w)
mainwidth = PANE_MINIMUM + 2; mainwidth = PANE_MINIMUM + 2;
else else
mainwidth = w->sx - totalcolumns; mainwidth = w->sx - totalcolumns;
width = PANE_MINIMUM + 1; width = PANE_MINIMUM;
} else } else
width = (w->sx - mainwidth) / columns; width = (w->sx - mainwidth - (columns - 1)) / columns;
/* Free old tree and create a new root. */ /* Free old tree and create a new root. */
layout_free(w); layout_free(w);
lc = w->layout_root = layout_create_cell(NULL); lc = w->layout_root = layout_create_cell(NULL);
layout_set_size(lc, mainwidth + columns * width, w->sy, 0, 0); layout_set_size(lc, mainwidth + columns * (width + 1) - 1, w->sy, 0, 0);
layout_make_node(lc, LAYOUT_LEFTRIGHT); layout_make_node(lc, LAYOUT_LEFTRIGHT);
/* Create the main pane. */ /* Create the main pane. */
@ -400,7 +398,7 @@ layout_set_main_v(struct window *w)
/* Create the new column. */ /* Create the new column. */
lccolumn = layout_create_cell(lc); lccolumn = layout_create_cell(lc);
layout_set_size(lccolumn, width - 1, w->sy, 0, 0); layout_set_size(lccolumn, width, w->sy, 0, 0);
TAILQ_INSERT_TAIL(&lc->cells, lccolumn, entry); TAILQ_INSERT_TAIL(&lc->cells, lccolumn, entry);
/* If only one row, just use the row directly. */ /* If only one row, just use the row directly. */
@ -415,7 +413,7 @@ layout_set_main_v(struct window *w)
for (i = 0; i < rows; i++) { for (i = 0; i < rows; i++) {
/* Create and add a pane cell. */ /* Create and add a pane cell. */
lcchild = layout_create_cell(lccolumn); lcchild = layout_create_cell(lccolumn);
layout_set_size(lcchild, width - 1, height - 1, 0, 0); layout_set_size(lcchild, width, height, 0, 0);
layout_make_leaf(lcchild, wp); layout_make_leaf(lcchild, wp);
TAILQ_INSERT_TAIL(&lccolumn->cells, lcchild, entry); TAILQ_INSERT_TAIL(&lccolumn->cells, lcchild, entry);
@ -427,7 +425,7 @@ layout_set_main_v(struct window *w)
/* Adjust the column to fit the full height if necessary. */ /* Adjust the column to fit the full height if necessary. */
if (i == rows) if (i == rows)
i--; i--;
used = ((i + 1) * height) - 1; used = ((i + 1) * (height + 1)) - 1;
if (w->sy <= used) if (w->sy <= used)
continue; continue;
lcchild = TAILQ_LAST(&lccolumn->cells, layout_cells); lcchild = TAILQ_LAST(&lccolumn->cells, layout_cells);
@ -435,7 +433,7 @@ layout_set_main_v(struct window *w)
} }
/* Adjust the last column width to fit if necessary. */ /* Adjust the last column width to fit if necessary. */
used = mainwidth + (columns * width) - 1; used = mainwidth + (columns * width) + columns - 1;
if (w->sx > used) { if (w->sx > used) {
lccolumn = TAILQ_LAST(&lc->cells, layout_cells); lccolumn = TAILQ_LAST(&lc->cells, layout_cells);
layout_resize_adjust(lccolumn, LAYOUT_LEFTRIGHT, w->sx - used); layout_resize_adjust(lccolumn, LAYOUT_LEFTRIGHT, w->sx - used);
@ -474,17 +472,18 @@ layout_set_tiled(struct window *w)
} }
/* What width and height should they be? */ /* What width and height should they be? */
width = w->sx / columns; width = (w->sx - (columns - 1)) / columns;
if (width < PANE_MINIMUM + 1) if (width < PANE_MINIMUM)
width = PANE_MINIMUM + 1; width = PANE_MINIMUM;
height = w->sy / rows; height = (w->sy - (rows - 1)) / rows;
if (width < PANE_MINIMUM + 1) if (height < PANE_MINIMUM)
width = PANE_MINIMUM + 1; height = PANE_MINIMUM;
/* Free old tree and create a new root. */ /* Free old tree and create a new root. */
layout_free(w); layout_free(w);
lc = w->layout_root = layout_create_cell(NULL); lc = w->layout_root = layout_create_cell(NULL);
layout_set_size(lc, width * columns, height * rows, 0, 0); layout_set_size(lc, (width + 1) * columns - 1,
(height + 1) * rows - 1, 0, 0);
layout_make_node(lc, LAYOUT_TOPBOTTOM); layout_make_node(lc, LAYOUT_TOPBOTTOM);
/* Create a grid of the cells. */ /* Create a grid of the cells. */
@ -496,7 +495,7 @@ layout_set_tiled(struct window *w)
/* Create the new row. */ /* Create the new row. */
lcrow = layout_create_cell(lc); lcrow = layout_create_cell(lc);
layout_set_size(lcrow, w->sx, height - 1, 0, 0); layout_set_size(lcrow, w->sx, height, 0, 0);
TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry); TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry);
/* If only one column, just use the row directly. */ /* If only one column, just use the row directly. */
@ -511,7 +510,7 @@ layout_set_tiled(struct window *w)
for (i = 0; i < columns; i++) { for (i = 0; i < columns; i++) {
/* Create and add a pane cell. */ /* Create and add a pane cell. */
lcchild = layout_create_cell(lcrow); lcchild = layout_create_cell(lcrow);
layout_set_size(lcchild, width - 1, height - 1, 0, 0); layout_set_size(lcchild, width, height, 0, 0);
layout_make_leaf(lcchild, wp); layout_make_leaf(lcchild, wp);
TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry);
@ -526,7 +525,7 @@ layout_set_tiled(struct window *w)
*/ */
if (i == columns) if (i == columns)
i--; i--;
used = ((i + 1) * width) - 1; used = ((i + 1) * (width + 1)) - 1;
if (w->sx <= used) if (w->sx <= used)
continue; continue;
lcchild = TAILQ_LAST(&lcrow->cells, layout_cells); lcchild = TAILQ_LAST(&lcrow->cells, layout_cells);
@ -534,7 +533,7 @@ layout_set_tiled(struct window *w)
} }
/* Adjust the last row height to fit if necessary. */ /* Adjust the last row height to fit if necessary. */
used = (rows * height) - 1; used = (rows * height) + rows - 1;
if (w->sy > used) { if (w->sy > used) {
lcrow = TAILQ_LAST(&lc->cells, layout_cells); lcrow = TAILQ_LAST(&lc->cells, layout_cells);
layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used); layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used);

2
tmux.c
View File

@ -396,7 +396,7 @@ main(int argc, char **argv)
options_set_number(wo, "force-height", 0); options_set_number(wo, "force-height", 0);
options_set_number(wo, "force-width", 0); options_set_number(wo, "force-width", 0);
options_set_number(wo, "main-pane-height", 24); options_set_number(wo, "main-pane-height", 24);
options_set_number(wo, "main-pane-width", 81); options_set_number(wo, "main-pane-width", 80);
options_set_number(wo, "mode-attr", 0); options_set_number(wo, "mode-attr", 0);
options_set_number(wo, "mode-bg", 3); options_set_number(wo, "mode-bg", 3);
options_set_number(wo, "mode-fg", 0); options_set_number(wo, "mode-fg", 0);