1
1
/****************************************************************************
2
* Copyright (c) 1998-2002,2005 Free Software Foundation, Inc. *
2
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
4
4
* Permission is hereby granted, free of charge, to any person obtaining a *
5
5
* copy of this software and associated documentation files (the *
39
39
#include <curses.priv.h>
42
MODULE_ID("$Id: lib_tracedmp.c,v 1.26 2005/01/29 16:23:51 tom Exp $")
42
MODULE_ID("$Id: lib_tracedmp.c,v 1.31 2008/08/16 19:30:56 tom Exp $")
46
#define my_buffer _nc_globals.tracedmp_buf
47
#define my_length _nc_globals.tracedmp_used
45
49
NCURSES_EXPORT(void)
46
50
_tracedump(const char *name, WINDOW *win)
49
static size_t used = 0;
51
52
int i, j, n, width;
53
54
/* compute narrowest possible display width */
67
68
if (width < win->_maxx)
69
if (++width + 1 > (int) used) {
70
used = 2 * (width + 1);
71
buf = typeRealloc(char, used, buf);
70
if (++width + 1 > (int) my_length) {
71
my_length = 2 * (width + 1);
72
my_buffer = typeRealloc(char, my_length, my_buffer);
74
75
for (n = 0; n <= win->_maxy; ++n) {
76
77
bool haveattrs, havecolors;
83
84
for (j = 0; j < width; ++j) {
84
85
chtype test = CharOf(win->_line[n].text[j]);
85
ep[j] = (UChar(test) == test
86
ep[j] = (char) ((UChar(test) == test
86
87
#if USE_WIDEC_SUPPORT
87
&& (win->_line[n].text[j].chars[1] == 0)
88
&& (win->_line[n].text[j].chars[1] == 0)
90
? (iscntrl(UChar(test))
91
? (iscntrl(UChar(test))
96
_tracef("%s[%2d] %3d%3d ='%s'",
97
_tracef("%s[%2d] %3ld%3ld ='%s'",
98
win->_line[n].firstchar,
99
win->_line[n].lastchar,
99
(long) win->_line[n].firstchar,
100
(long) win->_line[n].lastchar,
103
/* if there are multi-column characters on the line, print them now */
105
bool multicolumn = FALSE;
106
for (j = 0; j < width; ++j)
107
if (WidecExt(win->_line[n].text[j]) != 0) {
113
for (j = 0; j < width; ++j) {
114
int test = WidecExt(win->_line[n].text[j]);
116
ep[j] = (char) (test + '0');
122
_tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
123
"widec", n, 8, " ", my_buffer);
102
127
/* dump A_COLOR part, will screw up if there are more than 96 */
103
128
havecolors = FALSE;
104
129
for (j = 0; j < width; ++j)
109
134
if (havecolors) {
111
136
for (j = 0; j < width; ++j) {
112
137
int pair = GetPair(win->_line[n].text[j]);
115
140
else if (pair >= 36)
141
ep[j] = (char) (pair + 'A');
117
142
else if (pair >= 10)
143
ep[j] = (char) (pair + 'a');
119
144
else if (pair >= 1)
145
ep[j] = (char) (pair + '0');
125
150
_tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
126
"colors", n, 8, " ", buf);
151
"colors", n, 8, " ", my_buffer);
129
154
for (i = 0; i < 4; ++i) {
141
166
for (j = 0; j < width; ++j)
142
167
ep[j] = hex[(AttrOf(win->_line[n].text[j]) & mask) >>
145
170
_tracef("%*s%d[%2d]%*s='%s'", (int) strlen(name) -
146
1, "attrs", i, n, 8, " ", buf);
171
1, "attrs", i, n, 8, " ", my_buffer);
158
empty_module(_nc_lib_tracedmp)
183
EMPTY_MODULE(_nc_lib_tracedmp)
159
184
#endif /* TRACE */