]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/color_set.c
ncurses 5.4
[ncurses.git] / test / color_set.c
1 /*
2  * $Id: color_set.c,v 1.2 2003/12/07 00:08:47 tom Exp $
3  */
4
5 #include <test.priv.h>
6
7 #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
8
9 int
10 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
11 {
12     short f, b;
13     int i;
14
15     initscr();
16     cbreak();
17     noecho();
18
19     if (has_colors()) {
20         start_color();
21
22         pair_content(0, &f, &b);
23         printw("pair 0 contains (%d,%d)\n", f, b);
24         getch();
25
26         printw("Initializing pair 1 to red/black\n");
27         init_pair(1, COLOR_RED, COLOR_BLACK);
28         i = color_set(1, NULL);
29         printw("RED/BLACK (%s)\n", SHOW(i));
30         getch();
31
32         printw("Initializing pair 2 to white/blue\n");
33         init_pair(2, COLOR_WHITE, COLOR_BLUE);
34         i = color_set(2, NULL);
35         printw("WHITE/BLUE (%s)\n", SHOW(i));
36         getch();
37
38         printw("Resetting colors to pair 0\n");
39         i = color_set(0, NULL);
40         printw("Default Colors (%s)\n", SHOW(i));
41         getch();
42
43         printw("Resetting colors to pair 1\n");
44         i = color_set(1, NULL);
45         printw("RED/BLACK (%s)\n", SHOW(i));
46         getch();
47
48     } else {
49         printw("This demo requires a color terminal");
50         getch();
51     }
52     endwin();
53
54     ExitProgram(EXIT_SUCCESS);
55 }