I want to set a new color orange for later use but print out something in grey (color black + attribute bold) now, but that specific combination changes to the new color instead.
#include <curses.h>
int main() {
::initscr();
::start_color();
::init_color(8, 1000, 500, 0); //Set the 8th color to be orange
::init_pair(1, COLOR_BLACK, COLOR_BLACK); //Set the 1st pair to be black on black
::mvaddstr(0, 0, "Some dim text.");
::mvchgat(0, 0, -1, 0, 1, 0); //Text should be dark black on dark black (invisible)
::mvaddstr(1, 0, "Some bold text.");
::mvchgat(1, 0, -1, A_BOLD, 1, 0); //Text should be light black on dark black
::getch();
::endwin();
}
All functions are successful and such, I've omitted the tests for failure out of brevity.
I expected "Some dim text." to be invisible and "Some bold text." to be light black on black, but what actually happens is that only "Some bold text." is bright orange instead.
The color 8 in PDCurses, by default, is the same as A_BLACK | A_BOLD (as a foreground color -- it'd be A_BLACK | A_BLINK as a background color). This goes back to the behavior of ancient PC video cards in text mode. You can decouple the colors from the A_BOLD attribute by calling "PDC_set_bold(TRUE)"; however, in that case, you still wouldn't get light black from the above code.
If you want to use any of the default "light" colors, you're using colors 8 through 15 -- either explicitly, by number, or implicitly, via the A_BOLD and A_BLINK attributes. So, when adding a new color, you should either choose a number outside that range, or just be aware of which existing color you're overwriting (i.e. the "dark" color number + 8).