trace.h revision 2e4f8982
12e4f8982Smrg/* $XTermId: trace.h,v 1.78 2016/10/05 08:56:36 tom Exp $ */
2d522f475Smrg
320d2c4d2Smrg/*
42e4f8982Smrg * Copyright 1997-2015,2016 by Thomas E. Dickey
5492d43a5Smrg *
620d2c4d2Smrg *                         All Rights Reserved
7492d43a5Smrg *
820d2c4d2Smrg * Permission is hereby granted, free of charge, to any person obtaining a
920d2c4d2Smrg * copy of this software and associated documentation files (the
1020d2c4d2Smrg * "Software"), to deal in the Software without restriction, including
1120d2c4d2Smrg * without limitation the rights to use, copy, modify, merge, publish,
1220d2c4d2Smrg * distribute, sublicense, and/or sell copies of the Software, and to
1320d2c4d2Smrg * permit persons to whom the Software is furnished to do so, subject to
1420d2c4d2Smrg * the following conditions:
1520d2c4d2Smrg *
1620d2c4d2Smrg * The above copyright notice and this permission notice shall be included
1720d2c4d2Smrg * in all copies or substantial portions of the Software.
1820d2c4d2Smrg *
1920d2c4d2Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2020d2c4d2Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2120d2c4d2Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2220d2c4d2Smrg * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
2320d2c4d2Smrg * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2420d2c4d2Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2520d2c4d2Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2620d2c4d2Smrg *
2720d2c4d2Smrg * Except as contained in this notice, the name(s) of the above copyright
2820d2c4d2Smrg * holders shall not be used in advertising or otherwise to promote the
2920d2c4d2Smrg * sale, use or other dealings in this Software without prior written
3020d2c4d2Smrg * authorization.
3120d2c4d2Smrg */
32d522f475Smrg
33d522f475Smrg/*
34d522f475Smrg * Common/useful definitions for XTERM application
35d522f475Smrg */
36d522f475Smrg#ifndef	included_trace_h
37d522f475Smrg#define	included_trace_h
380bd37d32Smrg/* *INDENT-OFF* */
39d522f475Smrg
40d522f475Smrg#include <xterm.h>
41d522f475Smrg
42d522f475Smrg#if OPT_TRACE
43d522f475Smrg
442e4f8982Smrgextern	void	Trace ( const char *, ... ) GCC_PRINTFLIKE(1,2);
456879286fSmrg
46956cc18dSsnj#undef  TRACE
47d522f475Smrg#define TRACE(p) Trace p
48d522f475Smrg
4920d2c4d2Smrgextern	void	TraceClose (void);
5020d2c4d2Smrg
5120d2c4d2Smrg#undef  TRACE_CLOSE
5220d2c4d2Smrg#define TRACE_CLOSE TraceClose
5320d2c4d2Smrg
54d522f475Smrg#if OPT_TRACE > 1
55d522f475Smrg#define TRACE2(p) Trace p
56d522f475Smrg#endif
57d522f475Smrg
582e4f8982Smrgextern	const char * visibleChars(const Char * /* buf */, unsigned /* len */);
592e4f8982Smrgextern	const char * visibleIChars(const IChar * /* buf */, unsigned /* len */);
602e4f8982Smrgextern	const char * visibleUChar(unsigned);
61e0a2b6dfSmrgextern	const char * visibleDblChrset(unsigned /* chrset */);
62d522f475Smrgextern	const char * visibleEventType (int);
6320d2c4d2Smrgextern	const char * visibleNotifyDetail(int /* code */);
640bd37d32Smrgextern	const char * visibleNotifyMode (int /* code */);
65e0a2b6dfSmrgextern	const char * visibleScsCode(int /* chrset */);
66956cc18dSsnjextern	const char * visibleSelectionTarget(Display * /* d */, Atom /* a */);
672e4f8982Smrgextern	const char * visibleTekparse (int);
682e4f8982Smrgextern	const char * visibleVTparse (int);
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
910bd37d32Smrgextern	void	TraceTime(const char * /* fname */, int  /* lnum */);
920bd37d32Smrg#undef  TRACE_TIME
930bd37d32Smrg#define	TRACE_TIME TraceTime(__FILE__, __LINE__)
940bd37d32Smrg
952eaa94a1Schristosextern	void	TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal  /* count */);
96956cc18dSsnj#undef  TRACE_OPTS
97d522f475Smrg#define	TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens)
98d522f475Smrg
99d522f475Smrgextern	void	TraceTranslations(const char *, Widget);
100956cc18dSsnj#undef  TRACE_TRANS
101d522f475Smrg#define	TRACE_TRANS(name,w) TraceTranslations(name,w)
102d522f475Smrg
1030bd37d32Smrgextern	void	TraceWindowAttributes(XWindowAttributes *);
1040bd37d32Smrg#undef  TRACE_WIN_ATTRS
1050bd37d32Smrg#define	TRACE_WIN_ATTRS(a) TraceWindowAttributes(a)
1060bd37d32Smrg
107d522f475Smrgextern	void	TraceWMSizeHints(XtermWidget);
108956cc18dSsnj#undef  TRACE_WM_HINTS
109d522f475Smrg#define	TRACE_WM_HINTS(w) TraceWMSizeHints(w)
110d522f475Smrg
111d522f475Smrgextern	void	TraceXtermResources(void);
112956cc18dSsnj#undef  TRACE_XRES
113d522f475Smrg#define	TRACE_XRES() TraceXtermResources()
114d522f475Smrg
1150bd37d32Smrgextern	XtGeometryResult TraceResizeRequest(const char * /* fn */, int  /* ln */, Widget  /* w */, unsigned  /* reqwide */, unsigned  /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */);
116956cc18dSsnj#undef  REQ_RESIZE
1172eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
11820d2c4d2Smrg	TraceResizeRequest(__FILE__, __LINE__, w, \
119e39b573cSmrg			   (reqwide), (reqhigh), \
12020d2c4d2Smrg			   (gotwide), (gothigh))
1212eaa94a1Schristos
1220bd37d32Smrgextern const char * ModifierName(unsigned /* modifier */);
1230bd37d32Smrg#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s"
1240bd37d32Smrg#define ARG_MODIFIER_NAMES(state) \
1250bd37d32Smrg	   ModifierName(state & ShiftMask), \
1260bd37d32Smrg	   ModifierName(state & LockMask), \
1270bd37d32Smrg	   ModifierName(state & ControlMask), \
1280bd37d32Smrg	   ModifierName(state & Mod1Mask), \
1290bd37d32Smrg	   ModifierName(state & Mod2Mask), \
1300bd37d32Smrg	   ModifierName(state & Mod3Mask), \
1310bd37d32Smrg	   ModifierName(state & Mod4Mask), \
1320bd37d32Smrg	   ModifierName(state & Mod5Mask)
1330bd37d32Smrg
1342eaa94a1Schristos#else
1352eaa94a1Schristos
1362eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
1372eaa94a1Schristos	XtMakeResizeRequest((Widget) (w), \
1382eaa94a1Schristos			    (Dimension) (reqwide), (Dimension) (reqhigh), \
1392eaa94a1Schristos			    (gotwide), (gothigh))
1402eaa94a1Schristos
141d522f475Smrg#endif
142d522f475Smrg
1430bd37d32Smrgextern void TraceScreen(XtermWidget /* xw */, int /* whichBuf */);
1440bd37d32Smrg
145492d43a5Smrg/*
146492d43a5Smrg * The whole wnew->screen struct is zeroed in VTInitialize.  Use these macros
147492d43a5Smrg * where applicable for copying the pieces from the request widget into the
148492d43a5Smrg * new widget.  We do not have to use them for wnew->misc, but the associated
149492d43a5Smrg * traces are very useful for debugging.
150492d43a5Smrg */
151492d43a5Smrg#if OPT_TRACE
152492d43a5Smrg#define init_Bres(name) \
153492d43a5Smrg	TRACE(("init " #name " = %s\n", \
154492d43a5Smrg		BtoS(wnew->name = request->name)))
1550bd37d32Smrg#define init_Dres(name) \
1560bd37d32Smrg	TRACE(("init " #name " = %f\n", \
1570bd37d32Smrg		wnew->name = request->name))
158492d43a5Smrg#define init_Dres2(name,i) \
159492d43a5Smrg	TRACE(("init " #name "[%d] = %f\n", i, \
160492d43a5Smrg		wnew->name[i] = request->name[i]))
161492d43a5Smrg#define init_Ires(name) \
162492d43a5Smrg	TRACE(("init " #name " = %d\n", \
163492d43a5Smrg		wnew->name = request->name))
16401037d57Smrg#define init_Mres(name) \
16501037d57Smrg	TRACE(("init " #name " = %s\n", \
16601037d57Smrg		MtoS(wnew->name = request->name)))
167492d43a5Smrg#define init_Sres(name) \
168492d43a5Smrg	TRACE(("init " #name " = \"%s\"\n", \
169492d43a5Smrg		(wnew->name = x_strtrim(request->name)) != NULL \
170492d43a5Smrg			? wnew->name : "<null>"))
171492d43a5Smrg#define init_Sres2(name,i) \
172492d43a5Smrg	TRACE(("init " #name "[%d] = \"%s\"\n", i, \
173492d43a5Smrg		(wnew->name(i) = x_strtrim(request->name(i))) != NULL \
174492d43a5Smrg			? wnew->name(i) : "<null>"))
175492d43a5Smrg#define init_Tres(offset) \
176492d43a5Smrg	TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \
177492d43a5Smrg		fill_Tres(wnew, request, offset)))
178492d43a5Smrg#else
179492d43a5Smrg#define init_Bres(name)    wnew->name = request->name
1800bd37d32Smrg#define init_Dres(name)    wnew->name = request->name
181492d43a5Smrg#define init_Dres2(name,i) wnew->name[i] = request->name[i]
182492d43a5Smrg#define init_Ires(name)    wnew->name = request->name
18301037d57Smrg#define init_Mres(name)    wnew->name = request->name
184492d43a5Smrg#define init_Sres(name)    wnew->name = x_strtrim(request->name)
185492d43a5Smrg#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i))
186492d43a5Smrg#define init_Tres(offset)  fill_Tres(wnew, request, offset)
187492d43a5Smrg#endif
188492d43a5Smrg
1890bd37d32Smrg/* *INDENT-ON* */
190492d43a5Smrg
1910bd37d32Smrg#endif /* included_trace_h */
192