1 /****************************************************************************
2 * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
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: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
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. *
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 *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 ****************************************************************************/
35 * lib_traceatr.c - Tracing/Debugging routines (attributes)
38 #include <curses.priv.h>
39 #include <term.h> /* acs_chars */
41 MODULE_ID("$Id: lib_traceatr.c,v 1.30 2000/07/29 18:06:09 tom Exp $")
43 #define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
47 _traceattr2(int bufnum, attr_t newmode)
49 char *buf = _nc_trace_buf(bufnum, BUFSIZ);
57 { A_STANDOUT, "A_STANDOUT" },
58 { A_UNDERLINE, "A_UNDERLINE" },
59 { A_REVERSE, "A_REVERSE" },
60 { A_BLINK, "A_BLINK" },
63 { A_ALTCHARSET, "A_ALTCHARSET" },
64 { A_INVIS, "A_INVIS" },
65 { A_PROTECT, "A_PROTECT" },
66 { A_CHARTEXT, "A_CHARTEXT" },
67 { A_NORMAL, "A_NORMAL" },
68 { A_COLOR, "A_COLOR" },
75 { COLOR_BLACK, "COLOR_BLACK" },
76 { COLOR_RED, "COLOR_RED" },
77 { COLOR_GREEN, "COLOR_GREEN" },
78 { COLOR_YELLOW, "COLOR_YELLOW" },
79 { COLOR_BLUE, "COLOR_BLUE" },
80 { COLOR_MAGENTA, "COLOR_MAGENTA" },
81 { COLOR_CYAN, "COLOR_CYAN" },
82 { COLOR_WHITE, "COLOR_WHITE" },
87 unsigned save_nc_tracing = _nc_tracing;
92 for (n = 0; n < SIZEOF(names); n++) {
93 if ((newmode & names[n].val) != 0) {
96 strcat(tmp, names[n].name);
99 if (names[n].val == A_COLOR) {
100 short pairnum = PAIR_NUMBER(newmode);
103 if (pair_content(pairnum, &fg, &bg) == OK)
111 (void) sprintf(tmp, "{%d}", pairnum);
115 if (AttrOf(newmode) == A_NORMAL) {
118 strcat(tmp, "A_NORMAL");
121 _nc_tracing = save_nc_tracing;
122 return (strcat(buf, "}"));
126 _traceattr(attr_t newmode)
128 return _traceattr2(0, newmode);
131 /* Trace 'int' return-values */
133 _nc_retrace_attr_t(attr_t code)
135 T((T_RETURN("%s"), _traceattr(code)));
140 _tracechtype2(int bufnum, chtype ch)
142 char *buf = _nc_trace_buf(bufnum, BUFSIZ);
146 if (ch & A_ALTCHARSET) {
148 static const struct {
154 { 'l', "ACS_ULCORNER" }, /* upper left corner */
155 { 'm', "ACS_LLCORNER" }, /* lower left corner */
156 { 'k', "ACS_URCORNER" }, /* upper right corner */
157 { 'j', "ACS_LRCORNER" }, /* lower right corner */
158 { 't', "ACS_LTEE" }, /* tee pointing right */
159 { 'u', "ACS_RTEE" }, /* tee pointing left */
160 { 'v', "ACS_BTEE" }, /* tee pointing up */
161 { 'w', "ACS_TTEE" }, /* tee pointing down */
162 { 'q', "ACS_HLINE" }, /* horizontal line */
163 { 'x', "ACS_VLINE" }, /* vertical line */
164 { 'n', "ACS_PLUS" }, /* large plus or crossover */
165 { 'o', "ACS_S1" }, /* scan line 1 */
166 { 's', "ACS_S9" }, /* scan line 9 */
167 { '`', "ACS_DIAMOND" }, /* diamond */
168 { 'a', "ACS_CKBOARD" }, /* checker board (stipple) */
169 { 'f', "ACS_DEGREE" }, /* degree symbol */
170 { 'g', "ACS_PLMINUS" }, /* plus/minus */
171 { '~', "ACS_BULLET" }, /* bullet */
172 { ',', "ACS_LARROW" }, /* arrow pointing left */
173 { '+', "ACS_RARROW" }, /* arrow pointing right */
174 { '.', "ACS_DARROW" }, /* arrow pointing down */
175 { '-', "ACS_UARROW" }, /* arrow pointing up */
176 { 'h', "ACS_BOARD" }, /* board of squares */
177 { 'i', "ACS_LANTERN" }, /* lantern symbol */
178 { '0', "ACS_BLOCK" }, /* solid square block */
179 { 'p', "ACS_S3" }, /* scan line 3 */
180 { 'r', "ACS_S7" }, /* scan line 7 */
181 { 'y', "ACS_LEQUAL" }, /* less/equal */
182 { 'z', "ACS_GEQUAL" }, /* greater/equal */
183 { '{', "ACS_PI" }, /* Pi */
184 { '|', "ACS_NEQUAL" }, /* not equal */
185 { '}', "ACS_STERLING" }, /* UK pound sign */
191 for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
192 if (TextOf(cp[1]) == TextOf(ch)) {
194 /* don't exit from loop - there may be redefinitions */
200 for (sp = names; sp->val; sp++)
202 (void) strcat(buf, sp->name);
210 (void) strcat(buf, _tracechar(TextOf(ch)));
212 if (AttrOf(ch) != A_NORMAL)
213 (void) sprintf(buf + strlen(buf), " | %s",
214 _traceattr2(bufnum + 20, AttrOf(ch)));
221 _tracechtype(chtype ch)
223 return _tracechtype2(0, ch);
226 /* Trace 'chtype' return-values */
228 _nc_retrace_chtype(attr_t code)
230 T((T_RETURN("%s"), _tracechtype(code)));
235 extern void _nc_lib_traceatr(void);
237 _nc_lib_traceatr(void)