=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.17 retrieving revision 1.18 diff -c -r1.17 -r1.18 *** src/usr.bin/tmux/tty.c 2009/08/03 14:10:54 1.17 --- src/usr.bin/tmux/tty.c 2009/08/05 16:26:38 1.18 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.17 2009/08/03 14:10:54 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.18 2009/08/05 16:26:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 951,969 **** { struct grid_cell *tc = &tty->cell; u_char changed; ! u_int fg, bg; /* If any bits are being cleared, reset everything. */ ! if (tc->attr & ~gc->attr) tty_reset(tty); /* Filter out attribute bits already set. */ ! changed = gc->attr & ~tc->attr; ! tc->attr = gc->attr; /* Set the attributes. */ - fg = gc->fg; - bg = gc->bg; if (changed & GRID_ATTR_BRIGHT) tty_putcode(tty, TTYC_BOLD); if (changed & GRID_ATTR_DIM) --- 951,983 ---- { struct grid_cell *tc = &tty->cell; u_char changed; ! u_int fg, bg, 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. + */ + fg = gc->fg; bg = gc->bg; attr = gc->attr; + 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; + } + } + /* If any bits are being cleared, reset everything. */ ! if (tc->attr & ~attr) tty_reset(tty); /* Filter out attribute bits already set. */ ! changed = attr & ~tc->attr; ! tc->attr = attr; /* Set the attributes. */ if (changed & GRID_ATTR_BRIGHT) tty_putcode(tty, TTYC_BOLD); if (changed & GRID_ATTR_DIM)