C program under Linux ------ Curses: Color

zhaozj2021-02-16  106

#include

#include

#include

#include

int main ()

{

INITSCR ();

IF (! HAS_COLORS ())

{

Endwin ();

FPRINTF (stderr, "error: no color support on this terminal / n");

Exit (1);

}

Else

{

PrintW ("% s", "color support");

Refresh ();

Sleep (2);

}

IF (start_color ()! = ok)

{

Endwin ();

FPRINTF (stderr, "error: could not initialize colors! / n");

EXIT (2);

}

Clear ();

MVPrintW (5, 5, "There Are% D Colors and% D Color_Pairs Available", Colors, Color_Pairs);

Refresh (); SLEEP (2);

INIT_PAIR (1, color_red, color_black);

INIT_PAIR (2, color_red, color_green);

INIT_PAIR (3, color_green, color_red);

INIT_PAIR (4, Color_Yellow, Color_Blue);

INIT_PAIR (5, color_black, color_white);

INIT_PAIR (6, color_magenta, color_blue);

INIT_PAIR (7, color_cyan, color_white);

INT I;

For (i = 1; i <8; i )

{

Attroff (A_BOLD);

Attrse (Color_Pair (i));

MVPrintw (5 i, 5, "Color Pair:% D", I);

Attrse (A_BOLD);

MVPrintW (5 i, 25, "Bold Color PAIR:% D", I);

Refresh (); SLEEP (2);

}

Endwin ();

Exit (exit_success);

}

转载请注明原文地址:https://www.9cbs.com/read-10786.html

New Post(0)