我正在编写一个基于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(:
颜色对0是特殊的;它表示";没有颜色";。
颜色对0被假定为黑底白,但是实际上,无论终端在彩色之前实现什么已初始化。应用程序无法修改它。