我是 ASCII 美学的忠实粉丝,从终端创建图形的想法很吸引我。
我在 Windows 环境中使用 pdcurses,发现了一个非常有趣的属性:init_color。但是,它似乎根本不起作用!我尝试过的每个终端(CMD.exe、ConEmu 和 Console2)的颜色范围不仅限于 16 种颜色,而且我似乎无法编辑调色板。
我在网上找不到有关此主题的任何信息。
那么——这有可能吗?如果没有,还有其他选择吗?例如,我知道 ConEmu 有调色板,但我不知道如何告诉它从 c++ 程序中使用哪个调色板。
这是我尝试过的代码示例:
#include <curses.h>
int main()
{
init_color(1, 700, 600, 111);
initscr();
noecho();
if(has_colors() == FALSE)
{
endwin();
printf("Your terminal doesn't support color..!\n");
return 1;
}
init_color(2, 555, 555, 222);
start_color();
init_pair(1, 1, 0);
init_pair(2, 2, 0);
attron(COLOR_PAIR(1));
printw("aaaa ");
attron(COLOR_PAIR(2));
init_color(12, 700, 600, 111);
printw("bbbb\n");
getch();
endwin();
return 0;
}