1 /****************************************************************************
2 * Copyright (c) 1998 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 ****************************************************************************/
37 * lib_traceatr.c - Tracing/Debugging routines (attributes)
40 #include <curses.priv.h>
41 #include <term.h> /* acs_chars */
43 MODULE_ID("$Id: lib_traceatr.c,v 1.28 1998/03/21 18:39:36 tom Exp $")
45 #define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
48 char *_traceattr2(int bufnum, attr_t newmode)
50 char *buf = _nc_trace_buf(bufnum, BUFSIZ);
52 static const struct {unsigned int val; const char *name;}
55 { A_STANDOUT, "A_STANDOUT" },
56 { A_UNDERLINE, "A_UNDERLINE" },
57 { A_REVERSE, "A_REVERSE" },
58 { A_BLINK, "A_BLINK" },
61 { A_ALTCHARSET, "A_ALTCHARSET" },
62 { A_INVIS, "A_INVIS" },
63 { A_PROTECT, "A_PROTECT" },
64 { A_CHARTEXT, "A_CHARTEXT" },
65 { A_NORMAL, "A_NORMAL" },
66 { A_COLOR, "A_COLOR" },
70 { COLOR_BLACK, "COLOR_BLACK" },
71 { COLOR_RED, "COLOR_RED" },
72 { COLOR_GREEN, "COLOR_GREEN" },
73 { COLOR_YELLOW, "COLOR_YELLOW" },
74 { COLOR_BLUE, "COLOR_BLUE" },
75 { COLOR_MAGENTA, "COLOR_MAGENTA" },
76 { COLOR_CYAN, "COLOR_CYAN" },
77 { COLOR_WHITE, "COLOR_WHITE" },
80 unsigned save_nc_tracing = _nc_tracing;
85 for (n = 0; n < SIZEOF(names); n++) {
86 if ((newmode & names[n].val) != 0) {
89 strcat(tmp, names[n].name);
92 if (names[n].val == A_COLOR)
94 short pairnum = PAIR_NUMBER(newmode);
97 if (pair_content(pairnum, &fg, &bg) == OK)
105 (void) sprintf(tmp, "{%d}", pairnum);
109 if (AttrOf(newmode) == A_NORMAL) {
112 strcat(tmp, "A_NORMAL");
115 _nc_tracing = save_nc_tracing;
116 return (strcat(buf,"}"));
119 char *_traceattr(attr_t newmode)
121 return _traceattr2(0, newmode);
124 /* Trace 'int' return-values */
125 attr_t _nc_retrace_attr_t(attr_t code)
127 T((T_RETURN("%s"), _traceattr(code)));
131 char *_tracechtype2(int bufnum, chtype ch)
133 char *buf = _nc_trace_buf(bufnum, BUFSIZ);
137 if (ch & A_ALTCHARSET)
140 static const struct {unsigned int val; const char *name;}
143 {'l', "ACS_ULCORNER"}, /* upper left corner */
144 {'m', "ACS_LLCORNER"}, /* lower left corner */
145 {'k', "ACS_URCORNER"}, /* upper right corner */
146 {'j', "ACS_LRCORNER"}, /* lower right corner */
147 {'t', "ACS_LTEE"}, /* tee pointing right */
148 {'u', "ACS_RTEE"}, /* tee pointing left */
149 {'v', "ACS_BTEE"}, /* tee pointing up */
150 {'w', "ACS_TTEE"}, /* tee pointing down */
151 {'q', "ACS_HLINE"}, /* horizontal line */
152 {'x', "ACS_VLINE"}, /* vertical line */
153 {'n', "ACS_PLUS"}, /* large plus or crossover */
154 {'o', "ACS_S1"}, /* scan line 1 */
155 {'s', "ACS_S9"}, /* scan line 9 */
156 {'`', "ACS_DIAMOND"}, /* diamond */
157 {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
158 {'f', "ACS_DEGREE"}, /* degree symbol */
159 {'g', "ACS_PLMINUS"}, /* plus/minus */
160 {'~', "ACS_BULLET"}, /* bullet */
161 {',', "ACS_LARROW"}, /* arrow pointing left */
162 {'+', "ACS_RARROW"}, /* arrow pointing right */
163 {'.', "ACS_DARROW"}, /* arrow pointing down */
164 {'-', "ACS_UARROW"}, /* arrow pointing up */
165 {'h', "ACS_BOARD"}, /* board of squares */
166 {'i', "ACS_LANTERN"}, /* lantern symbol */
167 {'0', "ACS_BLOCK"}, /* solid square block */
168 {'p', "ACS_S3"}, /* scan line 3 */
169 {'r', "ACS_S7"}, /* scan line 7 */
170 {'y', "ACS_LEQUAL"}, /* less/equal */
171 {'z', "ACS_GEQUAL"}, /* greater/equal */
172 {'{', "ACS_PI"}, /* Pi */
173 {'|', "ACS_NEQUAL"}, /* not equal */
174 {'}', "ACS_STERLING"}, /* UK pound sign */
179 for (cp = acs_chars; cp[0] && cp[1]; cp += 2)
181 if (TextOf(cp[1]) == TextOf(ch))
184 /* don't exit from loop - there may be redefinitions */
191 for (sp = names; sp->val; sp++)
194 (void) strcat(buf, sp->name);
202 (void) strcat(buf, _tracechar(TextOf(ch)));
204 if (AttrOf(ch) != A_NORMAL)
205 (void) sprintf(buf + strlen(buf), " | %s", _traceattr2(bufnum+20,AttrOf(ch)));
211 char *_tracechtype(chtype ch)
213 return _tracechtype2(0, ch);
216 extern void _nc_lib_traceatr(void);
217 void _nc_lib_traceatr(void) { }