Welcome to the 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

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 1,114
    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/
  • 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
  • Posts: 777
    Are you trying to change the color in your terminal @Chronos?
  • 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:
    1. initscr(); // Start curses mode
    2.  
    3. if(has_colors() == FALSE) // Check the terminal has colour capability
    4. {
    5. endwin(); // Close Window and leave ncurses
    6. printf("Your terminal does not support colour. ");
    7. return(1); // Leave the program
    8. }
    9.  
    10. start_color(); // Start colour mode
    11. use_default_colors();
    12. ...
    13. ...

    Alan

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training