]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ncurses/test/testaddch.c
This commit was generated by cvs2svn to compensate for changes in r104752,
[FreeBSD/FreeBSD.git] / contrib / ncurses / test / testaddch.c
1 /*
2  * This is an example written by Alexander V. Lukyanov <lav@yars.free.net>,
3  * to demonstrate an inconsistency between ncurses and SVr4 curses.
4  *
5  * $Id: testaddch.c,v 1.4 2001/09/15 21:46:34 tom Exp $
6  */
7 #include <test.priv.h>
8
9 static void
10 attr_addstr(const char *s, chtype a)
11 {
12     while (*s)
13         addch(((unsigned char) (*s++)) | a);
14 }
15
16 int
17 main(
18         int argc GCC_UNUSED,
19         char *argv[]GCC_UNUSED)
20 {
21     unsigned i;
22     chtype back, set, attr;
23
24     initscr();
25     start_color();
26     init_pair(1, COLOR_WHITE, COLOR_BLUE);
27     init_pair(2, COLOR_WHITE, COLOR_RED);
28     init_pair(3, COLOR_BLACK, COLOR_MAGENTA);
29     init_pair(4, COLOR_BLACK, COLOR_GREEN);
30     init_pair(5, COLOR_BLACK, COLOR_CYAN);
31     init_pair(6, COLOR_BLACK, COLOR_YELLOW);
32     init_pair(7, COLOR_BLACK, COLOR_WHITE);
33
34     for (i = 0; i < 8; i++) {
35         back = (i & 1) ? A_BOLD | 'B' : ' ';
36         set = (i & 2) ? A_REVERSE : 0;
37         attr = (i & 4) ? COLOR_PAIR(4) : 0;
38
39         bkgdset(back);
40         attrset(set);
41
42         attr_addstr("Test string with spaces ->   <-\n", attr);
43     }
44     addch('\n');
45     for (i = 0; i < 8; i++) {
46         back = (i & 1) ? A_BOLD | 'B' | COLOR_PAIR(1) : ' ';
47         set = (i & 2) ? A_REVERSE | COLOR_PAIR(2) : 0;
48         attr = (i & 4) ? COLOR_PAIR(4) : 0;
49
50         bkgdset(back);
51         attrset(set);
52
53         attr_addstr("Test string with spaces ->   <-\n", attr);
54     }
55
56     getch();
57     endwin();
58     ExitProgram(EXIT_SUCCESS);
59 }