Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2016-05-30 12:01:13 +01:00
commit c7a0f56c71
5 changed files with 91 additions and 39 deletions

View File

@ -200,6 +200,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
status_timer_start_all(); status_timer_start_all();
if (strcmp(oe->name, "monitor-silence") == 0) if (strcmp(oe->name, "monitor-silence") == 0)
alerts_reset_all(); alerts_reset_all();
if (strcmp(oe->name, "window-style") == 0 ||
strcmp(oe->name, "window-active-style") == 0) {
RB_FOREACH(w, windows, &windows)
w->flags |= WINDOW_STYLECHANGED;
}
/* When the pane-border-status option has been changed, resize panes. */ /* When the pane-border-status option has been changed, resize panes. */
if (strcmp(oe->name, "pane-border-status") == 0) { if (strcmp(oe->name, "pane-border-status") == 0) {

View File

@ -28,7 +28,8 @@ static void screen_write_initctx(struct screen_write_ctx *,
static void screen_write_save_last(struct screen_write_ctx *, static void screen_write_save_last(struct screen_write_ctx *,
struct tty_ctx *); struct tty_ctx *);
static void screen_write_overwrite(struct screen_write_ctx *, u_int); static int screen_write_overwrite(struct screen_write_ctx *,
struct grid_cell *, u_int);
static int screen_write_combine(struct screen_write_ctx *, static int screen_write_combine(struct screen_write_ctx *,
const struct utf8_data *); const struct utf8_data *);
@ -917,8 +918,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
struct grid *gd = s->grid; struct grid *gd = s->grid;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
u_int width, xx, last; u_int width, xx, last;
struct grid_cell tmp_gc; struct grid_cell tmp_gc, now_gc;
int insert; int insert, skip, selected;
/* Ignore padding. */ /* Ignore padding. */
if (gc->flags & GRID_FLAG_PADDING) if (gc->flags & GRID_FLAG_PADDING)
@ -947,9 +948,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
return; return;
} }
/* Initialise the redraw context, saving the last cell. */ /* Initialise the redraw context. */
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
screen_write_save_last(ctx, &ttyctx);
/* If in insert mode, make space for the cells. */ /* If in insert mode, make space for the cells. */
if ((s->mode & MODE_INSERT) && s->cx <= screen_size_x(s) - width) { if ((s->mode & MODE_INSERT) && s->cx <= screen_size_x(s) - width) {
@ -958,11 +958,13 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
insert = 1; insert = 1;
} else } else
insert = 0; insert = 0;
skip = !insert;
/* Check this will fit on the current line and wrap if not. */ /* Check this will fit on the current line and wrap if not. */
if ((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width) { if ((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width) {
screen_write_linefeed(ctx, 1); screen_write_linefeed(ctx, 1);
s->cx = 0; /* carriage return */ s->cx = 0; /* carriage return */
skip = 0;
} }
/* Sanity check cursor position. */ /* Sanity check cursor position. */
@ -970,16 +972,25 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
return; return;
/* Handle overwriting of UTF-8 characters. */ /* Handle overwriting of UTF-8 characters. */
screen_write_overwrite(ctx, width); grid_view_get_cell(gd, s->cx, s->cy, &now_gc);
if (screen_write_overwrite(ctx, &now_gc, width))
skip = 0;
/* /*
* If the new character is UTF-8 wide, fill in padding cells. Have * If the new character is UTF-8 wide, fill in padding cells. Have
* already ensured there is enough room. * already ensured there is enough room.
*/ */
for (xx = s->cx + 1; xx < s->cx + width; xx++) for (xx = s->cx + 1; xx < s->cx + width; xx++) {
grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell); grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell);
skip = 0;
}
/* If no change, do not draw. */
if (skip)
skip = (memcmp(&now_gc, gc, sizeof now_gc) == 0);
/* Set the cell. */ /* Set the cell. */
if (!skip)
grid_view_set_cell(gd, s->cx, s->cy, gc); grid_view_set_cell(gd, s->cx, s->cy, gc);
/* /*
@ -992,12 +1003,23 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
else else
s->cx = screen_size_x(s) - last; s->cx = screen_size_x(s) - last;
/* Draw to the screen if necessary. */ /* Create space for character in insert mode. */
if (insert) { if (insert) {
ttyctx.num = width; ttyctx.num = width;
tty_write(tty_cmd_insertcharacter, &ttyctx); tty_write(tty_cmd_insertcharacter, &ttyctx);
} }
if (screen_check_selection(s, s->cx - width, s->cy)) {
/* Check if this is selected. */
selected = screen_check_selection(s, s->cx - width, s->cy);
if (selected)
skip = 0;
/* Save last cell if it will be needed. */
if (!skip && ctx->wp != NULL && ttyctx.ocx > ctx->wp->sx - width)
screen_write_save_last(ctx, &ttyctx);
/* Write to the screen. */
if (selected) {
memcpy(&tmp_gc, &s->sel.cell, sizeof tmp_gc); memcpy(&tmp_gc, &s->sel.cell, sizeof tmp_gc);
utf8_copy(&tmp_gc.data, &gc->data); utf8_copy(&tmp_gc.data, &gc->data);
tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET; tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET;
@ -1009,7 +1031,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
(GRID_FLAG_FG256|GRID_FLAG_BG256); (GRID_FLAG_FG256|GRID_FLAG_BG256);
ttyctx.cell = &tmp_gc; ttyctx.cell = &tmp_gc;
tty_write(tty_cmd_cell, &ttyctx); tty_write(tty_cmd_cell, &ttyctx);
} else { } else if (!skip) {
ttyctx.cell = gc; ttyctx.cell = gc;
tty_write(tty_cmd_cell, &ttyctx); tty_write(tty_cmd_cell, &ttyctx);
} }
@ -1057,16 +1079,17 @@ screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud)
* character, it is necessary to also overwrite any other cells which covered * character, it is necessary to also overwrite any other cells which covered
* by the same character. * by the same character.
*/ */
static void static int
screen_write_overwrite(struct screen_write_ctx *ctx, u_int width) screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc,
u_int width)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid *gd = s->grid; struct grid *gd = s->grid;
struct grid_cell gc; struct grid_cell tmp_gc;
u_int xx; u_int xx;
int done = 0;
grid_view_get_cell(gd, s->cx, s->cy, &gc); if (gc->flags & GRID_FLAG_PADDING) {
if (gc.flags & GRID_FLAG_PADDING) {
/* /*
* A padding cell, so clear any following and leading padding * A padding cell, so clear any following and leading padding
* cells back to the character. Don't overwrite the current * cells back to the character. Don't overwrite the current
@ -1074,27 +1097,33 @@ screen_write_overwrite(struct screen_write_ctx *ctx, u_int width)
*/ */
xx = s->cx + 1; xx = s->cx + 1;
while (--xx > 0) { while (--xx > 0) {
grid_view_get_cell(gd, xx, s->cy, &gc); grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
if (~gc.flags & GRID_FLAG_PADDING) if (~tmp_gc.flags & GRID_FLAG_PADDING)
break; break;
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
} }
/* Overwrite the character at the start of this padding. */ /* Overwrite the character at the start of this padding. */
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
done = 1;
} }
/* /*
* Overwrite any padding cells that belong to a UTF-8 character * Overwrite any padding cells that belong to a UTF-8 character
* we'll be overwriting with the current character. * we'll be overwriting with the current character.
*/ */
if (gc->data.width != 1 || gc->flags & GRID_FLAG_PADDING) {
xx = s->cx + width - 1; xx = s->cx + width - 1;
while (++xx < screen_size_x(s)) { while (++xx < screen_size_x(s)) {
grid_view_get_cell(gd, xx, s->cy, &gc); grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
if (~gc.flags & GRID_FLAG_PADDING) if (~tmp_gc.flags & GRID_FLAG_PADDING)
break; break;
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
done = 1;
} }
}
return (done);
} }
void void

4
tmux.h
View File

@ -945,10 +945,14 @@ struct window {
#define WINDOW_ZOOMED 0x1000 #define WINDOW_ZOOMED 0x1000
#define WINDOW_FORCEWIDTH 0x2000 #define WINDOW_FORCEWIDTH 0x2000
#define WINDOW_FORCEHEIGHT 0x4000 #define WINDOW_FORCEHEIGHT 0x4000
#define WINDOW_STYLECHANGED 0x8000
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE) #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
struct options *options; struct options *options;
struct grid_cell style;
struct grid_cell active_style;
u_int references; u_int references;
RB_ENTRY(window) entry; RB_ENTRY(window) entry;

32
tty.c
View File

@ -676,6 +676,7 @@ tty_fake_bce(const struct tty *tty, const struct window_pane *wp)
struct grid_cell gc; struct grid_cell gc;
memcpy(&gc, &grid_default_cell, sizeof gc); memcpy(&gc, &grid_default_cell, sizeof gc);
if (wp != NULL)
tty_default_colours(&gc, wp); tty_default_colours(&gc, wp);
if (gc.bg == 8 && !(gc.flags & GRID_FLAG_BG256)) if (gc.bg == 8 && !(gc.flags & GRID_FLAG_BG256))
@ -1133,9 +1134,9 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
{ {
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int cx; u_int cx, width;
u_int width;
if (ctx->ocy == ctx->orlower)
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
/* Is the cursor in the very last position? */ /* Is the cursor in the very last position? */
@ -1373,6 +1374,11 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy)
tty_putcode1(tty, TTYC_HPA, cx); tty_putcode1(tty, TTYC_HPA, cx);
goto out; goto out;
} else if (change > 0 && tty_term_has(term, TTYC_CUB)) { } else if (change > 0 && tty_term_has(term, TTYC_CUB)) {
if (change == 2 && tty_term_has(term, TTYC_CUB1)) {
tty_putcode(tty, TTYC_CUB1);
tty_putcode(tty, TTYC_CUB1);
goto out;
}
tty_putcode1(tty, TTYC_CUB, change); tty_putcode1(tty, TTYC_CUB, change);
goto out; goto out;
} else if (change < 0 && tty_term_has(term, TTYC_CUF)) { } else if (change < 0 && tty_term_has(term, TTYC_CUF)) {
@ -1438,6 +1444,7 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
u_char changed; u_char changed;
memcpy(&gc2, gc, sizeof gc2); memcpy(&gc2, gc, sizeof gc2);
if (wp != NULL)
tty_default_colours(&gc2, wp); tty_default_colours(&gc2, wp);
/* /*
@ -1788,20 +1795,27 @@ tty_try_rgb(struct tty *tty, const struct grid_cell_rgb *rgb, const char *type)
void void
tty_default_colours(struct grid_cell *gc, const struct window_pane *wp) tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
{ {
struct window *w = wp->window;
struct options *oo = w->options;
const struct grid_cell *agc, *pgc, *wgc; const struct grid_cell *agc, *pgc, *wgc;
if (wp == NULL) if (w->flags & WINDOW_STYLECHANGED) {
return; w->flags &= ~WINDOW_STYLECHANGED;
agc = options_get_style(oo, "window-active-style");
memcpy(&w->active_style, agc, sizeof w->active_style);
wgc = options_get_style(oo, "window-style");
memcpy(&w->style, wgc, sizeof w->style);
} else {
agc = &w->active_style;
wgc = &w->style;
}
pgc = &wp->colgc; pgc = &wp->colgc;
agc = options_get_style(wp->window->options, "window-active-style");
wgc = options_get_style(wp->window->options, "window-style");
if (gc->fg == 8 && !(gc->flags & GRID_FLAG_FG256)) { if (gc->fg == 8 && !(gc->flags & GRID_FLAG_FG256)) {
if (pgc->fg != 8 || (pgc->flags & GRID_FLAG_FG256)) { if (pgc->fg != 8 || (pgc->flags & GRID_FLAG_FG256)) {
gc->fg = pgc->fg; gc->fg = pgc->fg;
gc->flags |= (pgc->flags & GRID_FLAG_FG256); gc->flags |= (pgc->flags & GRID_FLAG_FG256);
} else if (wp == wp->window->active && } else if (wp == w->active &&
(agc->fg != 8 || (agc->flags & GRID_FLAG_FG256))) { (agc->fg != 8 || (agc->flags & GRID_FLAG_FG256))) {
gc->fg = agc->fg; gc->fg = agc->fg;
gc->flags |= (agc->flags & GRID_FLAG_FG256); gc->flags |= (agc->flags & GRID_FLAG_FG256);
@ -1815,7 +1829,7 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
if (pgc->bg != 8 || (pgc->flags & GRID_FLAG_BG256)) { if (pgc->bg != 8 || (pgc->flags & GRID_FLAG_BG256)) {
gc->bg = pgc->bg; gc->bg = pgc->bg;
gc->flags |= (pgc->flags & GRID_FLAG_BG256); gc->flags |= (pgc->flags & GRID_FLAG_BG256);
} else if (wp == wp->window->active && } else if (wp == w->active &&
(agc->bg != 8 || (agc->flags & GRID_FLAG_BG256))) { (agc->bg != 8 || (agc->flags & GRID_FLAG_BG256))) {
gc->bg = agc->bg; gc->bg = agc->bg;
gc->flags |= (agc->flags & GRID_FLAG_BG256); gc->flags |= (agc->flags & GRID_FLAG_BG256);

View File

@ -291,7 +291,7 @@ window_create1(u_int sx, u_int sy)
w = xcalloc(1, sizeof *w); w = xcalloc(1, sizeof *w);
w->name = NULL; w->name = NULL;
w->flags = 0; w->flags = WINDOW_STYLECHANGED;
TAILQ_INIT(&w->panes); TAILQ_INIT(&w->panes);
w->active = NULL; w->active = NULL;