]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_acs.c
ncurses 4.2
[ncurses.git] / ncurses / lib_acs.c
1 /****************************************************************************
2  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32  ****************************************************************************/
33
34
35
36 #include <curses.priv.h>
37 #include <term.h>       /* ena_acs, acs_chars */
38
39 MODULE_ID("$Id: lib_acs.c,v 1.13 1998/02/11 12:13:57 tom Exp $")
40
41 chtype acs_map[ACS_LEN];
42
43 void init_acs(void)
44 {
45         T(("initializing ACS map"));
46
47         /*
48          * Initializations for a UNIX-like multi-terminal environment.  Use
49          * ASCII chars and count on the terminfo description to do better.
50          */
51         ACS_ULCORNER = '+';     /* should be upper left corner */
52         ACS_LLCORNER = '+';     /* should be lower left corner */
53         ACS_URCORNER = '+';     /* should be upper right corner */
54         ACS_LRCORNER = '+';     /* should be lower right corner */
55         ACS_RTEE     = '+';     /* should be tee pointing left */
56         ACS_LTEE     = '+';     /* should be tee pointing right */
57         ACS_BTEE     = '+';     /* should be tee pointing up */
58         ACS_TTEE     = '+';     /* should be tee pointing down */
59         ACS_HLINE    = '-';     /* should be horizontal line */
60         ACS_VLINE    = '|';     /* should be vertical line */
61         ACS_PLUS     = '+';     /* should be large plus or crossover */
62         ACS_S1       = '~';     /* should be scan line 1 */
63         ACS_S9       = '_';     /* should be scan line 9 */
64         ACS_DIAMOND  = '+';     /* should be diamond */
65         ACS_CKBOARD  = ':';     /* should be checker board (stipple) */
66         ACS_DEGREE   = '\'';    /* should be degree symbol */
67         ACS_PLMINUS  = '#';     /* should be plus/minus */
68         ACS_BULLET   = 'o';     /* should be bullet */
69         ACS_LARROW   = '<';     /* should be arrow pointing left */
70         ACS_RARROW   = '>';     /* should be arrow pointing right */
71         ACS_DARROW   = 'v';     /* should be arrow pointing down */
72         ACS_UARROW   = '^';     /* should be arrow pointing up */
73         ACS_BOARD    = '#';     /* should be board of squares */
74         ACS_LANTERN  = '#';     /* should be lantern symbol */
75         ACS_BLOCK    = '#';     /* should be solid square block */
76         /* these defaults were invented for ncurses */
77         ACS_S3       = '-';     /* should be scan line 3 */
78         ACS_S7       = '-';     /* should be scan line 7 */
79         ACS_LEQUAL   = '<';     /* should be less-than-or-equal-to */
80         ACS_GEQUAL   = '>';     /* should be greater-than-or-equal-to */
81         ACS_PI       = '*';     /* should be greek pi */
82         ACS_NEQUAL   = '!';     /* should be not-equal */
83         ACS_STERLING = 'f';     /* should be pound-sterling symbol */
84
85 #ifdef ena_acs
86         if (ena_acs != NULL)
87         {
88                 TPUTS_TRACE("ena_acs");
89                 putp(ena_acs);
90         }
91 #endif /* ena_acs */
92
93 #ifdef acs_chars
94 #define ALTCHAR(c)      ((chtype)(((unsigned char)(c)) | A_ALTCHARSET))
95
96         if (acs_chars != NULL) {
97             size_t i = 0;
98             size_t length = strlen(acs_chars);
99
100                 while (i < length)
101                         switch (acs_chars[i]) {
102                         case 'l':case 'm':case 'k':case 'j':
103                         case 'u':case 't':case 'v':case 'w':
104                         case 'q':case 'x':case 'n':case 'o':
105                         case 's':case '`':case 'a':case 'f':
106                         case 'g':case '~':case ',':case '+':
107                         case '.':case '-':case 'h':case 'i':
108                         case '0':case 'p':case 'r':case 'y':
109                         case 'z':case '{':case '|':case '}':
110                                 acs_map[(unsigned int)acs_chars[i]] =
111                                         ALTCHAR(acs_chars[i+1]);
112                                 i++;
113                                 /* FALLTHRU */
114                         default:
115                                 i++;
116                                 break;
117                         }
118         }
119 #ifdef TRACE
120         /* Show the equivalent mapping, noting if it does not match the
121          * given attribute, whether by re-ordering or duplication.
122          */
123         if (_nc_tracing & TRACE_CALLS) {
124                 size_t n, m;
125                 char show[SIZEOF(acs_map) + 1];
126                 for (n = 1, m = 0; n < SIZEOF(acs_map); n++) {
127                         if (acs_map[n] != 0) {
128                                 show[m++] = (char)n;
129                                 show[m++] = TextOf(acs_map[n]);
130                         }
131                 }
132                 show[m] = 0;
133                 _tracef("%s acs_chars %s",
134                         (acs_chars == NULL)
135                         ? "NULL"
136                         : (strcmp(acs_chars, show)
137                                 ? "DIFF"
138                                 : "SAME"),
139                         _nc_visbuf(show));
140         }
141 #endif /* TRACE */
142 #endif /* acs_char */
143 }
144