summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--layout.c36
-rw-r--r--options-table.c2
-rw-r--r--screen-redraw.c22
-rw-r--r--tmux.h5
-rw-r--r--window.c48
5 files changed, 69 insertions, 44 deletions
diff --git a/layout.c b/layout.c
index 86d307ef..6e78b439 100644
--- a/layout.c
+++ b/layout.c
@@ -232,20 +232,20 @@ layout_fix_offsets(struct layout_cell *lc)
* case for the most upper panes only.
*/
static int
-layout_need_status(struct layout_cell *lc, int at_top)
+layout_need_status(struct layout_cell *lc, int status)
{
- struct layout_cell *first_lc;
+ struct layout_cell *next;
if (lc->parent != NULL) {
if (lc->parent->type == LAYOUT_LEFTRIGHT)
- return (layout_need_status(lc->parent, at_top));
+ return (layout_need_status(lc->parent, status));
- if (at_top)
- first_lc = TAILQ_FIRST(&lc->parent->cells);
+ if (status == PANE_STATUS_TOP)
+ next = TAILQ_FIRST(&lc->parent->cells);
else
- first_lc = TAILQ_LAST(&lc->parent->cells,layout_cells);
- if (lc == first_lc)
- return (layout_need_status(lc->parent, at_top));
+ next = TAILQ_LAST(&lc->parent->cells,layout_cells);
+ if (lc == next)
+ return (layout_need_status(lc->parent, status));
return (0);
}
return (1);
@@ -264,8 +264,8 @@ layout_fix_panes(struct window *w)
if ((lc = wp->layout_cell) == NULL)
continue;
- if (status != 0)
- shift = layout_need_status(lc, status == 1);
+ if (status != PANE_STATUS_OFF)
+ shift = layout_need_status(lc, status);
else
shift = 0;
@@ -317,8 +317,8 @@ layout_resize_check(struct window *w, struct layout_cell *lc,
available = lc->sx;
else {
available = lc->sy;
- if (status != 0)
- minimum += layout_need_status(lc, status == 1);
+ if (status != PANE_STATUS_OFF)
+ minimum += layout_need_status(lc, status);
}
if (available > minimum)
available -= minimum;
@@ -862,8 +862,8 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
break;
case LAYOUT_TOPBOTTOM:
minimum = PANE_MINIMUM * 2 + 1;
- if (status != 0)
- minimum += layout_need_status(lc, status == 1);
+ if (status != PANE_STATUS_OFF)
+ minimum += layout_need_status(lc, status);
if (sy < minimum)
return (NULL);
break;
@@ -1030,8 +1030,8 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
size = parent->sx;
else if (parent->type == LAYOUT_TOPBOTTOM) {
size = parent->sy;
- if (status != 0)
- size -= layout_need_status(parent, status == 1);
+ if (status != PANE_STATUS_OFF)
+ size -= layout_need_status(parent, status);
} else
return (0);
if (size < number - 1)
@@ -1050,8 +1050,8 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, change);
} else if (parent->type == LAYOUT_TOPBOTTOM) {
this = each;
- if (status != 0)
- this += layout_need_status(lc, status == 1);
+ if (status != PANE_STATUS_OFF)
+ this += layout_need_status(lc, status);
change = this - (int)lc->sy;
layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, change);
}
diff --git a/options-table.c b/options-table.c
index 228cf3f0..7bb767c7 100644
--- a/options-table.c
+++ b/options-table.c
@@ -689,7 +689,7 @@ const struct options_table_entry options_table[] = {
.type = OPTIONS_TABLE_CHOICE,
.scope = OPTIONS_TABLE_WINDOW,
.choices = options_table_pane_status_list,
- .default_num = 0
+ .default_num = PANE_STATUS_OFF
},
{ .name = "pane-border-style",
diff --git a/screen-redraw.c b/screen-redraw.c
index 65e890b6..2943e73b 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -45,10 +45,6 @@ static void screen_redraw_draw_pane(struct screen_redraw_ctx *,
#define CELL_BORDERS " xqlkmjwvtun~"
-#define CELL_STATUS_OFF 0
-#define CELL_STATUS_TOP 1
-#define CELL_STATUS_BOTTOM 2
-
/* Check if cell is on the border of a particular pane. */
static int
screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py)
@@ -112,12 +108,12 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
if (px > w->sx || py > w->sy)
return (CELL_OUTSIDE);
- if (pane_status != CELL_STATUS_OFF) {
+ if (pane_status != PANE_STATUS_OFF) {
TAILQ_FOREACH(wp, &w->panes, entry) {
if (!window_pane_visible(wp))
continue;
- if (pane_status == CELL_STATUS_TOP)
+ if (pane_status == PANE_STATUS_TOP)
line = wp->yoff - 1;
else
line = wp->yoff + wp->sy;
@@ -153,7 +149,7 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
borders |= 8;
if (px <= w->sx && screen_redraw_cell_border(c, px + 1, py))
borders |= 4;
- if (pane_status == CELL_STATUS_TOP) {
+ if (pane_status == PANE_STATUS_TOP) {
if (py != 0 && screen_redraw_cell_border(c, px, py - 1))
borders |= 2;
} else {
@@ -208,9 +204,9 @@ screen_redraw_check_is(u_int px, u_int py, int type, int pane_status,
border = screen_redraw_cell_border1(wantwp, px, py);
if (border == 0 || border == -1)
return (0);
- if (pane_status == CELL_STATUS_TOP && border == 4)
+ if (pane_status == PANE_STATUS_TOP && border == 4)
return (0);
- if (pane_status == CELL_STATUS_BOTTOM && border == 3)
+ if (pane_status == PANE_STATUS_BOTTOM && border == 3)
return (0);
/* If there are more than two panes, that's enough. */
@@ -222,7 +218,7 @@ screen_redraw_check_is(u_int px, u_int py, int type, int pane_status,
return (1);
/* With status lines mark the entire line. */
- if (pane_status != CELL_STATUS_OFF)
+ if (pane_status != PANE_STATUS_OFF)
return (1);
/* Check if the pane covers the whole width. */
@@ -324,7 +320,7 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
s = &wp->status_screen;
size = wp->status_size;
- if (ctx->pane_status == CELL_STATUS_TOP)
+ if (ctx->pane_status == PANE_STATUS_TOP)
yoff = wp->yoff - 1;
else
yoff = wp->yoff + wp->sy;
@@ -386,7 +382,7 @@ screen_redraw_update(struct client *c, int flags)
if (c->overlay_draw != NULL)
flags |= CLIENT_REDRAWOVERLAY;
- if (options_get_number(wo, "pane-border-status") != CELL_STATUS_OFF) {
+ if (options_get_number(wo, "pane-border-status") != PANE_STATUS_OFF) {
redraw = 0;
TAILQ_FOREACH(wp, &w->panes, entry) {
if (screen_redraw_make_pane_status(c, w, wp))
@@ -441,7 +437,7 @@ screen_redraw_screen(struct client *c)
screen_redraw_set_context(c, &ctx);
if (flags & (CLIENT_REDRAWWINDOW|CLIENT_REDRAWBORDERS)) {
- if (ctx.pane_status != CELL_STATUS_OFF)
+ if (ctx.pane_status != PANE_STATUS_OFF)
screen_redraw_draw_pane_status(&ctx);
screen_redraw_draw_borders(&ctx);
}
diff --git a/tmux.h b/tmux.h
index 8adfcba8..ba257ea8 100644
--- a/tmux.h
+++ b/tmux.h
@@ -955,6 +955,11 @@ TAILQ_HEAD(winlink_stack, winlink);
#define WINDOW_SIZE_SMALLEST 1
#define WINDOW_SIZE_MANUAL 2
+/* Pane border status option. */
+#define PANE_STATUS_OFF 0
+#define PANE_STATUS_TOP 1
+#define PANE_STATUS_BOTTOM 2
+
/* Layout direction. */
enum layout_type {
LAYOUT_LEFTRIGHT,
diff --git a/window.c b/window.c
index f900a1b2..c8b9b710 100644
--- a/window.c
+++ b/window.c
@@ -1288,25 +1288,35 @@ window_pane_choose_best(struct window_pane **list, u_int size)
struct window_pane *
window_pane_find_up(struct window_pane *wp)
{
+ struct window *w;
struct window_pane *next, *best, **list;
u_int edge, left, right, end, size;
int status, found;
if (wp == NULL)
return (NULL);
- status = options_get_number(wp->window->options, "pane-border-status");
+ w = wp->window;
+ status = options_get_number(w->options, "pane-border-status");
list = NULL;
size = 0;
edge = wp->yoff;
- if (edge == (status == 1 ? 1 : 0))
- edge = wp->window->sy + 1 - (status == 2 ? 1 : 0);
+ if (status == PANE_STATUS_TOP) {
+ if (edge == 1)
+ edge = w->sy + 1;
+ } else if (status == PANE_STATUS_BOTTOM) {
+ if (edge == 0)
+ edge = w->sy;
+ } else {
+ if (edge == 0)
+ edge = w->sy + 1;
+ }
left = wp->xoff;
right = wp->xoff + wp->sx;
- TAILQ_FOREACH(next, &wp->window->panes, entry) {
+ TAILQ_FOREACH(next, &w->panes, entry) {
if (next == wp)
continue;
if (next->yoff + next->sy + 1 != edge)
@@ -1335,25 +1345,35 @@ window_pane_find_up(struct window_pane *wp)
struct window_pane *
window_pane_find_down(struct window_pane *wp)
{
+ struct window *w;
struct window_pane *next, *best, **list;
u_int edge, left, right, end, size;
int status, found;
if (wp == NULL)
return (NULL);
- status = options_get_number(wp->window->options, "pane-border-status");
+ w = wp->window;
+ status = options_get_number(w->options, "pane-border-status");
list = NULL;
size = 0;
edge = wp->yoff + wp->sy + 1;
- if (edge >= wp->window->sy - (status == 2 ? 1 : 0))
- edge = (status == 1 ? 1 : 0);
+ if (status == PANE_STATUS_TOP) {
+ if (edge >= w->sy)
+ edge = 1;
+ } else if (status == PANE_STATUS_BOTTOM) {
+ if (edge >= w->sy - 1)
+ edge = 0;
+ } else {
+ if (edge >= wp->sy)
+ edge = 0;
+ }
left = wp->xoff;
right = wp->xoff + wp->sx;
- TAILQ_FOREACH(next, &wp->window->panes, entry) {
+ TAILQ_FOREACH(next, &w->panes, entry) {
if (next == wp)
continue;
if (next->yoff != edge)
@@ -1382,24 +1402,26 @@ window_pane_find_down(struct window_pane *wp)
struct window_pane *
window_pane_find_left(struct window_pane *wp)
{
+ struct window *w;
struct window_pane *next, *best, **list;
u_int edge, top, bottom, end, size;
int found;
if (wp == NULL)
return (NULL);
+ w = wp->window;
list = NULL;
size = 0;
edge = wp->xoff;
if (edge == 0)
- edge = wp->window->sx + 1;
+ edge = w->sx + 1;
top = wp->yoff;
bottom = wp->yoff + wp->sy;
- TAILQ_FOREACH(next, &wp->window->panes, entry) {
+ TAILQ_FOREACH(next, &w->panes, entry) {
if (next == wp)
continue;
if (next->xoff + next->sx + 1 != edge)
@@ -1428,24 +1450,26 @@ window_pane_find_left(struct window_pane *wp)
struct window_pane *
window_pane_find_right(struct window_pane *wp)
{
+ struct window *w;
struct window_pane *next, *best, **list;
u_int edge, top, bottom, end, size;
int found;
if (wp == NULL)
return (NULL);
+ w = wp->window;
list = NULL;
size = 0;
edge = wp->xoff + wp->sx + 1;
- if (edge >= wp->window->sx)
+ if (edge >= w->sx)
edge = 0;
top = wp->yoff;
bottom = wp->yoff + wp->sy;
- TAILQ_FOREACH(next, &wp->window->panes, entry) {
+ TAILQ_FOREACH(next, &w->panes, entry) {
if (next == wp)
continue;
if (next->xoff != edge)