aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/tty.c b/tty.c
index d3a4ba1d..cbdbec8d 100644
--- a/tty.c
+++ b/tty.c
@@ -951,19 +951,33 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc)
{
struct grid_cell *tc = &tty->cell;
u_char changed;
- u_int fg, bg;
+ 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 & ~gc->attr)
+ if (tc->attr & ~attr)
tty_reset(tty);
/* Filter out attribute bits already set. */
- changed = gc->attr & ~tc->attr;
- tc->attr = gc->attr;
+ changed = attr & ~tc->attr;
+ tc->attr = 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)