Linux.com

Home Linux Community Forums Software Command Line ncurses - start_color - screen color

ncurses - start_color - screen color

Link to this post 11 Jun 12

When using start_color command in ncurses the screen starts with a black background. Is there any way of resetting this to another color?

If this is not the appropriate forum for this question - sorry and please redirect me.

TIA

Alan

Link to this post 13 Jun 12

I don't use ncurses, but there are a few extensions that are mentioned at this link which you might find useful:
https://www.gnu.org/software/ncurses/

Link to this post 13 Jun 12

Thanks for the link I will follow it up.

Alan

Link to this post 14 Jun 12

Let's back to the basics ! Have u added refresh(); after declaring color code.....start_color routine requires no arguments. It is good practice to call this routine right after initscr();. There r some basic colors like black, red, green, yellow, blue, magenta, cyan, and white. The sample code looks like that:
start_color();
color_set(COLOR_PAIR(1));
refresh();
Don't confuse this code with ur original one, this is just an example. COLOR_PAIR is declared as own func and 1 indicates as Red color. Please see here for tricks and color codes: http://uw714doc.sco.com/en/SDK_charm/_Color_Manipulation.html

Link to this post 14 Jun 12

Are you trying to change the color in your terminal @Chronos?

Link to this post 14 Jun 12

I contacted Thomas Dickey and he very kindly helped me. Use use_default_colors() after start_color()

See http://invisible-island.net/ncurses/ncurses-intro.html - search for use_default_colors() This will use the terminal colors as you have them set up.

For example:


initscr(); // Start curses mode

if(has_colors() == FALSE) // Check the terminal has colour capability
{
endwin(); // Close Window and leave ncurses
printf("Your terminal does not support colour. ");
return(1); // Leave the program
}

start_color(); // Start colour mode

use_default_colors();
...
...

Alan

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board