bright colors with GNOME Terminal / 256-color terminals

Vincent Lefevre vincent at vinc17.org
Fri Dec 14 04:15:07 UTC 2018


In the Mutt manual:

   foreground can optionally be prefixed with the keyword bright to make
   the foreground color boldfaced (e.g., brightred).

That's the way to do with xterm, where boldfaced mode is a way to get
bright colors, but in GNOME Terminal, this does bold + bright colors.
IMHO, one should just get bright colors in GNOME Terminal (without
bold), or at least this should be configurable.

For instance, in xterm, one uses

  tput bold; tput setaf 3; echo abcdef

but in GNOME Terminal, one uses

  tput setaf 11; echo abcdef

I assume that the reason is that xterm just has 8 colors:

$ tput colors
8

thus it has to emulate the bright colors with the bold attribute.

Now, the issue is the following in color.c:

  if (is_bright)
  {
    if (is_fg)
    {
      *attr |= A_BOLD;
    }
    else if (COLORS < 16)
    {
      /* A_BLINK turns the background color brite on some terms */
      *attr |= A_BLINK;
    }
    else
    {
      /* Advance the color by 8 to get the bright version */
      *col += 8;
    }
  }

I think that

    if (is_fg)

should be replaced by

    if (is_fg && COLORS < 16)

Or in the following, equivalent way:

  if (is_bright)
  {
    if (COLORS >= 16)
    {
      /* Advance the color by 8 to get the bright version */
      *col += 8;
    }
    else if (is_fg)
    {
      *attr |= A_BOLD;
    }
    else
    {
      /* A_BLINK turns the background color brite on some terms */
      *attr |= A_BLINK;
    }
  }

Not tried yet, I need some sleep.

Note: Some users might not like this (i.e. they would like
bold + bright), in which case one could introduce "boldbright"
colors (and also maybe "bold" colors). In 8-color terminals,
"bold", "bright" and "boldbright" colors would be equivalent
(they would just set A_BOLD).

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Mutt-dev mailing list