【发布时间】:2013-12-11 02:59:34
【问题描述】:
我正在尝试让一个简单的控制台程序在 Windows 中工作(它在 linux 中工作)。我在 linux 上使用 curses,当迁移到 windows 时,我发现移植我的程序最不麻烦的方式是使用 pdcurses。我以前在 Windows 中使用过 pdcurses,但使用的是 win32a 插件。但是,我希望这个程序在 Windows 控制台中运行。
问题在于它似乎完全忽略了所有颜色命令。这是 Windows 上 pdcurses 的问题还是我只是愚蠢?即使是包装附带的演示也没有颜色。我在 Win7 64x 上使用 MSVC++ express 2010。
hasColors() 返回TRUE。当我从文档中运行这个简单的示例时,一切仍然是黑白的:
#include <curses.h>
int main()
{
initscr();
if(has_colors() == FALSE)
{ endwin();
printf("Your terminal does not support color\n");
exit(1);
}
start_color();
init_pair(1, COLOR_BLACK, COLOR_RED);
init_pair(2, COLOR_BLACK, COLOR_GREEN);
attron(COLOR_PAIR(1));
printw("This should be printed in black with a red background!\n");
attron(COLOR_PAIR(2));
printw("And this in a green background!\n");
refresh();
endwin();
}
【问题讨论】: