c++windowscolorsterminalpdcurses

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


I'm a big fan of ASCII aesthetics, and the idea of creating graphics from a terminal appeals to me.

I'm playing around with pdcurses on a Windows environment, and I found a very interesting property: init_color. However, it does not seem to work at all! Not only is the color range of every terminal I've tried (CMD.exe, ConEmu and Console2) limited to 16 colors, I cannot seem to be able to edit the palette.

I couldn't find anything about this topic online.

So- Is it at all possible? And if not, are there alternatives? For example, I know ConEmu has palettes, but I do not know how to tell it what palette to use from a c++ program.

Here's a sample of code I tried:

#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;
}

Solution

  • The code to do it in PDCurses 3.4 used to work in some versions of Windows, but later Windows (XP Service Pack 3+) broke it. However, it's been updated to work with current Windows if you grab the latest PDCurses code from git.

    BTW, you should only call init_color() after initscr().