Another ncurses question
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Another ncurses question




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Another ncurses question  
Simon Elliott


Report This Message To A Moderator Edit/Delete Message


 
11-09-05 10:53 PM

Looking at the man pages and curses.h, it seems that there are only 8
colours available:

#define COLOR_BLACK	0
#define COLOR_RED	1
#define COLOR_GREEN	2
#define COLOR_YELLOW	3
#define COLOR_BLUE	4
#define COLOR_MAGENTA	5
#define COLOR_CYAN	6
#define COLOR_WHITE	7

Is there any way to display any other colours?

--
Simon Elliott    http://www.ctsn.co.uk





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Jordan Abel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-09-05 10:53 PM

On 2005-11-09, Simon Elliott <Simon> wrote:
> Looking at the man pages and curses.h, it seems that there are only 8
> colours available:
>
> #define COLOR_BLACK	0
> #define COLOR_RED	1
> #define COLOR_GREEN	2
> #define COLOR_YELLOW	3
> #define COLOR_BLUE	4
> #define COLOR_MAGENTA	5
> #define COLOR_CYAN	6
> #define COLOR_WHITE	7
>
> Is there any way to display any other colours?

bold for foreground, you're SOL for background. [try blink, if you
dare.]

ncurses provides extensions that allow for more colors.





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Simon Elliott


Report This Message To A Moderator Edit/Delete Message


 
11-09-05 10:53 PM

On 09/11/2005, Jordan Abel wrote:
 
>
> bold for foreground, you're SOL for background. [try blink, if you
> dare.]
>
> ncurses provides extensions that allow for more colors.

Thanks. Looking at the man pages again, I now see that I can change the
RGB With init_color(), but still seem to be stuck with only 8 colours.

--
Simon Elliott    http://www.ctsn.co.uk





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Thomas Dickey


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-10-05 12:51 PM

Simon Elliott <Simon at ctsn.co.uk> wrote:
> On 09/11/2005, Jordan Abel wrote:
 
[vbcol=seagreen]
> Thanks. Looking at the man pages again, I now see that I can change the
> RGB With init_color(), but still seem to be stuck with only 8 colours.

no - only certain terminals support the feature used in init_color().
That doesn't define _more_ colors, but allows changing the values for
a palette.

ncurses normally provides coding for 16 colors, and can be compiled to suppo
rt
256 colors.  Only certain terminals (such as xterm) support the larger
numbers of colors.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Simon Elliott


Report This Message To A Moderator Edit/Delete Message


 
11-10-05 11:04 PM

On 10/11/2005, Thomas Dickey wrote:
 
>
> no - only certain terminals support the feature used in init_color().
> That doesn't define more colors, but allows changing the values for
> a palette.

OK

> ncurses normally provides coding for 16 colors, and can be compiled
> to support 256 colors.  Only certain terminals (such as xterm)
> support the larger numbers of colors.

I'm probably missing something blindingly obvious here, but I can't see
how to get 16 colours when there seems to be only these colours
availabe in my curses.h:

#define COLOR_BLACK	0
#define COLOR_RED	1
#define COLOR_GREEN	2
#define COLOR_YELLOW	3
#define COLOR_BLUE	4
#define COLOR_MAGENTA	5
#define COLOR_CYAN	6
#define COLOR_WHITE	7


--
Simon Elliott    http://www.ctsn.co.uk





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Thomas Dickey


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-10-05 11:04 PM

Simon Elliott <Simon at ctsn.co.uk> wrote:

> I'm probably missing something blindingly obvious here, but I can't see
> how to get 16 colours when there seems to be only these colours
> availabe in my curses.h:

...

Those are numbers 0 to 7, for the "ANSI" (actually ISO-6429) colors.
The start_color() manpage notes that the number of colors which the
terminfo claims that the terminal supports is given in the variable
COLORS.  It's ok to use values up to (not including) that.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Brian Raiter


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-10-05 11:04 PM

>> ncurses normally provides coding for 16 colors, and can be compiled 
>
> I'm probably missing something blindingly obvious here, but I can't
> see how to get 16 colours when there seems to be only these colours
> availabe in my curses.h:

Those numbers are just indexes into the default color palette --
i.e. the palette that ncurses sets up when you call start_color(). If
you define a different palette, using init_color(), then you'll be
using your own indexes instead of (or in addition to) the eight that
are predefined.

Don't forget to call can_change_color() before doing any of this.
Plenty of terminals exist that don't support arbitrary color
assignment. (I presume you're already calling has_colors() before
that.)

If you haven't already, man curs_color.

b





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Simon Elliott


Report This Message To A Moderator Edit/Delete Message


 
11-14-05 10:56 PM

On 10/11/2005, Thomas Dickey wrote:

> Those are numbers 0 to 7, for the "ANSI" (actually ISO-6429) colors.
> The start_color() manpage notes that the number of colors which the
> terminfo claims that the terminal supports is given in the variable
> COLORS.  It's ok to use values up to (not including) that.

Thanks. My xterm does this:

has_colors()       : TRUE
can_change_color() : FALSE
COLORS             : 8
COLOR_PAIRS        : 64

so looks like on that terminal at any rate I'm out of luck!

--
Simon Elliott    http://www.ctsn.co.uk





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Thomas Dickey


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-15-05 12:55 PM

Simon Elliott <Simon at ctsn.co.uk> wrote:

> so looks like on that terminal at any rate I'm out of luck!

ncurses doesn't _know_ what the terminal does.
You tell ncurses what it does based on the terminfo description.
(I don't recall which terminal emulator you're using).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net





[ Post a follow-up to this message ]



    Re: Another ncurses question  
Jordan Abel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-15-05 12:55 PM

On 2005-11-15, Thomas Dickey <dickey@saltmine.radix.net> wrote:
> Simon Elliott <Simon at ctsn.co.uk> wrote:
> 
>
> ncurses doesn't _know_ what the terminal does.
> You tell ncurses what it does based on the terminfo description.
> (I don't recall which terminal emulator you're using).

Also, on many terminals, setting the bold attribute picks a different
color than without it [i.e. dark grey instead of black, yellow instead
of brown, etc]





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:05 PM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register