aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2019-06-26 15:02:26 +0100
committerThomas Adam <thomas@xteddy.org>2019-06-26 15:02:26 +0100
commitf797ac9ff6cd18b9f5737bea80fbf58dc5b5729b (patch)
tree4fc6be8865e689de13a93e944a5d182d37b7257d
parenta1d4bf20f774707c22249399dd89d1d6acf049ef (diff)
parentc599ad63f8857bd74e85150e60339fd2efbb9650 (diff)
downloadrtmux-f797ac9ff6cd18b9f5737bea80fbf58dc5b5729b.tar.gz
rtmux-f797ac9ff6cd18b9f5737bea80fbf58dc5b5729b.tar.bz2
rtmux-f797ac9ff6cd18b9f5737bea80fbf58dc5b5729b.zip
Merge branch 'obsd-master'
-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--tty.c6
-rw-r--r--window.c50
6 files changed, 74 insertions, 47 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 1ec0261d..ba7db3e1 100644
--- a/options-table.c
+++ b/options-table.c
@@ -688,7 +688,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 e7c9f663..95fa4f93 100644
--- a/tmux.h
+++ b/tmux.h
@@ -957,6 +957,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/tty.c b/tty.c
index 8d3b2858..1c0c88d4 100644
--- a/tty.c
+++ b/tty.c
@@ -1060,17 +1060,17 @@ tty_clamp_area(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
*y = ctx->yoff + py - ctx->oy;
*ry = ny;
} else if (yoff < ctx->oy && yoff + ny > ctx->oy + ctx->sy) {
- /* Both left and right not visible. */
+ /* Both top and bottom not visible. */
*j = ctx->oy;
*y = 0;
*ry = ctx->sy;
} else if (yoff < ctx->oy) {
- /* Left not visible. */
+ /* Top not visible. */
*j = ctx->oy - (ctx->yoff + py);
*y = 0;
*ry = ny - *j;
} else {
- /* Right not visible. */
+ /* Bottom not visible. */
*j = 0;
*y = (ctx->yoff + py) - ctx->oy;
*ry = ctx->sy - *y;
diff --git a/window.c b/window.c
index 33e21d4c..10f3ca7f 100644
--- a/window.c
+++ b/window.c
@@ -410,6 +410,7 @@ window_set_name(struct window *w, const char *new_name)
void
window_resize(struct window *w, u_int sx, u_int sy)
{
+ log_debug("%s: @%u resize %ux%u", __func__, w->id, sx, sy);
w->sx = sx;
w->sy = sy;
}
@@ -924,6 +925,7 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
wp->sx = sx;
wp->sy = sy;
+ log_debug("%s: %%%u resize %ux%u", __func__, wp->id, sx, sy);
screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL);
wme = TAILQ_FIRST(&wp->modes);
@@ -1289,25 +1291,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)
@@ -1336,25 +1348,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)
@@ -1383,24 +1405,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)
@@ -1429,24 +1453,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)