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
39 #define TRACE /* turn on internal defs for this module */
42 #include <curses.priv.h>
44 MODULE_ID("$Id: lib_tracedmp.c,v 1.11 1998/02/11 12:14:00 tom Exp $")
46 void _tracedump(const char *name, WINDOW *win)
50 /* compute narrowest possible display width */
51 for (width = i = 0; i <= win->_maxy; i++)
54 for (j = 0; j <= win->_maxx; j++)
55 if (win->_line[i].text[j] != ' ')
61 if (width < win->_maxx)
64 for (n = 0; n <= win->_maxy; n++)
66 char buf[BUFSIZ], *ep;
67 bool haveattrs, havecolors;
69 /* dump A_CHARTEXT part */
70 (void) sprintf(buf, "%s[%2d] %3d%3d ='",
72 win->_line[n].firstchar,
73 win->_line[n].lastchar);
74 ep = buf + strlen(buf);
75 for (j = 0; j <= width; j++) {
76 ep[j] = TextOf(win->_line[n].text[j]);
84 /* dump A_COLOR part, will screw up if there are more than 96 */
86 for (j = 0; j <= width; j++)
87 if (win->_line[n].text[j] & A_COLOR)
94 (void) sprintf(buf, "%*s[%2d]%*s='", (int)strlen(name), "colors", n, 8, " ");
95 ep = buf + strlen(buf);
96 for (j = 0; j <= width; j++)
97 ep[j] = ((win->_line[n].text[j] >> 8) & 0xff) + ' ';
103 for (i = 0; i < 4; i++)
105 const char *hex = " 123456789ABCDEF";
106 chtype mask = (0xf << ((i + 4) * 4));
109 for (j = 0; j <= width; j++)
110 if (win->_line[n].text[j] & mask)
117 (void) sprintf(buf, "%*s%d[%2d]%*s='", (int)strlen(name)-1, "attrs", i, n, 8, " ");
118 ep = buf + strlen(buf);
119 for (j = 0; j <= width; j++)
120 ep[j] = hex[(win->_line[n].text[j] & mask) >> ((i + 4) * 4)];