Add support for a single "marked pane". There is one marked pane in the

server at a time; it may be toggled or cleared with select-pane -m and
-M (the border is highlighted). A new target '~' or '{marked}' specifies
the marked pane to commands and it is the default target for the
swap-pane and join-pane -s flag (this makes them much simpler to use -
mark the source pane and then change to the target pane to run swapp or
joinp).
This commit is contained in:
nicm
2015-06-04 11:43:51 +00:00
parent a3edfd9e84
commit a863834574
11 changed files with 296 additions and 40 deletions

View File

@ -26,8 +26,8 @@ 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,
struct window_pane **);
int screen_redraw_check_active(u_int, u_int, int, struct window *,
struct window_pane *);
int screen_redraw_check_is(u_int, u_int, int, struct window *,
struct window_pane *, struct window_pane *);
void screen_redraw_draw_borders(struct client *, int, u_int);
void screen_redraw_draw_panes(struct client *, u_int);
@ -175,13 +175,13 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py,
return (CELL_OUTSIDE);
}
/* Check active pane indicator. */
/* Check if the border of a particular pane. */
int
screen_redraw_check_active(u_int px, u_int py, int type, struct window *w,
struct window_pane *wp)
screen_redraw_check_is(u_int px, u_int py, int type, struct window *w,
struct window_pane *wantwp, struct window_pane *wp)
{
/* Is this off the active pane border? */
if (screen_redraw_cell_border1(w->active, px, py) != 1)
if (screen_redraw_cell_border1(wantwp, px, py) != 1)
return (0);
/* If there are more than two panes, that's enough. */
@ -196,7 +196,7 @@ screen_redraw_check_active(u_int px, u_int py, int type, struct window *w,
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)
if (wp == wantwp)
return (px <= wp->sx / 2);
return (px > wp->sx / 2);
}
@ -207,7 +207,7 @@ screen_redraw_check_active(u_int px, u_int py, int type, struct window *w,
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)
if (wp == wantwp)
return (py <= wp->sy / 2);
return (py > wp->sy / 2);
}
@ -274,13 +274,15 @@ screen_redraw_pane(struct client *c, struct window_pane *wp)
void
screen_redraw_draw_borders(struct client *c, int status, u_int top)
{
struct window *w = c->session->curw->window;
struct session *s = c->session;
struct window *w = s->curw->window;
struct options *oo = &w->options;
struct tty *tty = &c->tty;
struct window_pane *wp;
struct grid_cell active_gc, other_gc, msg_gc;
struct grid_cell m_active_gc, active_gc, m_other_gc, other_gc;
struct grid_cell msg_gc;
u_int i, j, type, msgx = 0, msgy = 0;
int small, flags;
int active, small, flags;
char msg[256];
const char *tmp;
size_t msglen = 0;
@ -314,15 +316,29 @@ screen_redraw_draw_borders(struct client *c, int status, u_int top)
style_apply(&active_gc, oo, "pane-active-border-style");
active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET;
memcpy(&m_other_gc, &other_gc, sizeof m_other_gc);
m_other_gc.attr ^= GRID_ATTR_REVERSE;
memcpy(&m_active_gc, &active_gc, sizeof m_active_gc);
m_active_gc.attr ^= GRID_ATTR_REVERSE;
for (j = 0; j < tty->sy - status; j++) {
for (i = 0; i < tty->sx; i++) {
type = screen_redraw_check_cell(c, i, j, &wp);
if (type == CELL_INSIDE)
continue;
if (type == CELL_OUTSIDE &&
small && i > msgx && j == msgy)
if (type == CELL_OUTSIDE && small &&
i > msgx && j == msgy)
continue;
if (screen_redraw_check_active(i, j, type, w, wp))
active = screen_redraw_check_is(i, j, type, w,
w->active, wp);
if (server_is_marked(s, s->curw, marked_window_pane) &&
screen_redraw_check_is(i, j, type, w,
marked_window_pane, wp)) {
if (active)
tty_attributes(tty, &m_active_gc, NULL);
else
tty_attributes(tty, &m_other_gc, NULL);
} else if (active)
tty_attributes(tty, &active_gc, NULL);
else
tty_attributes(tty, &other_gc, NULL);