1 04/15/88 "HIGHLIGHT" EXAMPLE
2
3 /*
4 * HIGHLIGHT. A program to turn U, B, and
5 * N sequences into highlighted
6 * output, allowing words to be
7 * displayed underlined or in bold.
8 */
9
10 #include <curses.h>
11
12
13 mainargc argv
14 char **argv;
15
16 FILE *fd;
17 int c c2;
18
19
20 if argc !=2
21 fprintfstderr "Usage: highlight file0\n";
22 exit1;
23
24
25
26 fd = fopenargv1 "r";
27 if fd == NULL
28 perrorargv1;
29 exit2;
30
31
32 initscr;
33
34 scrollokstdscr TRUE;
35
36 for ;;
37 c = getcfd;
38 if c == EOF
39 break;
40
41
42 if c == '\\'
43
44 c2 = getcfd;
45 switch c2
46
47 case 'B':
48 attrsetA_BOLD;
49 continue;
50 case'U':
51 attrsetA_UNDERLINE;
52 continue;
53
54 case'N':
55 attrset0;
56
57
58 continue;
59
60 addchc;
61 addchc2;
62
63 else
64 addchc;
65
66
67 fclosefd;
68 refresh;
69 endwin;
70 exit0;
71
72