]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_acs.c
ncurses 4.1
[ncurses.git] / ncurses / lib_acs.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22
23
24 #include <curses.priv.h>
25 #include <term.h>       /* ena_acs, acs_chars */
26
27 MODULE_ID("$Id: lib_acs.c,v 1.8 1997/04/24 11:04:07 tom Exp $")
28
29 chtype acs_map[128];
30
31 void init_acs(void)
32 {
33         T(("initializing ACS map"));
34
35         /*
36          * Initializations for a UNIX-like multi-terminal environment.  Use
37          * ASCII chars and count on the terminfo description to do better.
38          */
39         ACS_ULCORNER = '+';     /* should be upper left corner */
40         ACS_LLCORNER = '+';     /* should be lower left corner */
41         ACS_URCORNER = '+';     /* should be upper right corner */
42         ACS_LRCORNER = '+';     /* should be lower right corner */
43         ACS_RTEE     = '+';     /* should be tee pointing left */
44         ACS_LTEE     = '+';     /* should be tee pointing right */
45         ACS_BTEE     = '+';     /* should be tee pointing up */
46         ACS_TTEE     = '+';     /* should be tee pointing down */
47         ACS_HLINE    = '-';     /* should be horizontal line */
48         ACS_VLINE    = '|';     /* should be vertical line */
49         ACS_PLUS     = '+';     /* should be large plus or crossover */
50         ACS_S1       = '~';     /* should be scan line 1 */
51         ACS_S9       = '_';     /* should be scan line 9 */
52         ACS_DIAMOND  = '+';     /* should be diamond */
53         ACS_CKBOARD  = ':';     /* should be checker board (stipple) */
54         ACS_DEGREE   = '\'';    /* should be degree symbol */
55         ACS_PLMINUS  = '#';     /* should be plus/minus */
56         ACS_BULLET   = 'o';     /* should be bullet */
57         ACS_LARROW   = '<';     /* should be arrow pointing left */
58         ACS_RARROW   = '>';     /* should be arrow pointing right */
59         ACS_DARROW   = 'v';     /* should be arrow pointing down */
60         ACS_UARROW   = '^';     /* should be arrow pointing up */
61         ACS_BOARD    = '#';     /* should be board of squares */
62         ACS_LANTERN  = '#';     /* should be lantern symbol */
63         ACS_BLOCK    = '#';     /* should be solid square block */
64         /* these defaults were invented for ncurses */
65         ACS_S3       = '-';     /* should be scan line 3 */
66         ACS_S7       = '-';     /* should be scan line 7 */
67         ACS_LEQUAL   = '<';     /* should be less-than-or-equal-to */
68         ACS_GEQUAL   = '>';     /* should be greater-than-or-equal-to */
69         ACS_PI       = '*';     /* should be greek pi */
70         ACS_NEQUAL   = '!';     /* should be not-equal */
71         ACS_STERLING = 'f';     /* should be pound-sterling symbol */
72
73 #ifdef ena_acs
74         if (ena_acs != NULL)
75         {
76                 TPUTS_TRACE("ena_acs");
77                 putp(ena_acs);
78         }
79 #endif /* ena_acs */
80
81 #ifdef acs_chars
82 #define ALTCHAR(c)      (TextOf(c) | A_ALTCHARSET)
83
84         if (acs_chars != NULL) {
85             size_t i = 0;
86             size_t length = strlen(acs_chars);
87
88                 while (i < length)
89                         switch (acs_chars[i]) {
90                         case 'l':case 'm':case 'k':case 'j':
91                         case 'u':case 't':case 'v':case 'w':
92                         case 'q':case 'x':case 'n':case 'o':
93                         case 's':case '`':case 'a':case 'f':
94                         case 'g':case '~':case ',':case '+':
95                         case '.':case '-':case 'h':case 'I':
96                         case '0':case 'p':case 'r':case 'y':
97                         case 'z':case '{':case '|':case '}':
98                                 acs_map[(unsigned int)acs_chars[i]] =
99                                         ALTCHAR(acs_chars[i+1]);
100                                 i++;
101                                 /* FALLTHRU */
102                         default:
103                                 i++;
104                                 break;
105                         }
106         }
107 #ifdef TRACE
108 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
109         /* Show the equivalent mapping, noting if it does not match the
110          * given attribute, whether by re-ordering or duplication.
111          */
112         if (_nc_tracing & TRACE_CALLS) {
113                 size_t n, m;
114                 char show[SIZEOF(acs_map) + 1];
115                 for (n = 1, m = 0; n < SIZEOF(acs_map); n++) {
116                         if (acs_map[n] != 0) {
117                                 show[m++] = (char)n;
118                                 show[m++] = TextOf(acs_map[n]);
119                         }
120                 }
121                 show[m] = 0;
122                 _tracef("%s acs_chars %s",
123                         (acs_chars == NULL)
124                         ? "NULL"
125                         : (strcmp(acs_chars, show)
126                                 ? "DIFF"
127                                 : "SAME"),
128                         _nc_visbuf(show));
129         }
130 #endif /* TRACE */
131 #endif /* acs_char */
132 }
133