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 ****************************************************************************/
35 * lib_tracedmp.c - Tracing/Debugging routines
38 #include <curses.priv.h>
40 MODULE_ID("$Id: lib_tracedmp.c,v 1.13 1998/03/21 18:39:44 tom Exp $")
43 void _tracedump(const char *name, WINDOW *win)
47 /* compute narrowest possible display width */
48 for (width = i = 0; i <= win->_maxy; i++)
51 for (j = 0; j <= win->_maxx; j++)
52 if (win->_line[i].text[j] != ' ')
58 if (width < win->_maxx)
61 for (n = 0; n <= win->_maxy; n++)
63 char buf[BUFSIZ], *ep;
64 bool haveattrs, havecolors;
66 /* dump A_CHARTEXT part */
67 (void) sprintf(buf, "%s[%2d] %3d%3d ='",
69 win->_line[n].firstchar,
70 win->_line[n].lastchar);
71 ep = buf + strlen(buf);
72 for (j = 0; j <= width; j++) {
73 ep[j] = TextOf(win->_line[n].text[j]);
81 /* dump A_COLOR part, will screw up if there are more than 96 */
83 for (j = 0; j <= width; j++)
84 if (win->_line[n].text[j] & A_COLOR)
91 (void) sprintf(buf, "%*s[%2d]%*s='", (int)strlen(name), "colors", n, 8, " ");
92 ep = buf + strlen(buf);
93 for (j = 0; j <= width; j++)
94 ep[j] = ((win->_line[n].text[j] >> 8) & 0xff) + ' ';
100 for (i = 0; i < 4; i++)
102 const char *hex = " 123456789ABCDEF";
103 chtype mask = (0xf << ((i + 4) * 4));
106 for (j = 0; j <= width; j++)
107 if (win->_line[n].text[j] & mask)
114 (void) sprintf(buf, "%*s%d[%2d]%*s='", (int)strlen(name)-1, "attrs", i, n, 8, " ");
115 ep = buf + strlen(buf);
116 for (j = 0; j <= width; j++)
117 ep[j] = hex[(win->_line[n].text[j] & mask) >> ((i + 4) * 4)];
126 extern void _nc_lib_tracedmp(void);
127 void _nc_lib_tracedmp(void) { }