diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-25 11:41:50 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-25 11:41:50 +0000 |
commit | 94dba0ba8ecf815161c9576287d715a917f0161b (patch) | |
tree | 65ed80f3751004792f7dd7df3ef4455eaefb13ca /usr.bin/tmux | |
parent | c7d33c821d4dae98c7df5754abf79f8297bbff9f (diff) |
When only two panes in a window, only draw half the separating line as
active.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index d917b132e1f..cb6583cae92 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.23 2013/03/25 10:12:01 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.24 2013/03/25 11:41:49 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); |