Welcome to the new Linux Foundation Forum!

ncurses - start_color - screen color

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

Comments

  • Goineasy9Goineasy9 Posts: 1,116
    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/
  • ChronosChronos Posts: 4
    Thanks for the link I will follow it up.

    Alan
  • 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
  • saqman2060saqman2060 Posts: 777
    Are you trying to change the color in your terminal @Chronos?
  • ChronosChronos Posts: 4
    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
Sign In or Register to comment.