Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2018-08-17 11:20:20 +01:00
commit 98a3c98c28
3 changed files with 170 additions and 135 deletions

View File

@ -2235,7 +2235,7 @@ bad:
free(copy);
}
/* Handle the OSC 10 sequence for setting background colour. */
/* Handle the OSC 10 sequence for setting foreground colour. */
static void
input_osc_10(struct window_pane *wp, const char *p)
{

View File

@ -23,6 +23,18 @@
#include "tmux.h"
struct screen_redraw_ctx {
struct client *c;
u_int lines;
int top;
int pane_status;
u_int sx;
u_int sy;
};
static int screen_redraw_cell_border1(struct window_pane *, u_int, u_int);
static int screen_redraw_cell_border(struct client *, u_int, u_int);
static int screen_redraw_check_cell(struct client *, u_int, u_int, int,
@ -34,11 +46,11 @@ static int screen_redraw_make_pane_status(struct client *, struct window *,
struct window_pane *);
static void screen_redraw_draw_pane_status(struct client *, int);
static void screen_redraw_draw_borders(struct client *, int, u_int, u_int);
static void screen_redraw_draw_panes(struct client *, u_int, u_int);
static void screen_redraw_draw_status(struct client *, u_int, u_int);
static void screen_redraw_draw_number(struct client *, struct window_pane *,
u_int, u_int);
static void screen_redraw_draw_borders(struct screen_redraw_ctx *);
static void screen_redraw_draw_panes(struct screen_redraw_ctx *);
static void screen_redraw_draw_status(struct screen_redraw_ctx *);
static void screen_redraw_draw_number(struct screen_redraw_ctx *,
struct window_pane *);
#define CELL_INSIDE 0
#define CELL_LEFTRIGHT 1
@ -375,42 +387,44 @@ void
screen_redraw_screen(struct client *c, int draw_panes, int draw_status,
int draw_borders)
{
struct options *oo = c->session->options;
struct tty *tty = &c->tty;
struct window *w = c->session->curw->window;
struct options *wo = w->options;
u_int top, lines;
int position, pane_status;
struct options *oo = c->session->options;
struct tty *tty = &c->tty;
struct window *w = c->session->curw->window;
struct options *wo = w->options;
struct screen_redraw_ctx ctx;
if (c->flags & CLIENT_SUSPENDED)
return;
memset(&ctx, 0, sizeof ctx);
ctx.c = c;
if (c->flags & CLIENT_STATUSOFF)
lines = 0;
ctx.lines = 0;
else
lines = status_line_size(c->session);
ctx.lines = status_line_size(c->session);
if (c->message_string != NULL || c->prompt_string != NULL)
lines = (lines == 0) ? 1 : lines;
ctx.lines = (ctx.lines == 0) ? 1 : ctx.lines;
position = options_get_number(oo, "status-position");
if (lines != 0 && position == 0)
top = 1;
else
top = 0;
if (ctx.lines != 0 && options_get_number(oo, "status-position") == 0)
ctx.top = 1;
ctx.pane_status = options_get_number(wo, "pane-border-status");
if (lines == 0)
ctx.sx = tty->sx;
ctx.sy = tty->sy - ctx.lines;
if (ctx.lines == 0)
draw_status = 0;
if (draw_borders) {
pane_status = options_get_number(wo, "pane-border-status");
screen_redraw_draw_borders(c, pane_status, lines, top);
if (pane_status != CELL_STATUS_OFF)
screen_redraw_draw_pane_status(c, pane_status);
if (ctx.pane_status != CELL_STATUS_OFF)
screen_redraw_draw_pane_status(c, ctx.pane_status);
screen_redraw_draw_borders(&ctx);
}
if (draw_panes)
screen_redraw_draw_panes(c, lines, top);
screen_redraw_draw_panes(&ctx);
if (draw_status)
screen_redraw_draw_status(c, lines, top);
screen_redraw_draw_status(&ctx);
tty_reset(tty);
}
@ -435,25 +449,65 @@ screen_redraw_pane(struct client *c, struct window_pane *wp)
tty_reset(&c->tty);
}
/* Draw a border cell. */
static void
screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int x, u_int y,
int small, u_int msgx, u_int msgy, struct grid_cell *m_active_gc,
struct grid_cell *active_gc, struct grid_cell *m_other_gc,
struct grid_cell *other_gc)
{
struct client *c = ctx->c;
struct session *s = c->session;
struct window *w = s->curw->window;
struct tty *tty = &c->tty;
struct window_pane *wp;
struct window_pane *active = w->active;
struct window_pane *marked = marked_pane.wp;
u_int type;
int flag, pane_status = ctx->pane_status;
type = screen_redraw_check_cell(c, x, y, pane_status, &wp);
if (type == CELL_INSIDE)
return;
if (type == CELL_OUTSIDE && small && x > msgx && y == msgy)
return;
flag = screen_redraw_check_is(x, y, type, pane_status, w, active, wp);
if (server_is_marked(s, s->curw, marked_pane.wp) &&
screen_redraw_check_is(x, y, type, pane_status, w, marked, wp)) {
if (flag)
tty_attributes(tty, m_active_gc, NULL);
else
tty_attributes(tty, m_other_gc, NULL);
} else if (flag)
tty_attributes(tty, active_gc, NULL);
else
tty_attributes(tty, other_gc, NULL);
if (ctx->top)
tty_cursor(tty, x, ctx->lines + y);
else
tty_cursor(tty, x, y);
tty_putc(tty, CELL_BORDERS[type]);
}
/* Draw the borders. */
static void
screen_redraw_draw_borders(struct client *c, int pane_status, u_int lines,
u_int top)
screen_redraw_draw_borders(struct screen_redraw_ctx *ctx)
{
struct client *c = ctx->c;
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 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 active, small, flags;
u_int i, j, msgx = 0, msgy = 0;
int small, flags;
char msg[256];
const char *tmp;
size_t msglen = 0;
small = (tty->sy - lines + top > w->sy) || (tty->sx > w->sx);
small = (ctx->sy + ctx->top > w->sy) || (ctx->sx > w->sx);
if (small) {
flags = w->flags & (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT);
if (flags == (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT))
@ -470,12 +524,12 @@ screen_redraw_draw_borders(struct client *c, int pane_status, u_int lines,
w->sx, w->sy, tmp);
msglen = strlen(msg);
if (tty->sy - 1 - lines + top > w->sy && tty->sx >= msglen) {
msgx = tty->sx - msglen;
msgy = tty->sy - 1 - lines + top;
} else if (tty->sx - w->sx > msglen) {
msgx = tty->sx - msglen;
msgy = tty->sy - 1 - lines + top;
if (ctx->sy - 1 + ctx->top > w->sy && ctx->sx >= msglen) {
msgx = ctx->sx - msglen;
msgy = ctx->sy - 1 + ctx->top;
} else if (ctx->sx - w->sx > msglen) {
msgx = ctx->sx - msglen;
msgy = ctx->sy - 1 + ctx->top;
} else
small = 0;
}
@ -489,33 +543,11 @@ screen_redraw_draw_borders(struct client *c, int pane_status, u_int lines,
memcpy(&m_active_gc, &active_gc, sizeof m_active_gc);
m_active_gc.attr ^= GRID_ATTR_REVERSE;
for (j = 0; j < tty->sy - lines; j++) {
for (i = 0; i < tty->sx; i++) {
type = screen_redraw_check_cell(c, i, j, pane_status,
&wp);
if (type == CELL_INSIDE)
continue;
if (type == CELL_OUTSIDE && small &&
i > msgx && j == msgy)
continue;
active = screen_redraw_check_is(i, j, type, pane_status,
w, w->active, wp);
if (server_is_marked(s, s->curw, marked_pane.wp) &&
screen_redraw_check_is(i, j, type, pane_status, w,
marked_pane.wp, 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);
if (top)
tty_cursor(tty, i, lines + j);
else
tty_cursor(tty, i, j);
tty_putc(tty, CELL_BORDERS[type]);
for (j = 0; j < ctx->sy; j++) {
for (i = 0; i < ctx->sx; i++) {
screen_redraw_draw_borders_cell(ctx, i, j, small,
msgx, msgy, &m_active_gc, &active_gc, &m_other_gc,
&other_gc);
}
}
@ -529,48 +561,49 @@ screen_redraw_draw_borders(struct client *c, int pane_status, u_int lines,
/* Draw the panes. */
static void
screen_redraw_draw_panes(struct client *c, u_int lines, u_int top)
screen_redraw_draw_panes(struct screen_redraw_ctx *ctx)
{
struct client *c = ctx->c;
struct window *w = c->session->curw->window;
struct tty *tty = &c->tty;
struct window_pane *wp;
u_int i, y;
if (top)
y = lines;
if (ctx->top)
y = ctx->lines;
else
y = 0;
TAILQ_FOREACH(wp, &w->panes, entry) {
if (!window_pane_visible(wp))
continue;
for (i = 0; i < wp->sy; i++)
tty_draw_pane(tty, wp, i, wp->xoff, y + wp->yoff);
if (c->flags & CLIENT_IDENTIFY)
screen_redraw_draw_number(c, wp, lines, top);
screen_redraw_draw_number(ctx, wp);
}
}
/* Draw the status line. */
static void
screen_redraw_draw_status(struct client *c, u_int lines, u_int top)
screen_redraw_draw_status(struct screen_redraw_ctx *ctx)
{
struct client *c = ctx->c;
struct tty *tty = &c->tty;
u_int i, y;
if (top)
if (ctx->top)
y = 0;
else
y = tty->sy - lines;
for (i = 0; i < lines; i++)
y = ctx->sy;
for (i = 0; i < ctx->lines; i++)
tty_draw_line(tty, NULL, &c->status.status, i, 0, y);
}
/* Draw number on a pane. */
static void
screen_redraw_draw_number(struct client *c, struct window_pane *wp,
u_int lines, u_int top)
screen_redraw_draw_number(struct screen_redraw_ctx *ctx, struct window_pane *wp)
{
struct client *c = ctx->c;
struct tty *tty = &c->tty;
struct session *s = c->session;
struct options *oo = s->options;
@ -593,8 +626,8 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp,
px = wp->sx / 2; py = wp->sy / 2;
xoff = wp->xoff; yoff = wp->yoff;
if (top)
yoff += lines;
if (ctx->top)
yoff += ctx->lines;
if (wp->sx < len * 6 || wp->sy < 5) {
tty_cursor(tty, xoff + px - len / 2, yoff + py);

View File

@ -171,7 +171,12 @@ static const struct tty_default_key_raw tty_default_raw_keys[] = {
{ "\033[201~", KEYC_PASTE_END },
};
/* Default terminfo(5) keys. */
/*
* Default terminfo(5) keys. Any keys that have builtin modifiers
* (that is, where the key itself contains the modifiers) has the
* KEYC_XTERM flag set so a leading escape is not treated as meta (and
* probably removed).
*/
struct tty_default_key_code {
enum tty_code_code code;
key_code key;
@ -191,61 +196,61 @@ static const struct tty_default_key_code tty_default_code_keys[] = {
{ TTYC_KF11, KEYC_F11 },
{ TTYC_KF12, KEYC_F12 },
{ TTYC_KF13, KEYC_F1|KEYC_SHIFT },
{ TTYC_KF14, KEYC_F2|KEYC_SHIFT },
{ TTYC_KF15, KEYC_F3|KEYC_SHIFT },
{ TTYC_KF16, KEYC_F4|KEYC_SHIFT },
{ TTYC_KF17, KEYC_F5|KEYC_SHIFT },
{ TTYC_KF18, KEYC_F6|KEYC_SHIFT },
{ TTYC_KF19, KEYC_F7|KEYC_SHIFT },
{ TTYC_KF20, KEYC_F8|KEYC_SHIFT },
{ TTYC_KF21, KEYC_F9|KEYC_SHIFT },
{ TTYC_KF22, KEYC_F10|KEYC_SHIFT },
{ TTYC_KF23, KEYC_F11|KEYC_SHIFT },
{ TTYC_KF24, KEYC_F12|KEYC_SHIFT },
{ TTYC_KF13, KEYC_F1|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF14, KEYC_F2|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF15, KEYC_F3|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF16, KEYC_F4|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF17, KEYC_F5|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF18, KEYC_F6|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF19, KEYC_F7|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF20, KEYC_F8|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF21, KEYC_F9|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF22, KEYC_F10|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF23, KEYC_F11|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF24, KEYC_F12|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF25, KEYC_F1|KEYC_CTRL },
{ TTYC_KF26, KEYC_F2|KEYC_CTRL },
{ TTYC_KF27, KEYC_F3|KEYC_CTRL },
{ TTYC_KF28, KEYC_F4|KEYC_CTRL },
{ TTYC_KF29, KEYC_F5|KEYC_CTRL },
{ TTYC_KF30, KEYC_F6|KEYC_CTRL },
{ TTYC_KF31, KEYC_F7|KEYC_CTRL },
{ TTYC_KF32, KEYC_F8|KEYC_CTRL },
{ TTYC_KF33, KEYC_F9|KEYC_CTRL },
{ TTYC_KF34, KEYC_F10|KEYC_CTRL },
{ TTYC_KF35, KEYC_F11|KEYC_CTRL },
{ TTYC_KF36, KEYC_F12|KEYC_CTRL },
{ TTYC_KF25, KEYC_F1|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF26, KEYC_F2|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF27, KEYC_F3|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF28, KEYC_F4|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF29, KEYC_F5|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF30, KEYC_F6|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF31, KEYC_F7|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF32, KEYC_F8|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF33, KEYC_F9|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF34, KEYC_F10|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF35, KEYC_F11|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF36, KEYC_F12|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF37, KEYC_F1|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF38, KEYC_F2|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF39, KEYC_F3|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF40, KEYC_F4|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF41, KEYC_F5|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF42, KEYC_F6|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF43, KEYC_F7|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF44, KEYC_F8|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF45, KEYC_F9|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF46, KEYC_F10|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF47, KEYC_F11|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF48, KEYC_F12|KEYC_SHIFT|KEYC_CTRL },
{ TTYC_KF37, KEYC_F1|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF38, KEYC_F2|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF39, KEYC_F3|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF40, KEYC_F4|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF41, KEYC_F5|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF42, KEYC_F6|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF43, KEYC_F7|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF44, KEYC_F8|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF45, KEYC_F9|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF46, KEYC_F10|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF47, KEYC_F11|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF48, KEYC_F12|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM },
{ TTYC_KF49, KEYC_F1|KEYC_ESCAPE },
{ TTYC_KF50, KEYC_F2|KEYC_ESCAPE },
{ TTYC_KF51, KEYC_F3|KEYC_ESCAPE },
{ TTYC_KF52, KEYC_F4|KEYC_ESCAPE },
{ TTYC_KF53, KEYC_F5|KEYC_ESCAPE },
{ TTYC_KF54, KEYC_F6|KEYC_ESCAPE },
{ TTYC_KF55, KEYC_F7|KEYC_ESCAPE },
{ TTYC_KF56, KEYC_F8|KEYC_ESCAPE },
{ TTYC_KF57, KEYC_F9|KEYC_ESCAPE },
{ TTYC_KF58, KEYC_F10|KEYC_ESCAPE },
{ TTYC_KF59, KEYC_F11|KEYC_ESCAPE },
{ TTYC_KF60, KEYC_F12|KEYC_ESCAPE },
{ TTYC_KF49, KEYC_F1|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF50, KEYC_F2|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF51, KEYC_F3|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF52, KEYC_F4|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF53, KEYC_F5|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF54, KEYC_F6|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF55, KEYC_F7|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF56, KEYC_F8|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF57, KEYC_F9|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF58, KEYC_F10|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF59, KEYC_F11|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF60, KEYC_F12|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KF61, KEYC_F1|KEYC_ESCAPE|KEYC_SHIFT },
{ TTYC_KF62, KEYC_F2|KEYC_ESCAPE|KEYC_SHIFT },
{ TTYC_KF63, KEYC_F3|KEYC_ESCAPE|KEYC_SHIFT },
{ TTYC_KF61, KEYC_F1|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF62, KEYC_F2|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KF63, KEYC_F3|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KICH1, KEYC_IC },
{ TTYC_KDCH1, KEYC_DC },
@ -261,10 +266,7 @@ static const struct tty_default_key_code tty_default_code_keys[] = {
{ TTYC_KCUB1, KEYC_LEFT },
{ TTYC_KCUF1, KEYC_RIGHT },
/*
* Key and modifier capabilities. We set the xterm flag to mark that
* any leading escape means an escape key press and not the modifier.
*/
/* Key and modifier capabilities. */
{ TTYC_KDC2, KEYC_DC|KEYC_SHIFT|KEYC_XTERM },
{ TTYC_KDC3, KEYC_DC|KEYC_ESCAPE|KEYC_XTERM },
{ TTYC_KDC4, KEYC_DC|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM },