任何 Windows 终端的调色板都可以使用 pdcurses 进行编辑吗?

Can any Windows terminal's color palettes be edited with pdcurses?

本文关键字:pdcurses 编辑 可以使 终端 Windows 调色板 任何      更新时间:2023-10-16

我是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("bbbbn");
    getch();
    endwin();
    return 0;
}

在PDCurses 3.4中做这件事的代码曾经在某些版本的Windows中工作,但后来的Windows (XP Service Pack 3+)破坏了它。但是,如果你从git中获取最新的PDCurses代码,它已经被更新为可以与当前的Windows一起工作。

顺便说一句,你应该只在initscr()之后调用init_color()