1 04/15/88  "termhl" EXAMPLE
  2 
  3 /*
  4  *        TERMHL.  A terminfo level version of highlight.
  5  */
  6 
  7 #include <curses.h>
  8 #include <term.h>
  9 
 10 #define LF 012
 11 
 12 int ulmode =0;      /* Currently underlining */
 13 
 14 
 15 mainargc argv
 16 char **argv;
 17 
 18           FILE *fd;
 19           int  c c2;
 20           int outch;
 21 
 22           if argc > 2 
 23                     fprintfstderr "Usage: termhl file-name\n";
 24                     exit1;
 25           
 26 
 27 
 28           ifargc == 2 
 29                     fd = fopenargv1 "r";
 30                     if fd == NULL 
 31                               perrorargv1;
 32                               exit2;
 33                     
 34            else 
 35                     fd = stdin;
 36           
 37 
 38      setuptermNULL1NULL;
 39 
 40 
 41           for ;; 
 42                     c = getcfd;
 43                     if c==EOF
 44                        break;
 45                     if c=='\\' 
 46                        c2 = getcfd;
 47                        switch c2 
 48                               case  'B':
 49                                     if enter_bold_mode == NULL 
 50                                        tputs enter_reverse_mode 1
 51                                              outch;
 52                                     else
 53                                         tputs enter_bold_mode 1
 54                                               outch;
 55                                     continue;
 56 
 57 
 58                               case  'U':
 59                                     tputs enter_underline_mode 1
 60                                           outch;
 61                                     ulmode = 1;
 62                                     continue;
 63                               case  'N':
 64                                     tputs exit_attribute_mode 1
 65                                           outch;
 66                                     ulmode = 0;
 67                                     continue;
 68                               
 69                          putch c;
 70                          putchc2;
 71                          
 72                     else
 73 
 74 
 75                               putchc;
 76           
 77 
 78           fclosefd;
 79           fflushstdout;
 80           resetterm;
 81           exit0;
 82 
 83 
 84 
 85 /*
 86  * This function is like putchar.
 87  */
 88 
 89 putchc
 90 int c;
 91 
 92           outchc;
 93 
 94 
 95 
 96 /*
 97  * Outchar is a function version of putchar that can be passed to
 98  * tputs as a routine to call.
 99  */
100 outchc
101 int c;
102 
103           putcharc;
104