1

我是 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;
}
4

1 回答 1

1

在 PDCurses 3.4 中执行此操作的代码曾经在某些版本的 Windows 中工作,但后来的 Windows (XP Service Pack 3+) 破坏了它。但是,如果您从 git 获取最新的 PDCurses 代码,它已更新为适用于当前 Windows。

顺便说一句,你应该只init_color()initscr().

于 2016-08-25T12:58:36.637 回答