-/* $OpenBSD: options-table.c,v 1.155 2021/12/13 09:42:20 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.156 2022/02/01 14:46:41 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
static const char *options_table_pane_status_list[] = {
"off", "top", "bottom", NULL
};
+static const char *options_table_pane_border_indicators_list[] = {
+ "off", "colour", "arrows", "both", NULL
+};
static const char *options_table_pane_border_lines_list[] = {
"single", "double", "heavy", "simple", "number", NULL
};
.text = "Format of text in the pane status lines."
},
+ { .name = "pane-border-indicators",
+ .type = OPTIONS_TABLE_CHOICE,
+ .scope = OPTIONS_TABLE_WINDOW,
+ .choices = options_table_pane_border_indicators_list,
+ .default_num = PANE_BORDER_COLOUR,
+ .text = "Whether to indicate the active pane by colouring border or "
+ "displaying arrow markers."
+ },
+
{ .name = "pane-border-lines",
.type = OPTIONS_TABLE_CHOICE,
.scope = OPTIONS_TABLE_WINDOW,
-/* $OpenBSD: screen-redraw.c,v 1.92 2021/12/13 09:42:20 nicm Exp $ */
+/* $OpenBSD: screen-redraw.c,v 1.93 2022/02/01 14:46:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
#define START_ISOLATE "\342\201\246"
#define END_ISOLATE "\342\201\251"
+/* Border in relation to a pane. */
enum screen_redraw_border_type {
SCREEN_REDRAW_OUTSIDE,
SCREEN_REDRAW_INSIDE,
- SCREEN_REDRAW_BORDER
+ SCREEN_REDRAW_BORDER_LEFT,
+ SCREEN_REDRAW_BORDER_RIGHT,
+ SCREEN_REDRAW_BORDER_TOP,
+ SCREEN_REDRAW_BORDER_BOTTOM
};
+#define BORDER_MARKERS " +,.-"
/* Get cell border character. */
static void
screen_redraw_pane_border(struct window_pane *wp, u_int px, u_int py,
int pane_status)
{
- u_int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy;
+ struct options *oo = wp->window->options;
+ int split = 0;
+ u_int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy;
/* Inside pane. */
if (px >= wp->xoff && px < ex && py >= wp->yoff && py < ey)
return (SCREEN_REDRAW_INSIDE);
+ /* Get pane indicator. */
+ switch (options_get_number(oo, "pane-border-indicators")) {
+ case PANE_BORDER_COLOUR:
+ case PANE_BORDER_BOTH:
+ split = 1;
+ break;
+ }
+
/* Left/right borders. */
if (pane_status == PANE_STATUS_OFF) {
- if (screen_redraw_two_panes(wp->window, 0)) {
+ if (screen_redraw_two_panes(wp->window, 0) && split) {
if (wp->xoff == 0 && px == wp->sx && py <= wp->sy / 2)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_RIGHT);
if (wp->xoff != 0 &&
px == wp->xoff - 1 &&
py > wp->sy / 2)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_LEFT);
} else {
if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= ey) {
if (wp->xoff != 0 && px == wp->xoff - 1)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_LEFT);
if (px == ex)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_RIGHT);
}
}
} else {
if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= ey) {
if (wp->xoff != 0 && px == wp->xoff - 1)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_LEFT);
if (px == ex)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_RIGHT);
}
}
/* Top/bottom borders. */
if (pane_status == PANE_STATUS_OFF) {
- if (screen_redraw_two_panes(wp->window, 1)) {
+ if (screen_redraw_two_panes(wp->window, 1) && split) {
if (wp->yoff == 0 && py == wp->sy && px <= wp->sx / 2)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_BOTTOM);
if (wp->yoff != 0 &&
py == wp->yoff - 1 &&
px > wp->sx / 2)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_TOP);
} else {
if ((wp->xoff == 0 || px >= wp->xoff - 1) && px <= ex) {
if (wp->yoff != 0 && py == wp->yoff - 1)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_TOP);
if (py == ey)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_BOTTOM);
}
}
} else if (pane_status == PANE_STATUS_TOP) {
if ((wp->xoff == 0 || px >= wp->xoff - 1) && px <= ex) {
if (wp->yoff != 0 && py == wp->yoff - 1)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_TOP);
}
} else {
if ((wp->xoff == 0 || px >= wp->xoff - 1) && px <= ex) {
if (py == ey)
- return (SCREEN_REDRAW_BORDER);
+ return (SCREEN_REDRAW_BORDER_BOTTOM);
}
}
switch (screen_redraw_pane_border(wp, px, py, pane_status)) {
case SCREEN_REDRAW_INSIDE:
return (0);
- case SCREEN_REDRAW_BORDER:
- return (1);
case SCREEN_REDRAW_OUTSIDE:
break;
+ default:
+ return (1);
}
}
enum screen_redraw_border_type border;
border = screen_redraw_pane_border(wp, px, py, pane_status);
- if (border == SCREEN_REDRAW_BORDER)
+ if (border != SCREEN_REDRAW_INSIDE && border != SCREEN_REDRAW_OUTSIDE)
return (1);
return (0);
}
struct options *oo = w->options;
struct tty *tty = &c->tty;
struct format_tree *ft;
- struct window_pane *wp;
+ struct window_pane *wp, *active = server_client_get_pane(c);
struct grid_cell gc;
const struct grid_cell *tmp;
struct overlay_ranges r;
u_int cell_type, x = ctx->ox + i, y = ctx->oy + j;
+ int arrows = 0, border;
int pane_status = ctx->pane_status, isolates;
if (c->overlay_check != NULL) {
tty_cursor(tty, i, j);
if (isolates)
tty_puts(tty, END_ISOLATE);
+
+ switch (options_get_number(oo, "pane-border-indicators")) {
+ case PANE_BORDER_ARROWS:
+ case PANE_BORDER_BOTH:
+ arrows = 1;
+ break;
+ }
+
+ if (wp != NULL && arrows) {
+ border = screen_redraw_pane_border(active, x, y, pane_status);
+ if (((i == wp->xoff + 1 &&
+ (cell_type == CELL_LEFTRIGHT ||
+ (cell_type == CELL_TOPJOIN &&
+ border == SCREEN_REDRAW_BORDER_BOTTOM) ||
+ (cell_type == CELL_BOTTOMJOIN &&
+ border == SCREEN_REDRAW_BORDER_TOP))) ||
+ (j == wp->yoff + 1 &&
+ (cell_type == CELL_TOPBOTTOM ||
+ (cell_type == CELL_LEFTJOIN &&
+ border == SCREEN_REDRAW_BORDER_RIGHT) ||
+ (cell_type == CELL_RIGHTJOIN &&
+ border == SCREEN_REDRAW_BORDER_LEFT)))) &&
+ screen_redraw_check_is(x, y, pane_status, active))
+ utf8_set(&gc.data, BORDER_MARKERS[border]);
+ }
+
tty_cell(tty, &gc, &grid_default_cell, NULL);
if (isolates)
tty_puts(tty, START_ISOLATE);