trace.h revision 492d43a5
1492d43a5Smrg/* $XTermId: trace.h,v 1.55 2010/10/13 22:26:57 tom Exp $ */
2d522f475Smrg
320d2c4d2Smrg/*
4492d43a5Smrg *
520d2c4d2Smrg * Copyright 1997-2009,2010 by Thomas E. Dickey
6492d43a5Smrg *
720d2c4d2Smrg *                         All Rights Reserved
8492d43a5Smrg *
920d2c4d2Smrg * Permission is hereby granted, free of charge, to any person obtaining a
1020d2c4d2Smrg * copy of this software and associated documentation files (the
1120d2c4d2Smrg * "Software"), to deal in the Software without restriction, including
1220d2c4d2Smrg * without limitation the rights to use, copy, modify, merge, publish,
1320d2c4d2Smrg * distribute, sublicense, and/or sell copies of the Software, and to
1420d2c4d2Smrg * permit persons to whom the Software is furnished to do so, subject to
1520d2c4d2Smrg * the following conditions:
1620d2c4d2Smrg *
1720d2c4d2Smrg * The above copyright notice and this permission notice shall be included
1820d2c4d2Smrg * in all copies or substantial portions of the Software.
1920d2c4d2Smrg *
2020d2c4d2Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2120d2c4d2Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2220d2c4d2Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2320d2c4d2Smrg * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
2420d2c4d2Smrg * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2520d2c4d2Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2620d2c4d2Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2720d2c4d2Smrg *
2820d2c4d2Smrg * Except as contained in this notice, the name(s) of the above copyright
2920d2c4d2Smrg * holders shall not be used in advertising or otherwise to promote the
3020d2c4d2Smrg * sale, use or other dealings in this Software without prior written
3120d2c4d2Smrg * authorization.
32492d43a5Smrg *
3320d2c4d2Smrg */
34d522f475Smrg
35d522f475Smrg/*
36d522f475Smrg * Common/useful definitions for XTERM application
37d522f475Smrg */
38d522f475Smrg#ifndef	included_trace_h
39d522f475Smrg#define	included_trace_h
40d522f475Smrg
41d522f475Smrg#include <xterm.h>
42d522f475Smrg
43d522f475Smrg#if OPT_TRACE
44d522f475Smrg
45d522f475Smrgextern	void	Trace ( const char *, ... )
46d522f475Smrg#ifdef GCC_PRINTF
47d522f475Smrg	__attribute__ ((format(printf,1,2)))
48d522f475Smrg#endif
49d522f475Smrg	;
50956cc18dSsnj#undef  TRACE
51d522f475Smrg#define TRACE(p) Trace p
52d522f475Smrg
5320d2c4d2Smrgextern	void	TraceClose (void);
5420d2c4d2Smrg
5520d2c4d2Smrg#undef  TRACE_CLOSE
5620d2c4d2Smrg#define TRACE_CLOSE TraceClose
5720d2c4d2Smrg
58d522f475Smrg#if OPT_TRACE > 1
59d522f475Smrg#define TRACE2(p) Trace p
60d522f475Smrg#endif
61d522f475Smrg
6220d2c4d2Smrgextern	char *	visibleChars (const Char * /* buf */, unsigned /* len */);
63d522f475Smrgextern	char *	visibleIChar (IChar *, unsigned);
64956cc18dSsnjextern	char *	visibleIChars (IChar * /* buf */, unsigned /* len */);
6520d2c4d2Smrgextern	const char * visibleChrsetName(unsigned /* chrset */);
66d522f475Smrgextern	const char * visibleEventType (int);
6720d2c4d2Smrgextern	const char * visibleNotifyDetail(int /* code */);
68956cc18dSsnjextern	const char * visibleSelectionTarget(Display * /* d */, Atom /* a */);
69d522f475Smrgextern	const char * visibleXError (int /* code */);
70d522f475Smrg
71d522f475Smrgextern	void	TraceArgv(const char * /* tag */, char ** /* argv */);
72956cc18dSsnj#undef  TRACE_ARGV
73d522f475Smrg#define	TRACE_ARGV(tag,argv) TraceArgv(tag,argv)
74d522f475Smrg
7520d2c4d2Smrgextern	const	char *trace_who;
76956cc18dSsnj#undef  TRACE_CHILD
77d522f475Smrg#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child;
78d522f475Smrg
7920d2c4d2Smrgextern	void	TraceFocus(Widget, XEvent *);
8020d2c4d2Smrg#undef  TRACE_FOCUS
8120d2c4d2Smrg#define	TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e)
8220d2c4d2Smrg
83d522f475Smrgextern	void	TraceSizeHints(XSizeHints *);
84956cc18dSsnj#undef  TRACE_HINTS
85d522f475Smrg#define	TRACE_HINTS(hints) TraceSizeHints(hints)
86d522f475Smrg
872eaa94a1Schristosextern	void	TraceIds(const char * /* fname */, int  /* lnum */);
88956cc18dSsnj#undef  TRACE_IDS
89d522f475Smrg#define	TRACE_IDS TraceIds(__FILE__, __LINE__)
90d522f475Smrg
912eaa94a1Schristosextern	void	TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal  /* count */);
92956cc18dSsnj#undef  TRACE_OPTS
93d522f475Smrg#define	TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens)
94d522f475Smrg
95d522f475Smrgextern	void	TraceTranslations(const char *, Widget);
96956cc18dSsnj#undef  TRACE_TRANS
97d522f475Smrg#define	TRACE_TRANS(name,w) TraceTranslations(name,w)
98d522f475Smrg
99d522f475Smrgextern	void	TraceWMSizeHints(XtermWidget);
100956cc18dSsnj#undef  TRACE_WM_HINTS
101d522f475Smrg#define	TRACE_WM_HINTS(w) TraceWMSizeHints(w)
102d522f475Smrg
103d522f475Smrgextern	void	TraceXtermResources(void);
104956cc18dSsnj#undef  TRACE_XRES
105d522f475Smrg#define	TRACE_XRES() TraceXtermResources()
106d522f475Smrg
1072eaa94a1Schristosextern	int	TraceResizeRequest(const char * /* fn */, int  /* ln */, Widget  /* w */, Dimension  /* reqwide */, Dimension  /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */);
108956cc18dSsnj#undef  REQ_RESIZE
1092eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
11020d2c4d2Smrg	TraceResizeRequest(__FILE__, __LINE__, w, \
11120d2c4d2Smrg			   (Dimension) (reqwide), (Dimension) (reqhigh), \
11220d2c4d2Smrg			   (gotwide), (gothigh))
1132eaa94a1Schristos
1142eaa94a1Schristos#else
1152eaa94a1Schristos
1162eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
1172eaa94a1Schristos	XtMakeResizeRequest((Widget) (w), \
1182eaa94a1Schristos			    (Dimension) (reqwide), (Dimension) (reqhigh), \
1192eaa94a1Schristos			    (gotwide), (gothigh))
1202eaa94a1Schristos
121d522f475Smrg#endif
122d522f475Smrg
123492d43a5Smrg/*
124492d43a5Smrg * The whole wnew->screen struct is zeroed in VTInitialize.  Use these macros
125492d43a5Smrg * where applicable for copying the pieces from the request widget into the
126492d43a5Smrg * new widget.  We do not have to use them for wnew->misc, but the associated
127492d43a5Smrg * traces are very useful for debugging.
128492d43a5Smrg */
129492d43a5Smrg#if OPT_TRACE
130492d43a5Smrg#define init_Bres(name) \
131492d43a5Smrg	TRACE(("init " #name " = %s\n", \
132492d43a5Smrg		BtoS(wnew->name = request->name)))
133492d43a5Smrg#define init_Dres2(name,i) \
134492d43a5Smrg	TRACE(("init " #name "[%d] = %f\n", i, \
135492d43a5Smrg		wnew->name[i] = request->name[i]))
136492d43a5Smrg#define init_Ires(name) \
137492d43a5Smrg	TRACE(("init " #name " = %d\n", \
138492d43a5Smrg		wnew->name = request->name))
139492d43a5Smrg#define init_Sres(name) \
140492d43a5Smrg	TRACE(("init " #name " = \"%s\"\n", \
141492d43a5Smrg		(wnew->name = x_strtrim(request->name)) != NULL \
142492d43a5Smrg			? wnew->name : "<null>"))
143492d43a5Smrg#define init_Sres2(name,i) \
144492d43a5Smrg	TRACE(("init " #name "[%d] = \"%s\"\n", i, \
145492d43a5Smrg		(wnew->name(i) = x_strtrim(request->name(i))) != NULL \
146492d43a5Smrg			? wnew->name(i) : "<null>"))
147492d43a5Smrg#define init_Tres(offset) \
148492d43a5Smrg	TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \
149492d43a5Smrg		fill_Tres(wnew, request, offset)))
150492d43a5Smrg#else
151492d43a5Smrg#define init_Bres(name)    wnew->name = request->name
152492d43a5Smrg#define init_Dres2(name,i) wnew->name[i] = request->name[i]
153492d43a5Smrg#define init_Ires(name)    wnew->name = request->name
154492d43a5Smrg#define init_Sres(name)    wnew->name = x_strtrim(request->name)
155492d43a5Smrg#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i))
156492d43a5Smrg#define init_Tres(offset)  fill_Tres(wnew, request, offset)
157492d43a5Smrg#endif
158492d43a5Smrg
159492d43a5Smrg
160d522f475Smrg#endif	/* included_trace_h */
161