Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2017-01-12 02:01:11 +00:00
commit 4a76861925
4 changed files with 53 additions and 24 deletions

View File

@ -1049,7 +1049,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
width = gc->data.width; width = gc->data.width;
/* /*
* If this is a wide character and there is no room on the screen, for * If this is a wide character and there is no room on the screen for
* the entire character, don't print it. * the entire character, don't print it.
*/ */
if (!(s->mode & MODE_WRAP) && (width > 1 && if (!(s->mode & MODE_WRAP) && (width > 1 &&

6
tmux.h
View File

@ -862,11 +862,6 @@ struct window_pane {
TAILQ_HEAD(window_panes, window_pane); TAILQ_HEAD(window_panes, window_pane);
RB_HEAD(window_pane_tree, window_pane); RB_HEAD(window_pane_tree, window_pane);
#define WINDOW_PANE_PALETTE_HAS(wp, c) \
((wp) != NULL && (wp)->palette != NULL && \
((c) < 0x100 || (c) & COLOUR_FLAG_256) && \
(wp)->palette[(c) & 0xff] != 0)
/* Window structure. */ /* Window structure. */
struct window { struct window {
u_int id; u_int id;
@ -2159,6 +2154,7 @@ void window_set_name(struct window *, const char *);
void window_remove_ref(struct window *); void window_remove_ref(struct window *);
void winlink_clear_flags(struct winlink *); void winlink_clear_flags(struct winlink *);
int winlink_shuffle_up(struct session *, struct winlink *); int winlink_shuffle_up(struct session *, struct winlink *);
int window_pane_get_palette(const struct window_pane *, int);
/* layout.c */ /* layout.c */
u_int layout_count_cells(struct layout_cell *); u_int layout_count_cells(struct layout_cell *);

37
tty.c
View File

@ -1609,11 +1609,12 @@ tty_check_fg(struct tty *tty, const struct window_pane *wp,
{ {
u_char r, g, b; u_char r, g, b;
u_int colours; u_int colours;
int c;
/* Perform substitution if this pane has a palette */ /* Perform substitution if this pane has a palette */
if ((~gc->flags & GRID_FLAG_NOPALETTE) && if ((~gc->flags & GRID_FLAG_NOPALETTE) &&
gc->fg != 8 && WINDOW_PANE_PALETTE_HAS(wp, gc->fg)) (c = window_pane_get_palette(wp, gc->fg)) != -1)
gc->fg = wp->palette[gc->fg & 0xff]; gc->fg = c;
/* Is this a 24-bit colour? */ /* Is this a 24-bit colour? */
if (gc->fg & COLOUR_FLAG_RGB) { if (gc->fg & COLOUR_FLAG_RGB) {
@ -1624,13 +1625,17 @@ tty_check_fg(struct tty *tty, const struct window_pane *wp,
} else } else
return; return;
} }
/* How many colours does this terminal have? */
if ((tty->term->flags|tty->term_flags) & TERM_256COLOURS)
colours = 256;
else
colours = tty_term_number(tty->term, TTYC_COLORS); colours = tty_term_number(tty->term, TTYC_COLORS);
/* Is this a 256-colour colour? */ /* Is this a 256-colour colour? */
if (gc->fg & COLOUR_FLAG_256) { if (gc->fg & COLOUR_FLAG_256) {
/* And not a 256 colour mode? */ /* And not a 256 colour mode? */
if (!(tty->term->flags & TERM_256COLOURS) && if (colours != 256) {
!(tty->term_flags & TERM_256COLOURS)) {
gc->fg = colour_256to16(gc->fg); gc->fg = colour_256to16(gc->fg);
if (gc->fg & 8) { if (gc->fg & 8) {
gc->fg &= 7; gc->fg &= 7;
@ -1657,11 +1662,12 @@ tty_check_bg(struct tty *tty, const struct window_pane *wp,
{ {
u_char r, g, b; u_char r, g, b;
u_int colours; u_int colours;
int c;
/* Perform substitution if this pane has a palette */ /* Perform substitution if this pane has a palette */
if ((~gc->flags & GRID_FLAG_NOPALETTE) && if ((~gc->flags & GRID_FLAG_NOPALETTE) &&
gc->bg != 8 && WINDOW_PANE_PALETTE_HAS(wp, gc->bg)) (c = window_pane_get_palette(wp, gc->bg)) != -1)
gc->bg = wp->palette[gc->bg & 0xff]; gc->bg = c;
/* Is this a 24-bit colour? */ /* Is this a 24-bit colour? */
if (gc->bg & COLOUR_FLAG_RGB) { if (gc->bg & COLOUR_FLAG_RGB) {
@ -1672,6 +1678,11 @@ tty_check_bg(struct tty *tty, const struct window_pane *wp,
} else } else
return; return;
} }
/* How many colours does this terminal have? */
if ((tty->term->flags|tty->term_flags) & TERM_256COLOURS)
colours = 256;
else
colours = tty_term_number(tty->term, TTYC_COLORS); colours = tty_term_number(tty->term, TTYC_COLORS);
/* Is this a 256-colour colour? */ /* Is this a 256-colour colour? */
@ -1681,8 +1692,7 @@ tty_check_bg(struct tty *tty, const struct window_pane *wp,
* palette. Bold background doesn't exist portably, so just * palette. Bold background doesn't exist portably, so just
* discard the bold bit if set. * discard the bold bit if set.
*/ */
if (!(tty->term->flags & TERM_256COLOURS) && if (colours != 256) {
!(tty->term_flags & TERM_256COLOURS)) {
gc->bg = colour_256to16(gc->bg); gc->bg = colour_256to16(gc->bg);
if (gc->bg & 8) { if (gc->bg & 8) {
gc->bg &= 7; gc->bg &= 7;
@ -1817,6 +1827,7 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
struct window *w = wp->window; struct window *w = wp->window;
struct options *oo = w->options; struct options *oo = w->options;
const struct grid_cell *agc, *pgc, *wgc; const struct grid_cell *agc, *pgc, *wgc;
int c;
if (w->flags & WINDOW_STYLECHANGED) { if (w->flags & WINDOW_STYLECHANGED) {
w->flags &= ~WINDOW_STYLECHANGED; w->flags &= ~WINDOW_STYLECHANGED;
@ -1838,8 +1849,9 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
else else
gc->fg = wgc->fg; gc->fg = wgc->fg;
if (gc->fg != 8 && WINDOW_PANE_PALETTE_HAS(wp, gc->fg)) if (gc->fg != 8 &&
gc->fg = wp->palette[gc->fg & 0xff]; (c = window_pane_get_palette(wp, gc->fg)) != -1)
gc->fg = c;
} }
if (gc->bg == 8) { if (gc->bg == 8) {
@ -1850,8 +1862,9 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
else else
gc->bg = wgc->bg; gc->bg = wgc->bg;
if (gc->bg != 8 && WINDOW_PANE_PALETTE_HAS(wp, gc->bg)) if (gc->bg != 8 &&
gc->bg = wp->palette[gc->bg & 0xff]; (c = window_pane_get_palette(wp, gc->bg)) != -1)
gc->bg = c;
} }
} }

View File

@ -464,12 +464,12 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
* If the now active or inactive pane do not have a custom style or if * If the now active or inactive pane do not have a custom style or if
* the palette is different, they need to be redrawn. * the palette is different, they need to be redrawn.
*/ */
if (WINDOW_PANE_PALETTE_HAS(w->active, w->active->colgc.fg) || if (window_pane_get_palette(w->active, w->active->colgc.fg) != -1 ||
WINDOW_PANE_PALETTE_HAS(w->active, w->active->colgc.bg) || window_pane_get_palette(w->active, w->active->colgc.bg) != -1 ||
style_equal(&grid_default_cell, &w->active->colgc)) style_equal(&grid_default_cell, &w->active->colgc))
w->active->flags |= PANE_REDRAW; w->active->flags |= PANE_REDRAW;
if (WINDOW_PANE_PALETTE_HAS(wp, wp->colgc.fg) || if (window_pane_get_palette(wp, wp->colgc.fg) != -1 ||
WINDOW_PANE_PALETTE_HAS(wp, wp->colgc.bg) || window_pane_get_palette(wp, wp->colgc.bg) != -1 ||
style_equal(&grid_default_cell, &wp->colgc)) style_equal(&grid_default_cell, &wp->colgc))
wp->flags |= PANE_REDRAW; wp->flags |= PANE_REDRAW;
} }
@ -1532,3 +1532,23 @@ winlink_shuffle_up(struct session *s, struct winlink *wl)
return (idx); return (idx);
} }
int
window_pane_get_palette(const struct window_pane *wp, int c)
{
int new;
if (wp == NULL || wp->palette == NULL)
return (-1);
new = -1;
if (c < 8)
new = wp->palette[c];
else if (c >= 90 && c <= 97)
new = wp->palette[8 + c - 90];
else if (c & COLOUR_FLAG_256)
new = wp->palette[c & ~COLOUR_FLAG_256];
if (new == 0)
return (-1);
return (new);
}