trace.h revision 6879286f
16879286fSmrg/* $XTermId: trace.h,v 1.56 2010/11/11 01:10:52 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
456879286fSmrgextern	void	Trace ( const char *, ... ) GCC_PRINTFLIKE(1,2);
466879286fSmrg
47956cc18dSsnj#undef  TRACE
48d522f475Smrg#define TRACE(p) Trace p
49d522f475Smrg
5020d2c4d2Smrgextern	void	TraceClose (void);
5120d2c4d2Smrg
5220d2c4d2Smrg#undef  TRACE_CLOSE
5320d2c4d2Smrg#define TRACE_CLOSE TraceClose
5420d2c4d2Smrg
55d522f475Smrg#if OPT_TRACE > 1
56d522f475Smrg#define TRACE2(p) Trace p
57d522f475Smrg#endif
58d522f475Smrg
5920d2c4d2Smrgextern	char *	visibleChars (const Char * /* buf */, unsigned /* len */);
60d522f475Smrgextern	char *	visibleIChar (IChar *, unsigned);
61956cc18dSsnjextern	char *	visibleIChars (IChar * /* buf */, unsigned /* len */);
6220d2c4d2Smrgextern	const char * visibleChrsetName(unsigned /* chrset */);
63d522f475Smrgextern	const char * visibleEventType (int);
6420d2c4d2Smrgextern	const char * visibleNotifyDetail(int /* code */);
65956cc18dSsnjextern	const char * visibleSelectionTarget(Display * /* d */, Atom /* a */);
66d522f475Smrgextern	const char * visibleXError (int /* code */);
67d522f475Smrg
68d522f475Smrgextern	void	TraceArgv(const char * /* tag */, char ** /* argv */);
69956cc18dSsnj#undef  TRACE_ARGV
70d522f475Smrg#define	TRACE_ARGV(tag,argv) TraceArgv(tag,argv)
71d522f475Smrg
7220d2c4d2Smrgextern	const	char *trace_who;
73956cc18dSsnj#undef  TRACE_CHILD
74d522f475Smrg#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child;
75d522f475Smrg
7620d2c4d2Smrgextern	void	TraceFocus(Widget, XEvent *);
7720d2c4d2Smrg#undef  TRACE_FOCUS
7820d2c4d2Smrg#define	TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e)
7920d2c4d2Smrg
80d522f475Smrgextern	void	TraceSizeHints(XSizeHints *);
81956cc18dSsnj#undef  TRACE_HINTS
82d522f475Smrg#define	TRACE_HINTS(hints) TraceSizeHints(hints)
83d522f475Smrg
842eaa94a1Schristosextern	void	TraceIds(const char * /* fname */, int  /* lnum */);
85956cc18dSsnj#undef  TRACE_IDS
86d522f475Smrg#define	TRACE_IDS TraceIds(__FILE__, __LINE__)
87d522f475Smrg
882eaa94a1Schristosextern	void	TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal  /* count */);
89956cc18dSsnj#undef  TRACE_OPTS
90d522f475Smrg#define	TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens)
91d522f475Smrg
92d522f475Smrgextern	void	TraceTranslations(const char *, Widget);
93956cc18dSsnj#undef  TRACE_TRANS
94d522f475Smrg#define	TRACE_TRANS(name,w) TraceTranslations(name,w)
95d522f475Smrg
96d522f475Smrgextern	void	TraceWMSizeHints(XtermWidget);
97956cc18dSsnj#undef  TRACE_WM_HINTS
98d522f475Smrg#define	TRACE_WM_HINTS(w) TraceWMSizeHints(w)
99d522f475Smrg
100d522f475Smrgextern	void	TraceXtermResources(void);
101956cc18dSsnj#undef  TRACE_XRES
102d522f475Smrg#define	TRACE_XRES() TraceXtermResources()
103d522f475Smrg
1042eaa94a1Schristosextern	int	TraceResizeRequest(const char * /* fn */, int  /* ln */, Widget  /* w */, Dimension  /* reqwide */, Dimension  /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */);
105956cc18dSsnj#undef  REQ_RESIZE
1062eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
10720d2c4d2Smrg	TraceResizeRequest(__FILE__, __LINE__, w, \
10820d2c4d2Smrg			   (Dimension) (reqwide), (Dimension) (reqhigh), \
10920d2c4d2Smrg			   (gotwide), (gothigh))
1102eaa94a1Schristos
1112eaa94a1Schristos#else
1122eaa94a1Schristos
1132eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
1142eaa94a1Schristos	XtMakeResizeRequest((Widget) (w), \
1152eaa94a1Schristos			    (Dimension) (reqwide), (Dimension) (reqhigh), \
1162eaa94a1Schristos			    (gotwide), (gothigh))
1172eaa94a1Schristos
118d522f475Smrg#endif
119d522f475Smrg
120492d43a5Smrg/*
121492d43a5Smrg * The whole wnew->screen struct is zeroed in VTInitialize.  Use these macros
122492d43a5Smrg * where applicable for copying the pieces from the request widget into the
123492d43a5Smrg * new widget.  We do not have to use them for wnew->misc, but the associated
124492d43a5Smrg * traces are very useful for debugging.
125492d43a5Smrg */
126492d43a5Smrg#if OPT_TRACE
127492d43a5Smrg#define init_Bres(name) \
128492d43a5Smrg	TRACE(("init " #name " = %s\n", \
129492d43a5Smrg		BtoS(wnew->name = request->name)))
130492d43a5Smrg#define init_Dres2(name,i) \
131492d43a5Smrg	TRACE(("init " #name "[%d] = %f\n", i, \
132492d43a5Smrg		wnew->name[i] = request->name[i]))
133492d43a5Smrg#define init_Ires(name) \
134492d43a5Smrg	TRACE(("init " #name " = %d\n", \
135492d43a5Smrg		wnew->name = request->name))
136492d43a5Smrg#define init_Sres(name) \
137492d43a5Smrg	TRACE(("init " #name " = \"%s\"\n", \
138492d43a5Smrg		(wnew->name = x_strtrim(request->name)) != NULL \
139492d43a5Smrg			? wnew->name : "<null>"))
140492d43a5Smrg#define init_Sres2(name,i) \
141492d43a5Smrg	TRACE(("init " #name "[%d] = \"%s\"\n", i, \
142492d43a5Smrg		(wnew->name(i) = x_strtrim(request->name(i))) != NULL \
143492d43a5Smrg			? wnew->name(i) : "<null>"))
144492d43a5Smrg#define init_Tres(offset) \
145492d43a5Smrg	TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \
146492d43a5Smrg		fill_Tres(wnew, request, offset)))
147492d43a5Smrg#else
148492d43a5Smrg#define init_Bres(name)    wnew->name = request->name
149492d43a5Smrg#define init_Dres2(name,i) wnew->name[i] = request->name[i]
150492d43a5Smrg#define init_Ires(name)    wnew->name = request->name
151492d43a5Smrg#define init_Sres(name)    wnew->name = x_strtrim(request->name)
152492d43a5Smrg#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i))
153492d43a5Smrg#define init_Tres(offset)  fill_Tres(wnew, request, offset)
154492d43a5Smrg#endif
155492d43a5Smrg
156492d43a5Smrg
157d522f475Smrg#endif	/* included_trace_h */
158