summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-04-15 22:34:47 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-04-15 22:34:47 +0000
commit0e25f8647fc3f3a3e6d48c358c22f27c581be2ca (patch)
treeeb2aa532defae6d4e25cc96482fa7eb823bbe538
parent85ea9a7b37455fc3eb4b44d1d567b04b1055cdd5 (diff)
Fix some issues in bright colour handling. Bold background doesn't exist
so there is no reason for tty_check_bg to mess with the BRIGHT flag at all, ever. Also use aixterm colours for 256-to-16 translation if the terminal supports them. And there is no reason for tty_colours_bg to worry about whether the terminal supports them - tty_check_bg has already taken care of it.
-rw-r--r--usr.bin/tmux/tty.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 741b230640d..44960d1b710 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.174 2015/04/15 22:10:13 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.175 2015/04/15 22:34:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1453,6 +1453,8 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
{
u_int colours;
+ colours = tty_term_number(tty->term, TTYC_COLORS);
+
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_FG256) {
/* And not a 256 colour mode? */
@@ -1461,7 +1463,10 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
gc->fg = colour_256to16(gc->fg);
if (gc->fg & 8) {
gc->fg &= 7;
- gc->attr |= GRID_ATTR_BRIGHT;
+ if (colours >= 16)
+ gc->fg += 90;
+ else
+ gc->attr |= GRID_ATTR_BRIGHT;
} else
gc->attr &= ~GRID_ATTR_BRIGHT;
gc->flags &= ~GRID_FLAG_FG256;
@@ -1470,7 +1475,6 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
}
/* Is this an aixterm colour? */
- colours = tty_term_number(tty->term, TTYC_COLORS);
if (gc->fg >= 90 && gc->fg <= 97 && colours < 16) {
gc->fg -= 90;
gc->attr |= GRID_ATTR_BRIGHT;
@@ -1482,6 +1486,8 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc)
{
u_int colours;
+ colours = tty_term_number(tty->term, TTYC_COLORS);
+
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_BG256) {
/*
@@ -1492,20 +1498,19 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc)
if (!(tty->term->flags & TERM_256COLOURS) &&
!(tty->term_flags & TERM_256COLOURS)) {
gc->bg = colour_256to16(gc->bg);
- if (gc->bg & 8)
+ if (gc->bg & 8) {
gc->bg &= 7;
- gc->attr &= ~GRID_ATTR_BRIGHT;
+ if (colours >= 16)
+ gc->fg += 90;
+ }
gc->flags &= ~GRID_FLAG_BG256;
}
return;
}
/* Is this an aixterm colour? */
- colours = tty_term_number(tty->term, TTYC_COLORS);
- if (gc->bg >= 90 && gc->bg <= 97 && colours < 16) {
+ if (gc->bg >= 90 && gc->bg <= 97 && colours < 16)
gc->bg -= 90;
- gc->attr |= GRID_ATTR_BRIGHT;
- }
}
void
@@ -1559,14 +1564,9 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
/* Is this an aixterm bright colour? */
if (bg >= 90 && bg <= 97) {
- /* 16 colour terminals or above only. */
- if (tty_term_number(tty->term, TTYC_COLORS) >= 16) {
- xsnprintf(s, sizeof s, "\033[%dm", bg + 10);
- tty_puts(tty, s);
- goto save_bg;
- }
- bg -= 90;
- /* no such thing as a bold background */
+ xsnprintf(s, sizeof s, "\033[%dm", bg + 10);
+ tty_puts(tty, s);
+ goto save_bg;
}
/* Otherwise set the background colour. */