=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/layout-set.c,v retrieving revision 1.6 retrieving revision 1.7 diff -c -r1.6 -r1.7 *** src/usr.bin/tmux/layout-set.c 2010/04/25 20:28:13 1.6 --- src/usr.bin/tmux/layout-set.c 2010/12/08 19:57:03 1.7 *************** *** 1,4 **** ! /* $OpenBSD: layout-set.c,v 1.6 2010/04/25 20:28:13 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: layout-set.c,v 1.7 2010/12/08 19:57:03 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 135,144 **** return; /* How many can we fit? */ ! if (w->sx / n < PANE_MINIMUM + 1) ! width = PANE_MINIMUM + 1; ! else ! width = w->sx / n; /* Free the old root and construct a new. */ layout_free(w); --- 135,143 ---- return; /* How many can we fit? */ ! width = (w->sx - (n - 1)) / n; ! if (width < PANE_MINIMUM) ! width = PANE_MINIMUM; /* Free the old root and construct a new. */ layout_free(w); *************** *** 151,162 **** TAILQ_FOREACH(wp, &w->panes, entry) { /* Create child cell. */ lcnew = layout_create_cell(lc); ! layout_set_size(lcnew, width - 1, w->sy, xoff, 0); layout_make_leaf(lcnew, wp); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); i++; ! xoff += width; } /* Allocate any remaining space. */ --- 150,161 ---- TAILQ_FOREACH(wp, &w->panes, entry) { /* Create child cell. */ lcnew = layout_create_cell(lc); ! layout_set_size(lcnew, width, w->sy, xoff, 0); layout_make_leaf(lcnew, wp); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); i++; ! xoff += width + 1; } /* Allocate any remaining space. */ *************** *** 189,198 **** return; /* How many can we fit? */ ! if (w->sy / n < PANE_MINIMUM + 1) ! height = PANE_MINIMUM + 1; ! else ! height = w->sy / n; /* Free the old root and construct a new. */ layout_free(w); --- 188,196 ---- return; /* How many can we fit? */ ! height = (w->sy - (n - 1)) / n; ! if (height < PANE_MINIMUM) ! height = PANE_MINIMUM; /* Free the old root and construct a new. */ layout_free(w); *************** *** 205,216 **** TAILQ_FOREACH(wp, &w->panes, entry) { /* Create child cell. */ lcnew = layout_create_cell(lc); ! layout_set_size(lcnew, w->sx, height - 1, 0, yoff); layout_make_leaf(lcnew, wp); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); i++; ! yoff += height; } /* Allocate any remaining space. */ --- 203,214 ---- TAILQ_FOREACH(wp, &w->panes, entry) { /* Create child cell. */ lcnew = layout_create_cell(lc); ! layout_set_size(lcnew, w->sx, height, 0, yoff); layout_make_leaf(lcnew, wp); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); i++; ! yoff += height + 1; } /* Allocate any remaining space. */ *************** *** 244,256 **** return; n--; /* take off main pane */ ! /* How many rows and columns will be needed? */ ! columns = w->sx / (PANE_MINIMUM + 1); /* maximum columns */ if (columns == 0) columns = 1; rows = 1 + (n - 1) / columns; columns = 1 + (n - 1) / rows; ! width = w->sx / columns; /* Get the main pane height and add one for separator line. */ mainheight = options_get_number(&w->options, "main-pane-height") + 1; --- 242,254 ---- return; n--; /* take off main pane */ ! /* How many rows and columns will be needed, not counting main? */ ! columns = (w->sx + 1) / (PANE_MINIMUM + 1); /* maximum columns */ if (columns == 0) columns = 1; rows = 1 + (n - 1) / columns; columns = 1 + (n - 1) / rows; ! width = (w->sx - (n - 1)) / columns; /* Get the main pane height and add one for separator line. */ mainheight = options_get_number(&w->options, "main-pane-height") + 1; *************** *** 264,277 **** mainheight = PANE_MINIMUM + 2; else mainheight = w->sy - totalrows; ! height = PANE_MINIMUM + 1; } else ! height = (w->sy - mainheight) / rows; /* Free old tree and create a new root. */ layout_free(w); lc = w->layout_root = layout_create_cell(NULL); ! layout_set_size(lc, w->sx, mainheight + rows * height, 0, 0); layout_make_node(lc, LAYOUT_TOPBOTTOM); /* Create the main pane. */ --- 262,275 ---- mainheight = PANE_MINIMUM + 2; else mainheight = w->sy - totalrows; ! height = PANE_MINIMUM; } else ! height = (w->sy - mainheight - (rows - 1)) / rows; /* Free old tree and create a new root. */ layout_free(w); lc = w->layout_root = layout_create_cell(NULL); ! layout_set_size(lc, w->sx, mainheight + rows * (height + 1) - 1, 0, 0); layout_make_node(lc, LAYOUT_TOPBOTTOM); /* Create the main pane. */ *************** *** 289,295 **** /* Create the new row. */ lcrow = layout_create_cell(lc); ! layout_set_size(lcrow, w->sx, height - 1, 0, 0); TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry); /* If only one column, just use the row directly. */ --- 287,293 ---- /* Create the new row. */ lcrow = layout_create_cell(lc); ! layout_set_size(lcrow, w->sx, height, 0, 0); TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry); /* If only one column, just use the row directly. */ *************** *** 304,310 **** for (i = 0; i < columns; i++) { /* Create and add a pane cell. */ lcchild = layout_create_cell(lcrow); ! layout_set_size(lcchild, width - 1, height - 1, 0, 0); layout_make_leaf(lcchild, wp); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); --- 302,308 ---- for (i = 0; i < columns; i++) { /* Create and add a pane cell. */ lcchild = layout_create_cell(lcrow); ! layout_set_size(lcchild, width, height, 0, 0); layout_make_leaf(lcchild, wp); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); *************** *** 316,322 **** /* Adjust the row to fit the full width if necessary. */ if (i == columns) i--; ! used = ((i + 1) * width) - 1; if (w->sx <= used) continue; lcchild = TAILQ_LAST(&lcrow->cells, layout_cells); --- 314,320 ---- /* Adjust the row to fit the full width if necessary. */ if (i == columns) i--; ! used = ((i + 1) * (width + 1)) - 1; if (w->sx <= used) continue; lcchild = TAILQ_LAST(&lcrow->cells, layout_cells); *************** *** 324,330 **** } /* Adjust the last row height to fit if necessary. */ ! used = mainheight + (rows * height) - 1; if (w->sy > used) { lcrow = TAILQ_LAST(&lc->cells, layout_cells); layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used); --- 322,328 ---- } /* Adjust the last row height to fit if necessary. */ ! used = mainheight + (rows * height) + rows - 1; if (w->sy > used) { lcrow = TAILQ_LAST(&lc->cells, layout_cells); layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used); *************** *** 355,367 **** return; n--; /* take off main pane */ ! /* How many rows and columns will be needed? */ ! rows = w->sy / (PANE_MINIMUM + 1); /* maximum rows */ if (rows == 0) rows = 1; columns = 1 + (n - 1) / rows; rows = 1 + (n - 1) / columns; ! height = w->sy / rows; /* Get the main pane width and add one for separator line. */ mainwidth = options_get_number(&w->options, "main-pane-width") + 1; --- 353,365 ---- return; n--; /* take off main pane */ ! /* How many rows and columns will be needed, not counting main? */ ! rows = (w->sy + 1) / (PANE_MINIMUM + 1); /* maximum rows */ if (rows == 0) rows = 1; columns = 1 + (n - 1) / rows; rows = 1 + (n - 1) / columns; ! height = (w->sy - (n - 1)) / rows; /* Get the main pane width and add one for separator line. */ mainwidth = options_get_number(&w->options, "main-pane-width") + 1; *************** *** 375,388 **** mainwidth = PANE_MINIMUM + 2; else mainwidth = w->sx - totalcolumns; ! width = PANE_MINIMUM + 1; } else ! width = (w->sx - mainwidth) / columns; /* Free old tree and create a new root. */ layout_free(w); lc = w->layout_root = layout_create_cell(NULL); ! layout_set_size(lc, mainwidth + columns * width, w->sy, 0, 0); layout_make_node(lc, LAYOUT_LEFTRIGHT); /* Create the main pane. */ --- 373,386 ---- mainwidth = PANE_MINIMUM + 2; else mainwidth = w->sx - totalcolumns; ! width = PANE_MINIMUM; } else ! width = (w->sx - mainwidth - (columns - 1)) / columns; /* Free old tree and create a new root. */ layout_free(w); lc = w->layout_root = layout_create_cell(NULL); ! layout_set_size(lc, mainwidth + columns * (width + 1) - 1, w->sy, 0, 0); layout_make_node(lc, LAYOUT_LEFTRIGHT); /* Create the main pane. */ *************** *** 400,406 **** /* Create the new column. */ lccolumn = layout_create_cell(lc); ! layout_set_size(lccolumn, width - 1, w->sy, 0, 0); TAILQ_INSERT_TAIL(&lc->cells, lccolumn, entry); /* If only one row, just use the row directly. */ --- 398,404 ---- /* Create the new column. */ lccolumn = layout_create_cell(lc); ! layout_set_size(lccolumn, width, w->sy, 0, 0); TAILQ_INSERT_TAIL(&lc->cells, lccolumn, entry); /* If only one row, just use the row directly. */ *************** *** 415,421 **** for (i = 0; i < rows; i++) { /* Create and add a pane cell. */ lcchild = layout_create_cell(lccolumn); ! layout_set_size(lcchild, width - 1, height - 1, 0, 0); layout_make_leaf(lcchild, wp); TAILQ_INSERT_TAIL(&lccolumn->cells, lcchild, entry); --- 413,419 ---- for (i = 0; i < rows; i++) { /* Create and add a pane cell. */ lcchild = layout_create_cell(lccolumn); ! layout_set_size(lcchild, width, height, 0, 0); layout_make_leaf(lcchild, wp); TAILQ_INSERT_TAIL(&lccolumn->cells, lcchild, entry); *************** *** 427,433 **** /* Adjust the column to fit the full height if necessary. */ if (i == rows) i--; ! used = ((i + 1) * height) - 1; if (w->sy <= used) continue; lcchild = TAILQ_LAST(&lccolumn->cells, layout_cells); --- 425,431 ---- /* Adjust the column to fit the full height if necessary. */ if (i == rows) i--; ! used = ((i + 1) * (height + 1)) - 1; if (w->sy <= used) continue; lcchild = TAILQ_LAST(&lccolumn->cells, layout_cells); *************** *** 435,441 **** } /* Adjust the last column width to fit if necessary. */ ! used = mainwidth + (columns * width) - 1; if (w->sx > used) { lccolumn = TAILQ_LAST(&lc->cells, layout_cells); layout_resize_adjust(lccolumn, LAYOUT_LEFTRIGHT, w->sx - used); --- 433,439 ---- } /* Adjust the last column width to fit if necessary. */ ! used = mainwidth + (columns * width) + columns - 1; if (w->sx > used) { lccolumn = TAILQ_LAST(&lc->cells, layout_cells); layout_resize_adjust(lccolumn, LAYOUT_LEFTRIGHT, w->sx - used); *************** *** 474,490 **** } /* What width and height should they be? */ ! width = w->sx / columns; ! if (width < PANE_MINIMUM + 1) ! width = PANE_MINIMUM + 1; ! height = w->sy / rows; ! if (width < PANE_MINIMUM + 1) ! width = PANE_MINIMUM + 1; /* Free old tree and create a new root. */ layout_free(w); lc = w->layout_root = layout_create_cell(NULL); ! layout_set_size(lc, width * columns, height * rows, 0, 0); layout_make_node(lc, LAYOUT_TOPBOTTOM); /* Create a grid of the cells. */ --- 472,489 ---- } /* What width and height should they be? */ ! width = (w->sx - (columns - 1)) / columns; ! if (width < PANE_MINIMUM) ! width = PANE_MINIMUM; ! height = (w->sy - (rows - 1)) / rows; ! if (height < PANE_MINIMUM) ! height = PANE_MINIMUM; /* Free old tree and create a new root. */ layout_free(w); lc = w->layout_root = layout_create_cell(NULL); ! layout_set_size(lc, (width + 1) * columns - 1, ! (height + 1) * rows - 1, 0, 0); layout_make_node(lc, LAYOUT_TOPBOTTOM); /* Create a grid of the cells. */ *************** *** 496,502 **** /* Create the new row. */ lcrow = layout_create_cell(lc); ! layout_set_size(lcrow, w->sx, height - 1, 0, 0); TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry); /* If only one column, just use the row directly. */ --- 495,501 ---- /* Create the new row. */ lcrow = layout_create_cell(lc); ! layout_set_size(lcrow, w->sx, height, 0, 0); TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry); /* If only one column, just use the row directly. */ *************** *** 511,517 **** for (i = 0; i < columns; i++) { /* Create and add a pane cell. */ lcchild = layout_create_cell(lcrow); ! layout_set_size(lcchild, width - 1, height - 1, 0, 0); layout_make_leaf(lcchild, wp); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); --- 510,516 ---- for (i = 0; i < columns; i++) { /* Create and add a pane cell. */ lcchild = layout_create_cell(lcrow); ! layout_set_size(lcchild, width, height, 0, 0); layout_make_leaf(lcchild, wp); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); *************** *** 526,532 **** */ if (i == columns) i--; ! used = ((i + 1) * width) - 1; if (w->sx <= used) continue; lcchild = TAILQ_LAST(&lcrow->cells, layout_cells); --- 525,531 ---- */ if (i == columns) i--; ! used = ((i + 1) * (width + 1)) - 1; if (w->sx <= used) continue; lcchild = TAILQ_LAST(&lcrow->cells, layout_cells); *************** *** 534,540 **** } /* Adjust the last row height to fit if necessary. */ ! used = (rows * height) - 1; if (w->sy > used) { lcrow = TAILQ_LAST(&lc->cells, layout_cells); layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used); --- 533,539 ---- } /* Adjust the last row height to fit if necessary. */ ! used = (rows * height) + rows - 1; if (w->sy > used) { lcrow = TAILQ_LAST(&lc->cells, layout_cells); layout_resize_adjust(lcrow, LAYOUT_TOPBOTTOM, w->sy - used);