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
    I have colors=256.

    echo $TERM
    xterm-256color
    -->display full color change on my last program post
    TERM=xterm
    echo $TERM
    xterm
    -->display color 0 to 7 only.

    This display Error on color 7, 8 and 9
    Code:
    #include <ncurses.h>
      
    const short colors[] =
    {
        COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
        COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
    };
     
    const int num_colors = sizeof(colors) / sizeof(*colors);
    
    WINDOW *w;
      
    void set_colors(void)
    {
        int i;
        initscr();
        start_color();
        use_default_colors();
    
        for (i = 0; i < num_colors; ++i)
        {
            init_pair(i, colors[i], COLOR_BLACK);
            attron(COLOR_PAIR(i));
            printw("COLOR %hd\n", i);
            refresh();
        }
        int j;
        for(;i<21;i++)
        {
            j=(i-10)*100;
            int r=init_color(i, 500, 1000, j);
            if (r==ERR)
                printw("ERROR COLOR %hd\n", i);
            init_pair(i, i, COLOR_BLACK);
            attron(COLOR_PAIR(i));
            printw("COLOR %hd\n", i);
            refresh();
        }
        standend();
        getch();
        endwin();
    }
      
    int main(void)
    {
        set_colors();
        return 0;
    }
    Last edited by mariostg; 08-04-2012 at 08:05 PM.

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