diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 16:50:57 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 16:50:57 +0000 |
commit | 88b83be07b0c080a460db393d292c9a0b3c05c39 (patch) | |
tree | 7cfb7a0043779a3d01ac7e6d477a8ef7c83f5647 /tty.c | |
parent | 65a28912ebf180f736f29fcecc3c87223e5ee533 (diff) | |
download | rtmux-88b83be07b0c080a460db393d292c9a0b3c05c39.tar.gz rtmux-88b83be07b0c080a460db393d292c9a0b3c05c39.tar.bz2 rtmux-88b83be07b0c080a460db393d292c9a0b3c05c39.zip |
Sync OpenBSD patchset 220:
If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.
This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.120 2009-08-09 15:26:24 tcunha Exp $ */ +/* $Id: tty.c,v 1.121 2009-08-09 16:50:57 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -961,19 +961,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) |