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