2 /***************************************************************************
4 ****************************************************************************
5 * ncurses is copyright (C) 1992-1995 *
7 * zmbenhal@netcom.com *
9 * esr@snark.thyrsus.com *
11 * Permission is hereby granted to reproduce and distribute ncurses *
12 * by any means and for any fee, whether alone or as part of a *
13 * larger distribution, in source or in binary form, PROVIDED *
14 * this notice is included with any such distribution, and is not *
15 * removed from any of its header files. Mention of ncurses in any *
16 * applications linked with it is highly appreciated. *
18 * ncurses comes AS IS with no warranty, implied or expressed. *
20 ***************************************************************************/
23 * lib_tracedmp.c - Tracing/Debugging routines
27 #define TRACE /* turn on internal defs for this module */
30 #include <curses.priv.h>
32 MODULE_ID("$Id: lib_tracedmp.c,v 1.9 1997/01/15 00:39:27 tom Exp $")
34 void _tracedump(const char *name, WINDOW *win)
38 /* compute narrowest possible display width */
39 for (width = i = 0; i <= win->_maxy; i++)
42 for (j = 0; j <= win->_maxx; j++)
43 if (win->_line[i].text[j] != ' ')
49 if (width < win->_maxx)
52 for (n = 0; n <= win->_maxy; n++)
54 char buf[BUFSIZ], *ep;
55 bool haveattrs, havecolors;
57 /* dump A_CHARTEXT part */
58 (void) sprintf(buf, "%s[%2d] %3d%3d ='",
60 win->_line[n].firstchar,
61 win->_line[n].lastchar);
62 ep = buf + strlen(buf);
63 for (j = 0; j <= width; j++) {
64 ep[j] = TextOf(win->_line[n].text[j]);
72 /* dump A_COLOR part, will screw up if there are more than 96 */
74 for (j = 0; j <= width; j++)
75 if (win->_line[n].text[j] & A_COLOR)
82 (void) sprintf(buf, "%*s[%2d]%*s='", (int)strlen(name), "colors", n, 8, " ");
83 ep = buf + strlen(buf);
84 for (j = 0; j <= width; j++)
85 ep[j] = ((win->_line[n].text[j] >> 8) & 0xff) + ' ';
91 for (i = 0; i < 4; i++)
93 const char *hex = " 123456789ABCDEF";
94 chtype mask = (0xf << ((i + 4) * 4));
97 for (j = 0; j <= width; j++)
98 if (win->_line[n].text[j] & mask)
105 (void) sprintf(buf, "%*s%d[%2d]%*s='", (int)strlen(name)-1, "attrs", i, n, 8, " ");
106 ep = buf + strlen(buf);
107 for (j = 0; j <= width; j++)
108 ep[j] = hex[(win->_line[n].text[j] & mask) >> ((i + 4) * 4)];