Ncurses(三)- 使用颜色
检查颜色可用
在使用颜色之前,你需要知道你的终端是否支持颜色显示,你可以通过以下if检测:
if (has_colors() == FALSE) {
endwin();
printf("Your terminal does not support color\n");
exit(1);
}
当然了,我相信这是不需要的,这确认了颜色显示可用
使用颜色
在使用颜色之前你必须先执行start_color();
函数,这个函数不带任何参数