=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.309 retrieving revision 1.310 diff -u -r1.309 -r1.310 --- src/usr.bin/tmux/tty.c 2018/10/18 08:38:01 1.309 +++ src/usr.bin/tmux/tty.c 2018/10/25 15:13:38 1.310 @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.309 2018/10/18 08:38:01 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.310 2018/10/25 15:13:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -851,7 +851,7 @@ if (wp != NULL) tty_default_colours(&gc, wp); - if (bg != 8 || gc.bg != 8) + if (!COLOUR_DEFAULT(bg) || !COLOUR_DEFAULT(gc.bg)) return (1); return (0); } @@ -1098,7 +1098,7 @@ * background colour isn't default (because it doesn't work * after SGR 0). */ - if (tty->term_type == TTY_VT420 && bg != 8) { + if (tty->term_type == TTY_VT420 && COLOUR_DEFAULT(bg)) { xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x", py + 1, px + 1, py + ny, px + nx); tty_puts(tty, tmp); @@ -2134,10 +2134,10 @@ */ if (!tty_term_has(tty->term, TTYC_SETAB)) { if (gc2.attr & GRID_ATTR_REVERSE) { - if (gc2.fg != 7 && gc2.fg != 8) + if (gc2.fg != 7 && !COLOUR_DEFAULT(gc2.fg)) gc2.attr &= ~GRID_ATTR_REVERSE; } else { - if (gc2.bg != 0 && gc2.bg != 8) + if (gc2.bg != 0 && !COLOUR_DEFAULT(gc2.bg)) gc2.attr |= GRID_ATTR_REVERSE; } } @@ -2212,7 +2212,7 @@ * case if only one is default need to fall onward to set the other * colour. */ - if (gc->fg == 8 || gc->bg == 8) { + if (COLOUR_DEFAULT(gc->fg) || COLOUR_DEFAULT(gc->bg)) { /* * If don't have AX but do have op, send sgr0 (op can't * actually be used because it is sometimes the same as sgr0 @@ -2224,32 +2224,32 @@ if (!have_ax && tty_term_has(tty->term, TTYC_OP)) tty_reset(tty); else { - if (gc->fg == 8 && tc->fg != 8) { + if (COLOUR_DEFAULT(gc->fg) && !COLOUR_DEFAULT(tc->fg)) { if (have_ax) tty_puts(tty, "\033[39m"); else if (tc->fg != 7) tty_putcode1(tty, TTYC_SETAF, 7); - tc->fg = 8; + tc->fg = gc->fg; } - if (gc->bg == 8 && tc->bg != 8) { + if (COLOUR_DEFAULT(gc->bg) && !COLOUR_DEFAULT(tc->bg)) { if (have_ax) tty_puts(tty, "\033[49m"); else if (tc->bg != 0) tty_putcode1(tty, TTYC_SETAB, 0); - tc->bg = 8; + tc->bg = gc->fg; } } } /* Set the foreground colour. */ - if (gc->fg != 8 && gc->fg != tc->fg) + if (!COLOUR_DEFAULT(gc->fg) && gc->fg != tc->fg) tty_colours_fg(tty, gc); /* * Set the background colour. This must come after the foreground as * tty_colour_fg() can call tty_reset(). */ - if (gc->bg != 8 && gc->bg != tc->bg) + if (!COLOUR_DEFAULT(gc->bg) && gc->bg != tc->bg) tty_colours_bg(tty, gc); } @@ -2515,9 +2515,11 @@ else gc->fg = wgc->fg; - if (gc->fg != 8 && - (c = window_pane_get_palette(wp, gc->fg)) != -1) - gc->fg = c; + if (gc->fg != 8) { + c = window_pane_get_palette(wp, gc->fg); + if (c != -1) + gc->fg = c; + } } if (gc->bg == 8) { @@ -2528,9 +2530,11 @@ else gc->bg = wgc->bg; - if (gc->bg != 8 && - (c = window_pane_get_palette(wp, gc->bg)) != -1) - gc->bg = c; + if (gc->bg != 8) { + c = window_pane_get_palette(wp, gc->bg); + if (c != -1) + gc->bg = c; + } } }