Код: Выделить всё
void InitColors()
{
start_color();
if (can_change_color() && COLORS >= 256)
{
init_color(COLOR_BLACK, 400, 400,
400);
init_color(COLOR_BLUE, 700, 700,
700);
init_color(COLOR_WHITE, 900, 900,
900);
init_pair(1, COLOR_WHITE,
COLOR_BLUE);
init_pair(2, COLOR_BLACK,
COLOR_WHITE);
bkgd(COLOR_PAIR(2));
}
else
{
// Fallback for terminals that don't support color
if (COLORS >= 8)
{
init_pair(1, COLOR_WHITE, COLOR_BLUE);
init_pair(2, COLOR_WHITE, COLOR_BLACK);
init_pair(3, COLOR_BLACK,
COLOR_WHITE);
bkgd(COLOR_PAIR(2));
}
else
{
// Monochrome fallback
init_pair(1, COLOR_WHITE, COLOR_BLACK);
bkgd(COLOR_PAIR(1));
}
}
}
int main(int argc, char** argv)
{
setlocale(LC_ALL,
"");
setlocale(LC_CTYPE, "");
initscr();
nodelay(stdscr, TRUE);
noecho();
raw();
InitColors();
clear();
attron(COLOR_PAIR(1));
printw("Hey there!\n");
refresh();
attron(COLOR_PAIR(2));
printw("Hey there!\n");
refresh();
while (1) {}
}
linux output:
Я использую WSL для проверки выхода Linux. Я использую Pdcurses в Windows.
Подробнее здесь: https://stackoverflow.com/questions/796 ... in-ncurses