Trying to manipulate colors using ncurses, I bumped into a weird bug.
I want to set my own colors by changing color definitions using init_color. I also wanted to make the cursor invisible. That's when init_color stopped functioning correctly.
I narrowed it down to this example: it should work fine and display a 'Hello World' on a bright red background.
int main(int ac, char** av){
initscr();
start_color();
refresh();
init_my_color();
init_pair(1,COLOR_BLACK,100);
attron(COLOR_PAIR(1));
printw("Hello World");
refresh();
getch();
endwin();
return 0;}
void init_my_color(){
//curs_set(0); //<- but if you uncomment this line, it doesn't work anymore.
init_color(100,999,111,111);
return;}
Can someone explain this behavior?
I tried moving the code around in multiple ways, identifying the line that creates the problem. I also tried getting the return value for init_color, but even when it doesn't work, it doesn't return ERR. can_change_color returns TRUE, and without the curs_set call, it all works fine in my terminal.
EDIT: I forgot to mention that in order to test it, you need to change the color before reloading the program, otherwise it'll just use the same color whether it works or not.