trace.h revision 492d43a5
1/* $XTermId: trace.h,v 1.55 2010/10/13 22:26:57 tom Exp $ */ 2 3/* 4 * 5 * Copyright 1997-2009,2010 by Thomas E. Dickey 6 * 7 * All Rights Reserved 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a 10 * copy of this software and associated documentation files (the 11 * "Software"), to deal in the Software without restriction, including 12 * without limitation the rights to use, copy, modify, merge, publish, 13 * distribute, sublicense, and/or sell copies of the Software, and to 14 * permit persons to whom the Software is furnished to do so, subject to 15 * the following conditions: 16 * 17 * The above copyright notice and this permission notice shall be included 18 * in all copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 * 28 * Except as contained in this notice, the name(s) of the above copyright 29 * holders shall not be used in advertising or otherwise to promote the 30 * sale, use or other dealings in this Software without prior written 31 * authorization. 32 * 33 */ 34 35/* 36 * Common/useful definitions for XTERM application 37 */ 38#ifndef included_trace_h 39#define included_trace_h 40 41#include <xterm.h> 42 43#if OPT_TRACE 44 45extern void Trace ( const char *, ... ) 46#ifdef GCC_PRINTF 47 __attribute__ ((format(printf,1,2))) 48#endif 49 ; 50#undef TRACE 51#define TRACE(p) Trace p 52 53extern void TraceClose (void); 54 55#undef TRACE_CLOSE 56#define TRACE_CLOSE TraceClose 57 58#if OPT_TRACE > 1 59#define TRACE2(p) Trace p 60#endif 61 62extern char * visibleChars (const Char * /* buf */, unsigned /* len */); 63extern char * visibleIChar (IChar *, unsigned); 64extern char * visibleIChars (IChar * /* buf */, unsigned /* len */); 65extern const char * visibleChrsetName(unsigned /* chrset */); 66extern const char * visibleEventType (int); 67extern const char * visibleNotifyDetail(int /* code */); 68extern const char * visibleSelectionTarget(Display * /* d */, Atom /* a */); 69extern const char * visibleXError (int /* code */); 70 71extern void TraceArgv(const char * /* tag */, char ** /* argv */); 72#undef TRACE_ARGV 73#define TRACE_ARGV(tag,argv) TraceArgv(tag,argv) 74 75extern const char *trace_who; 76#undef TRACE_CHILD 77#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child; 78 79extern void TraceFocus(Widget, XEvent *); 80#undef TRACE_FOCUS 81#define TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e) 82 83extern void TraceSizeHints(XSizeHints *); 84#undef TRACE_HINTS 85#define TRACE_HINTS(hints) TraceSizeHints(hints) 86 87extern void TraceIds(const char * /* fname */, int /* lnum */); 88#undef TRACE_IDS 89#define TRACE_IDS TraceIds(__FILE__, __LINE__) 90 91extern void TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal /* count */); 92#undef TRACE_OPTS 93#define TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens) 94 95extern void TraceTranslations(const char *, Widget); 96#undef TRACE_TRANS 97#define TRACE_TRANS(name,w) TraceTranslations(name,w) 98 99extern void TraceWMSizeHints(XtermWidget); 100#undef TRACE_WM_HINTS 101#define TRACE_WM_HINTS(w) TraceWMSizeHints(w) 102 103extern void TraceXtermResources(void); 104#undef TRACE_XRES 105#define TRACE_XRES() TraceXtermResources() 106 107extern int TraceResizeRequest(const char * /* fn */, int /* ln */, Widget /* w */, Dimension /* reqwide */, Dimension /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */); 108#undef REQ_RESIZE 109#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 110 TraceResizeRequest(__FILE__, __LINE__, w, \ 111 (Dimension) (reqwide), (Dimension) (reqhigh), \ 112 (gotwide), (gothigh)) 113 114#else 115 116#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 117 XtMakeResizeRequest((Widget) (w), \ 118 (Dimension) (reqwide), (Dimension) (reqhigh), \ 119 (gotwide), (gothigh)) 120 121#endif 122 123/* 124 * The whole wnew->screen struct is zeroed in VTInitialize. Use these macros 125 * where applicable for copying the pieces from the request widget into the 126 * new widget. We do not have to use them for wnew->misc, but the associated 127 * traces are very useful for debugging. 128 */ 129#if OPT_TRACE 130#define init_Bres(name) \ 131 TRACE(("init " #name " = %s\n", \ 132 BtoS(wnew->name = request->name))) 133#define init_Dres2(name,i) \ 134 TRACE(("init " #name "[%d] = %f\n", i, \ 135 wnew->name[i] = request->name[i])) 136#define init_Ires(name) \ 137 TRACE(("init " #name " = %d\n", \ 138 wnew->name = request->name)) 139#define init_Sres(name) \ 140 TRACE(("init " #name " = \"%s\"\n", \ 141 (wnew->name = x_strtrim(request->name)) != NULL \ 142 ? wnew->name : "<null>")) 143#define init_Sres2(name,i) \ 144 TRACE(("init " #name "[%d] = \"%s\"\n", i, \ 145 (wnew->name(i) = x_strtrim(request->name(i))) != NULL \ 146 ? wnew->name(i) : "<null>")) 147#define init_Tres(offset) \ 148 TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \ 149 fill_Tres(wnew, request, offset))) 150#else 151#define init_Bres(name) wnew->name = request->name 152#define init_Dres2(name,i) wnew->name[i] = request->name[i] 153#define init_Ires(name) wnew->name = request->name 154#define init_Sres(name) wnew->name = x_strtrim(request->name) 155#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i)) 156#define init_Tres(offset) fill_Tres(wnew, request, offset) 157#endif 158 159 160#endif /* included_trace_h */ 161