[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help understanding colour limitations.

From: Thomas Dickey
Subject: Re: Help understanding colour limitations.
Date: Sun, 20 Aug 2017 15:44:37 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Aug 20, 2017 at 01:01:39PM -0400, Patrick wrote:
> Hi Everyone
> I know that with the int constant COLORS we will know how many
> colours the terminal supports. I know that 8, 88 and 256 are pretty
> much the only combinations that are likely to be encountered and I
> am assuming that if I default to 8 on something else, I should be
> safe.

actually, there's the faction that insists that 16 million colors are
"standard", but read on.
> However, is there any danger in initializing 256 colours, with
> init_color(),  when the terminal only support 8 or 88 ? I am
> creating a palette of 256 colours(or almost 256) but I know this
> can't be used in all terminals. However can they be safely
> initialized if I only actually use a smaller amount that the
> terminal actually supports? I am planning on having the first 8,
> just the same as the built in colours, BLACK, BLUE, GREEN etc

Like anything else, "it depends".  xterm's predefined palettes for
16-, 88- and 256-colors all have the same colors in the first 8 slots,
and the 16/88/256 palettes have the same colors in the first 16 slots.

Now... with init_color
       int init_color(short color, short r, short g, short b);

you're telling ncurses (if it can) to use the terminfo capability
initc, to set specific r/g/b values.  ncurses ignores the request
if "color" is out of range (i.e., <= 0, or >= COLORS).  So that's
safe.  Setting large palettes can be slow, however.  In the demo I've
been working on, I simply tell the application what the terminal's
palette is, and don't try to tell ncurses to change the palette.

However (using xterm as an example), a palette which is designed for
256 colors may not be as useful with an 88-color terminal.  Offhand,
I recall that urxvt prefers (or used to) 88-colors, so you might run
into one of those.  Linux console doesn't do 256 colors either.

As long as the first 8 colors match the ANSI definitions, then it's
simple to work with (you always know how to print text, since that's 0 and 7).
That wouldn't hold for "16 million", since the first 8 slots are
indistinguishable grays that look black to humans without a color-selector
application.  (I have some thoughts about improving that situation...).

Thomas E. Dickey <address@hidden>

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]