=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.63 retrieving revision 1.64 diff -c -r1.63 -r1.64 *** src/usr.bin/tmux/tty.c 2009/10/28 08:52:36 1.63 --- src/usr.bin/tmux/tty.c 2009/11/04 13:34:26 1.64 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.63 2009/10/28 08:52:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.64 2009/11/04 13:34:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 1121,1127 **** { struct grid_cell *tc = &tty->cell, gc2; u_char changed; ! u_int fg = gc->fg, bg = gc->bg, attr = gc->attr; /* If the character is space, don't care about foreground. */ if (gc->data == ' ' && !(gc->flags & GRID_FLAG_UTF8)) { --- 1121,1127 ---- { struct grid_cell *tc = &tty->cell, gc2; u_char changed; ! u_int new_attr; /* If the character is space, don't care about foreground. */ if (gc->data == ' ' && !(gc->flags & GRID_FLAG_UTF8)) { *************** *** 1137,1170 **** gc = &gc2; } - /* If any bits are being cleared, reset everything. */ - if (tc->attr & ~attr) - tty_reset(tty); - /* - * Set the colours. This may call tty_reset() (so it comes next) and - * may add to the desired attributes in attr. - */ - tty_colours(tty, gc, &attr); - - /* * If no setab, try to use the reverse attribute as a best-effort for a * non-default background. This is a bit of a hack but it doesn't do * any serious harm and makes a couple of applications happier. */ if (!tty_term_has(tty->term, TTYC_SETAB)) { ! if (attr & GRID_ATTR_REVERSE) { ! if (fg != 7 && fg != 8) ! attr &= ~GRID_ATTR_REVERSE; } else { ! if (bg != 0 && bg != 8) ! attr |= GRID_ATTR_REVERSE; } } /* Filter out attribute bits already set. */ ! changed = attr & ~tc->attr; ! tc->attr = attr; /* Set the attributes. */ if (changed & GRID_ATTR_BRIGHT) --- 1137,1176 ---- gc = &gc2; } /* * If no setab, try to use the reverse attribute as a best-effort for a * non-default background. This is a bit of a hack but it doesn't do * any serious harm and makes a couple of applications happier. */ if (!tty_term_has(tty->term, TTYC_SETAB)) { ! if (gc != &gc2) { ! memcpy(&gc2, gc, sizeof gc2); ! gc = &gc2; ! } ! ! if (gc->attr & GRID_ATTR_REVERSE) { ! if (gc->fg != 7 && gc->fg != 8) ! gc2.attr &= ~GRID_ATTR_REVERSE; } else { ! if (gc->bg != 0 && gc->bg != 8) ! gc2.attr |= GRID_ATTR_REVERSE; } } + /* If any bits are being cleared, reset everything. */ + if (tc->attr & ~gc->attr) + tty_reset(tty); + + /* + * Set the colours. This may call tty_reset() (so it comes next) and + * may add to (NOT remove) the desired attributes by changing new_attr. + */ + new_attr = gc->attr; + tty_colours(tty, gc, &new_attr); + /* Filter out attribute bits already set. */ ! changed = new_attr & ~tc->attr; ! tc->attr = new_attr; /* Set the attributes. */ if (changed & GRID_ATTR_BRIGHT)