summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-06-26 13:03:48 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-06-26 13:03:48 +0000
commit065ad3e0793f02f37626774b5e89c534a6a32389 (patch)
treea75ece5c281cbcb6a148a602308ec9c8af8dd233 /usr.bin/tmux/window.c
parentf7d2daaffd87276289544946ef5af234ac63cada (diff)
Add #define for the pane status line option position numbers.
Diffstat (limited to 'usr.bin/tmux/window.c')
-rw-r--r--usr.bin/tmux/window.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 9c121374483..ab3aff0619f 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.236 2019/06/24 08:20:02 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.237 2019/06/26 13:03:47 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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)