When only two panes in a window, only draw half the separating line as

active.
pull/1/head
Nicholas Marriott 2013-03-25 11:41:49 +00:00
parent 0ef24f9912
commit 111d993e75
1 changed files with 53 additions and 4 deletions

View File

@ -24,7 +24,11 @@
int screen_redraw_cell_border1(struct window_pane *, u_int, u_int);
int screen_redraw_cell_border(struct client *, u_int, u_int);
int screen_redraw_check_cell(struct client *, u_int, u_int);
int screen_redraw_check_cell(struct client *, u_int, u_int,
struct window_pane **);
int screen_redraw_check_active(u_int, u_int, int, struct window *,
struct window_pane *);
void screen_redraw_draw_number(struct client *, struct window_pane *);
#define CELL_INSIDE 0
@ -93,7 +97,8 @@ screen_redraw_cell_border(struct client *c, u_int px, u_int py)
/* Check if cell inside a pane. */
int
screen_redraw_check_cell(struct client *c, u_int px, u_int py)
screen_redraw_check_cell(struct client *c, u_int px, u_int py,
struct window_pane **wpp)
{
struct window *w = c->session->curw->window;
struct window_pane *wp;
@ -105,6 +110,7 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py)
TAILQ_FOREACH(wp, &w->panes, entry) {
if (!window_pane_visible(wp))
continue;
*wpp = wp;
/* If outside the pane and its border, skip it. */
if ((wp->xoff != 0 && px < wp->xoff - 1) ||
@ -162,9 +168,52 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py)
}
}
*wpp = NULL;
return (CELL_OUTSIDE);
}
/* Check active pane indicator. */
int
screen_redraw_check_active(u_int px, u_int py, int type, struct window *w,
struct window_pane *wp)
{
/* Is this off the active pane border? */
if (screen_redraw_cell_border1(w->active, px, py) != 1)
return (0);
/* If there are more than two panes, that's enough. */
if (window_count_panes(w) != 2)
return (1);
/* Else if the cell is not a border cell, forget it. */
if (wp == NULL || (type == CELL_OUTSIDE || type == CELL_INSIDE))
return (1);
/* Check if the pane covers the whole width. */
if (wp->xoff == 0 && wp->sx == w->sx) {
/* This can either be the top pane or the bottom pane. */
if (wp->yoff == 0) { /* top pane */
if (wp == w->active)
return (px <= wp->sx / 2);
return (px > wp->sx / 2);
}
return (0);
}
/* Check if the pane covers the whole height. */
if (wp->yoff == 0 && wp->sy == w->sy) {
/* This can either be the left pane or the right pane. */
if (wp->xoff == 0) { /* left pane */
if (wp == w->active)
return (py <= wp->sy / 2);
return (py > wp->sy / 2);
}
return (0);
}
return (type);
}
/* Redraw entire screen. */
void
screen_redraw_screen(struct client *c, int status_only, int borders_only)
@ -223,10 +272,10 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
break;
}
for (i = 0; i < tty->sx; i++) {
type = screen_redraw_check_cell(c, i, j);
type = screen_redraw_check_cell(c, i, j, &wp);
if (type == CELL_INSIDE)
continue;
if (screen_redraw_cell_border1(w->active, i, j) == 1)
if (screen_redraw_check_active(i, j, type, w, wp))
tty_attributes(tty, &active_gc);
else
tty_attributes(tty, &other_gc);