【问题标题】:color in pdcurses on win32win32上pdcurses的颜色
【发布时间】: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();
}

【问题讨论】:

    标签: winapi pdcurses


    【解决方案1】:

    它可能无法解决任何问题,但我发现有时程序不会更新 GCC 代码块上的颜色,我添加了一个 getch();最后,它似乎解决了我在颜色或向屏幕添加文本时遇到的任何问题。

    确保 getch();虽然是在刷新之前

    【讨论】:

      【解决方案2】:

      你是不是错过了:

      attroff(COLOR_PAIR(1)) attroff(COLOR_PAIR(2))

      每次打印后?

      添加它们,看看会发生什么。

      我在 x64 win7 下使用带有 code::blocks 的 pdcurses,我对颜色没有任何问题。有可能只有 MSVC++ 有这个问题,但我对此表示怀疑。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-06-12
        • 1970-01-01
        • 1970-01-01
        • 2014-07-24
        • 1970-01-01
        • 2012-04-29
        • 1970-01-01
        • 2010-12-04
        相关资源
        最近更新 更多