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