trace.h revision f2e35a3a
1/* $XTermId: trace.h,v 1.92 2021/02/01 23:58:05 tom Exp $ */ 2 3/* 4 * Copyright 1997-2020,2021 by Thomas E. Dickey 5 * 6 * All Rights Reserved 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the 10 * "Software"), to deal in the Software without restriction, including 11 * without limitation the rights to use, copy, modify, merge, publish, 12 * distribute, sublicense, and/or sell copies of the Software, and to 13 * permit persons to whom the Software is furnished to do so, subject to 14 * the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 * 27 * Except as contained in this notice, the name(s) of the above copyright 28 * holders shall not be used in advertising or otherwise to promote the 29 * sale, use or other dealings in this Software without prior written 30 * authorization. 31 */ 32 33/* 34 * Common/useful definitions for XTERM application 35 */ 36#ifndef included_trace_h 37#define included_trace_h 38/* *INDENT-OFF* */ 39 40#include <xterm.h> 41 42#if OPT_TRACE 43 44#include <stdarg.h> 45 46extern void Trace ( const char *, ... ) GCC_PRINTFLIKE(1,2); 47extern void TraceVA ( const char *fmt, va_list ap ); 48extern void TraceXError (Display *d, XErrorEvent *ev); 49 50#undef TRACE 51#define TRACE(p) Trace p 52 53#undef TRACE_VA 54#define TRACE_VA(p) TraceVA p 55#define TRACE_X_ERR(d,e) TraceXError(d,e) 56 57extern void TraceClose (void); 58 59#undef TRACE_CLOSE 60#define TRACE_CLOSE TraceClose 61 62#if OPT_TRACE > 1 63#define TRACE2(p) Trace p 64#endif 65 66#define TRACE_L "{{" 67#define TRACE_R "}}" 68 69extern const char * visibleChars(const Char * /* buf */, unsigned /* len */); 70extern const char * visibleEventMode(EventMode); 71extern const char * visibleIChars(const IChar * /* buf */, unsigned /* len */); 72extern const char * visibleUChar(unsigned); 73extern const char * visibleDblChrset(unsigned /* chrset */); 74extern const char * visibleEventType (int); 75extern const char * visibleMappingMode (int); 76extern const char * visibleNotifyDetail(int /* code */); 77extern const char * visibleNotifyMode (int /* code */); 78extern const char * visibleScsCode(DECNRCM_codes /* chrset */); 79extern const char * visibleSelectionTarget(Display * /* d */, Atom /* a */); 80extern const char * visibleTekparse (int); 81extern const char * visibleVTparse (int); 82extern const char * visibleXError (int /* code */); 83 84extern const char * TraceAtomName(Display * /* d */, Atom /* a */); 85 86extern void TraceArgv(const char * /* tag */, char ** /* argv */); 87#undef TRACE_ARGV 88#define TRACE_ARGV(tag,argv) TraceArgv(tag,argv) 89 90extern const char *trace_who; 91#undef TRACE_CHILD 92#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child; 93 94extern void TraceEvent(const char *, XEvent *, String *, Cardinal *); 95#undef TRACE_EVENT 96#define TRACE_EVENT(t,e,s,n) TraceEvent(t, (XEvent *)e, s, n) 97 98#undef TRACE_FALLBACK 99#if OPT_RENDERFONT && OPT_WIDE_CHARS 100extern void TraceFallback(XtermWidget, const char *, unsigned, int, XftFont *); 101#define TRACE_FALLBACK(w,t,c,n,f) TraceFallback(w, t, c, n, f) 102#else 103#define TRACE_FALLBACK(w,t,c,n,f) /*nothing*/ 104#endif 105 106extern void TraceFocus(Widget, XEvent *); 107#undef TRACE_FOCUS 108#define TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e) 109 110extern void TraceSizeHints(XSizeHints *); 111#undef TRACE_HINTS 112#define TRACE_HINTS(hints) TraceSizeHints(hints) 113 114extern void TraceIds(const char * /* fname */, int /* lnum */); 115#undef TRACE_IDS 116#define TRACE_IDS TraceIds(__FILE__, __LINE__) 117 118extern void TraceTime(const char * /* fname */, int /* lnum */); 119#undef TRACE_TIME 120#define TRACE_TIME TraceTime(__FILE__, __LINE__) 121 122extern void TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal /* count */); 123#undef TRACE_OPTS 124#define TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens) 125 126extern void TraceTranslations(const char *, Widget); 127#undef TRACE_TRANS 128#define TRACE_TRANS(name,w) TraceTranslations(name,w) 129 130extern void TraceWindowAttributes(XWindowAttributes *); 131#undef TRACE_WIN_ATTRS 132#define TRACE_WIN_ATTRS(a) TraceWindowAttributes(a) 133 134extern void TraceWMSizeHints(XtermWidget); 135#undef TRACE_WM_HINTS 136#define TRACE_WM_HINTS(w) TraceWMSizeHints(w) 137 138extern void TraceXtermResources(void); 139#undef TRACE_XRES 140#define TRACE_XRES() TraceXtermResources() 141 142extern XtGeometryResult TraceResizeRequest(const char * /* fn */, int /* ln */, Widget /* w */, unsigned /* reqwide */, unsigned /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */); 143#undef REQ_RESIZE 144#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 145 TraceResizeRequest(__FILE__, __LINE__, w, \ 146 (reqwide), (reqhigh), \ 147 (gotwide), (gothigh)) 148 149extern const char * ModifierName(unsigned /* modifier */); 150#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s" 151#define ARG_MODIFIER_NAMES(state) \ 152 ModifierName(state & ShiftMask), \ 153 ModifierName(state & LockMask), \ 154 ModifierName(state & ControlMask), \ 155 ModifierName(state & Mod1Mask), \ 156 ModifierName(state & Mod2Mask), \ 157 ModifierName(state & Mod3Mask), \ 158 ModifierName(state & Mod4Mask), \ 159 ModifierName(state & Mod5Mask) 160 161#else 162 163#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 164 XtMakeResizeRequest((Widget) (w), \ 165 (Dimension) (reqwide), (Dimension) (reqhigh), \ 166 (gotwide), (gothigh)) 167 168#define TRACE(p) /*nothing*/ 169#define TRACE_CLOSE() /*nothing*/ 170#define TRACE_ARGV(tag,argv) /*nothing*/ 171#define TRACE_CHILD /*nothing*/ 172#define TRACE_EVENT(t,e,s,n) /*nothing*/ 173#define TRACE_FALLBACK(w,t,c,n,f) /*nothing*/ 174#define TRACE_FOCUS(w,e) /*nothing*/ 175#define TRACE_HINTS(hints) /*nothing*/ 176#define TRACE_IDS /*nothing*/ 177#define TRACE_OPTS(opts,ress,lens) /*nothing*/ 178#define TRACE_TRANS(name,w) /*nothing*/ 179#define TRACE_WIN_ATTRS(w) /*nothing*/ 180#define TRACE_WM_HINTS(w) /*nothing*/ 181#define TRACE_X_ERR(d,e) /*nothing*/ 182#define TRACE_XRES() /*nothing*/ 183 184#endif 185 186#ifndef TRACE2 187#define TRACE2(p) /*nothing*/ 188#endif 189 190extern void TraceScreen(XtermWidget /* xw */, int /* whichBuf */); 191 192/* 193 * The whole wnew->screen struct is zeroed in VTInitialize. Use these macros 194 * where applicable for copying the pieces from the request widget into the 195 * new widget. We do not have to use them for wnew->misc, but the associated 196 * traces are very useful for debugging. 197 */ 198#if OPT_TRACE 199#define init_Bres(name) \ 200 TRACE(("init " #name " = %s\n", \ 201 BtoS(wnew->name = request->name))) 202#define init_Dres(name) \ 203 TRACE(("init " #name " = %f\n", \ 204 wnew->name = request->name)) 205#define init_Dres2(name,i) \ 206 TRACE(("init " #name "[%d] = %f\n", i, \ 207 wnew->name[i] = request->name[i])) 208#define init_Ires(name) \ 209 TRACE(("init " #name " = %d\n", \ 210 wnew->name = request->name)) 211#define init_Mres(name) \ 212 TRACE(("init " #name " = %s\n", \ 213 MtoS(wnew->name = request->name))) 214#define init_Sres(name) \ 215 TRACE(("init " #name " = \"%s\"\n", \ 216 (wnew->name = x_strtrim(request->name)) != NULL \ 217 ? wnew->name : "<null>")) 218#define init_Sres2(name,i) \ 219 TRACE(("init " #name "[%d] = \"%s\"\n", i, \ 220 (wnew->name(i) = x_strtrim(request->name(i))) != NULL \ 221 ? wnew->name(i) : "<null>")) 222#define init_Tres(offset) \ 223 TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \ 224 fill_Tres(wnew, request, offset))) 225#else 226#define init_Bres(name) wnew->name = request->name 227#define init_Dres(name) wnew->name = request->name 228#define init_Dres2(name,i) wnew->name[i] = request->name[i] 229#define init_Ires(name) wnew->name = request->name 230#define init_Mres(name) wnew->name = request->name 231#define init_Sres(name) wnew->name = x_strtrim(request->name) 232#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i)) 233#define init_Tres(offset) fill_Tres(wnew, request, offset) 234#endif 235 236/* *INDENT-ON* */ 237 238#endif /* included_trace_h */ 239