Thread: Ncurses restore color on endwin()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    51
    Ok I think I got it. init_color() not required. On a term that supports 256 colors, it is as simple as that. I should have thought about it before. And most importantly, the terminal colorsheme is not broken on exit.

    Code:
    #include <ncurses.h>
      
    WINDOW *w;
      
    void set_colors(void)
    {
        int i;
        initscr();
        start_color();
        use_default_colors();
    
        for(i=0 ;i<256;i++)
        {
            init_pair(i, i, COLOR_BLACK);
            attron(COLOR_PAIR(i));
            printw("[COLOR %hd] ", i);
            refresh();
        }
        standend();
        getch();
        endwin();
    }
      
    int main(void)
    {
        set_colors();
        return 0;
    }
    Last edited by mariostg; 08-05-2012 at 08:00 AM. Reason: remove variable j

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Change color per Character ncurses
    By greendragons in forum C Programming
    Replies: 5
    Last Post: 04-30-2012, 08:10 PM
  2. Need help to restore running app
    By WDT in forum C# Programming
    Replies: 4
    Last Post: 08-05-2009, 11:05 AM
  3. log and restore
    By TopJo in forum C Programming
    Replies: 3
    Last Post: 07-01-2003, 07:14 PM
  4. Restore CD's
    By windoze victim in forum Tech Board
    Replies: 8
    Last Post: 03-10-2003, 05:50 AM
  5. windows restore
    By master2000 in forum Tech Board
    Replies: 8
    Last Post: 01-08-2003, 09:42 AM