无论我将其设置为什么颜色,ncurses 程序都会在黑色上打印白色

ncurses program will print white on black no matter what color i set it to

我正在编写一个基于 ncurses 的文本应用程序。我有一个名为 colorPlot 的函数:

void colorPlot(int x, int y, int foregroundColor, int backgroundColor, char plotChar)
{
    init_pair(0, foregroundColor, backgroundColor);
    attrset(COLOR_PAIR(0));
    mvaddch(y, x, plotChar);
}

但是每当我尝试在我的主函数中调用它时:

int main(void) {
    initscr();
    start_color();

    colorPlot(1, 1, COLOR_RED, COLOR_WHITE, '@');

    refresh();

    getch();

    endwin();
}

它只打印黑底白字。为什么不打印红底白字?

颜色对 0(start_color 见手册)已保留:

color pair 0 is special; it denotes "no color".

Color pair 0 is assumed to be white on black, but is actually whatever the terminal implements before color is initialized. It cannot be modified by the application.