source: trunk/ncurses/test/testaddch.c@ 3003

Last change on this file since 3003 was 2621, checked in by bird, 19 years ago

GNU ncurses 5.5

File size: 1.4 KB
Line 
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.5 2002/06/29 23:32:18 tom Exp $
6 */
7#include <test.priv.h>
8
9static void
10attr_addstr(const char *s, chtype a)
11{
12 while (*s)
13 addch(((unsigned char) (*s++)) | a);
14}
15
16int
17main(
18 int argc GCC_UNUSED,
19 char *argv[]GCC_UNUSED)
20{
21 unsigned i;
22 chtype back, set, attr;
23
24 setlocale(LC_ALL, "");
25
26 initscr();
27 start_color();
28 init_pair(1, COLOR_WHITE, COLOR_BLUE);
29 init_pair(2, COLOR_WHITE, COLOR_RED);
30 init_pair(3, COLOR_BLACK, COLOR_MAGENTA);
31 init_pair(4, COLOR_BLACK, COLOR_GREEN);
32 init_pair(5, COLOR_BLACK, COLOR_CYAN);
33 init_pair(6, COLOR_BLACK, COLOR_YELLOW);
34 init_pair(7, COLOR_BLACK, COLOR_WHITE);
35
36 for (i = 0; i < 8; i++) {
37 back = (i & 1) ? A_BOLD | 'B' : ' ';
38 set = (i & 2) ? A_REVERSE : 0;
39 attr = (i & 4) ? COLOR_PAIR(4) : 0;
40
41 bkgdset(back);
42 attrset(set);
43
44 attr_addstr("Test string with spaces -> <-\n", attr);
45 }
46 addch('\n');
47 for (i = 0; i < 8; i++) {
48 back = (i & 1) ? A_BOLD | 'B' | COLOR_PAIR(1) : ' ';
49 set = (i & 2) ? A_REVERSE | COLOR_PAIR(2) : 0;
50 attr = (i & 4) ? COLOR_PAIR(4) : 0;
51
52 bkgdset(back);
53 attrset(set);
54
55 attr_addstr("Test string with spaces -> <-\n", attr);
56 }
57
58 getch();
59 endwin();
60 ExitProgram(EXIT_SUCCESS);
61}
Note: See TracBrowser for help on using the repository browser.