Documentation

A display attribute defines the Color and Style of all the characters rendered after the
attribute is applied.

At most 256 colors, picked from a 240 and 16 color palette, are possible for the background and
foreground. The 240 colors and 16 colors are points in different palettes. See Color for more
information.

Specifies the display attributes such that the final style and color values do not depend on
the previously applied display attribute. The display attributes can still depend on the
terminal's default colors (unfortunately).

Currently the foreground and background color are specified as points in either a:

16 color palette. Where the first 8 colors are equal to the 8 colors of the ISO 6429 (ANSI) 8
color palette and the second 8 colors are bright/vivid versions of the first 8 colors.

240 color palette. This palette is a regular sampling of the full RGB colorspace.

The 8 ISO 6429 (ANSI) colors are as follows:

black

red

green

yellow

blue

magenta

cyan

white

The mapping from points in the 240 color palette to colors actually displayable by the terminal
depends on the number of colors the terminal claims to support. Which is usually determined by
the terminfo colors property. If this property is not being accurately reported then the color
reproduction will be incorrect.

If the terminal reports <= 16 colors then the 240 color palette points are only mapped to the 8
color pallete. I'm not sure of the RGB points for the bright colors which is why they are not
addressable via the 240 color palette.

If the terminal reports > 16 colors then the 240 color palette points are mapped to the nearest
points in a (color count - 16) subsampling of the 240 color palette.

All of this assumes the terminals are behaving similarly to xterm and rxvt when handling colors.
And that the individual colors have not been remapped by the user. There may be a way to verify
this through terminfo but I don't know it.