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;
}