trace.h revision f2e35a3a
1f2e35a3aSmrg/* $XTermId: trace.h,v 1.92 2021/02/01 23:58:05 tom Exp $ */ 2d522f475Smrg 320d2c4d2Smrg/* 4f2e35a3aSmrg * Copyright 1997-2020,2021 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 44f2e35a3aSmrg#include <stdarg.h> 45f2e35a3aSmrg 462e4f8982Smrgextern void Trace ( const char *, ... ) GCC_PRINTFLIKE(1,2); 47f2e35a3aSmrgextern void TraceVA ( const char *fmt, va_list ap ); 48f2e35a3aSmrgextern void TraceXError (Display *d, XErrorEvent *ev); 496879286fSmrg 50956cc18dSsnj#undef TRACE 51d522f475Smrg#define TRACE(p) Trace p 52d522f475Smrg 53f2e35a3aSmrg#undef TRACE_VA 54f2e35a3aSmrg#define TRACE_VA(p) TraceVA p 55f2e35a3aSmrg#define TRACE_X_ERR(d,e) TraceXError(d,e) 56f2e35a3aSmrg 5720d2c4d2Smrgextern void TraceClose (void); 5820d2c4d2Smrg 5920d2c4d2Smrg#undef TRACE_CLOSE 6020d2c4d2Smrg#define TRACE_CLOSE TraceClose 6120d2c4d2Smrg 62d522f475Smrg#if OPT_TRACE > 1 63d522f475Smrg#define TRACE2(p) Trace p 64d522f475Smrg#endif 65d522f475Smrg 66f2e35a3aSmrg#define TRACE_L "{{" 67f2e35a3aSmrg#define TRACE_R "}}" 68f2e35a3aSmrg 692e4f8982Smrgextern const char * visibleChars(const Char * /* buf */, unsigned /* len */); 70f2e35a3aSmrgextern const char * visibleEventMode(EventMode); 712e4f8982Smrgextern const char * visibleIChars(const IChar * /* buf */, unsigned /* len */); 722e4f8982Smrgextern const char * visibleUChar(unsigned); 73e0a2b6dfSmrgextern const char * visibleDblChrset(unsigned /* chrset */); 74d522f475Smrgextern const char * visibleEventType (int); 75f2e35a3aSmrgextern const char * visibleMappingMode (int); 7620d2c4d2Smrgextern const char * visibleNotifyDetail(int /* code */); 770bd37d32Smrgextern const char * visibleNotifyMode (int /* code */); 78f2e35a3aSmrgextern const char * visibleScsCode(DECNRCM_codes /* chrset */); 79956cc18dSsnjextern const char * visibleSelectionTarget(Display * /* d */, Atom /* a */); 802e4f8982Smrgextern const char * visibleTekparse (int); 812e4f8982Smrgextern const char * visibleVTparse (int); 82d522f475Smrgextern const char * visibleXError (int /* code */); 83d522f475Smrg 84913cc679Smrgextern const char * TraceAtomName(Display * /* d */, Atom /* a */); 85913cc679Smrg 86d522f475Smrgextern void TraceArgv(const char * /* tag */, char ** /* argv */); 87956cc18dSsnj#undef TRACE_ARGV 88d522f475Smrg#define TRACE_ARGV(tag,argv) TraceArgv(tag,argv) 89d522f475Smrg 9020d2c4d2Smrgextern const char *trace_who; 91956cc18dSsnj#undef TRACE_CHILD 92d522f475Smrg#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child; 93d522f475Smrg 94f2e35a3aSmrgextern void TraceEvent(const char *, XEvent *, String *, Cardinal *); 95f2e35a3aSmrg#undef TRACE_EVENT 96f2e35a3aSmrg#define TRACE_EVENT(t,e,s,n) TraceEvent(t, (XEvent *)e, s, n) 97f2e35a3aSmrg 98f2e35a3aSmrg#undef TRACE_FALLBACK 99f2e35a3aSmrg#if OPT_RENDERFONT && OPT_WIDE_CHARS 100f2e35a3aSmrgextern void TraceFallback(XtermWidget, const char *, unsigned, int, XftFont *); 101f2e35a3aSmrg#define TRACE_FALLBACK(w,t,c,n,f) TraceFallback(w, t, c, n, f) 102f2e35a3aSmrg#else 103f2e35a3aSmrg#define TRACE_FALLBACK(w,t,c,n,f) /*nothing*/ 104f2e35a3aSmrg#endif 105f2e35a3aSmrg 10620d2c4d2Smrgextern void TraceFocus(Widget, XEvent *); 10720d2c4d2Smrg#undef TRACE_FOCUS 10820d2c4d2Smrg#define TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e) 10920d2c4d2Smrg 110d522f475Smrgextern void TraceSizeHints(XSizeHints *); 111956cc18dSsnj#undef TRACE_HINTS 112d522f475Smrg#define TRACE_HINTS(hints) TraceSizeHints(hints) 113d522f475Smrg 1142eaa94a1Schristosextern void TraceIds(const char * /* fname */, int /* lnum */); 115956cc18dSsnj#undef TRACE_IDS 116d522f475Smrg#define TRACE_IDS TraceIds(__FILE__, __LINE__) 117d522f475Smrg 1180bd37d32Smrgextern void TraceTime(const char * /* fname */, int /* lnum */); 1190bd37d32Smrg#undef TRACE_TIME 1200bd37d32Smrg#define TRACE_TIME TraceTime(__FILE__, __LINE__) 1210bd37d32Smrg 1222eaa94a1Schristosextern void TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal /* count */); 123956cc18dSsnj#undef TRACE_OPTS 124d522f475Smrg#define TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens) 125d522f475Smrg 126d522f475Smrgextern void TraceTranslations(const char *, Widget); 127956cc18dSsnj#undef TRACE_TRANS 128d522f475Smrg#define TRACE_TRANS(name,w) TraceTranslations(name,w) 129d522f475Smrg 1300bd37d32Smrgextern void TraceWindowAttributes(XWindowAttributes *); 1310bd37d32Smrg#undef TRACE_WIN_ATTRS 1320bd37d32Smrg#define TRACE_WIN_ATTRS(a) TraceWindowAttributes(a) 1330bd37d32Smrg 134d522f475Smrgextern void TraceWMSizeHints(XtermWidget); 135956cc18dSsnj#undef TRACE_WM_HINTS 136d522f475Smrg#define TRACE_WM_HINTS(w) TraceWMSizeHints(w) 137d522f475Smrg 138d522f475Smrgextern void TraceXtermResources(void); 139956cc18dSsnj#undef TRACE_XRES 140d522f475Smrg#define TRACE_XRES() TraceXtermResources() 141d522f475Smrg 1420bd37d32Smrgextern XtGeometryResult TraceResizeRequest(const char * /* fn */, int /* ln */, Widget /* w */, unsigned /* reqwide */, unsigned /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */); 143956cc18dSsnj#undef REQ_RESIZE 1442eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 14520d2c4d2Smrg TraceResizeRequest(__FILE__, __LINE__, w, \ 146e39b573cSmrg (reqwide), (reqhigh), \ 14720d2c4d2Smrg (gotwide), (gothigh)) 1482eaa94a1Schristos 1490bd37d32Smrgextern const char * ModifierName(unsigned /* modifier */); 1500bd37d32Smrg#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s" 1510bd37d32Smrg#define ARG_MODIFIER_NAMES(state) \ 1520bd37d32Smrg ModifierName(state & ShiftMask), \ 1530bd37d32Smrg ModifierName(state & LockMask), \ 1540bd37d32Smrg ModifierName(state & ControlMask), \ 1550bd37d32Smrg ModifierName(state & Mod1Mask), \ 1560bd37d32Smrg ModifierName(state & Mod2Mask), \ 1570bd37d32Smrg ModifierName(state & Mod3Mask), \ 1580bd37d32Smrg ModifierName(state & Mod4Mask), \ 1590bd37d32Smrg ModifierName(state & Mod5Mask) 1600bd37d32Smrg 1612eaa94a1Schristos#else 1622eaa94a1Schristos 1632eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 1642eaa94a1Schristos XtMakeResizeRequest((Widget) (w), \ 1652eaa94a1Schristos (Dimension) (reqwide), (Dimension) (reqhigh), \ 1662eaa94a1Schristos (gotwide), (gothigh)) 1672eaa94a1Schristos 168f2e35a3aSmrg#define TRACE(p) /*nothing*/ 169f2e35a3aSmrg#define TRACE_CLOSE() /*nothing*/ 170f2e35a3aSmrg#define TRACE_ARGV(tag,argv) /*nothing*/ 171f2e35a3aSmrg#define TRACE_CHILD /*nothing*/ 172f2e35a3aSmrg#define TRACE_EVENT(t,e,s,n) /*nothing*/ 173f2e35a3aSmrg#define TRACE_FALLBACK(w,t,c,n,f) /*nothing*/ 174f2e35a3aSmrg#define TRACE_FOCUS(w,e) /*nothing*/ 175f2e35a3aSmrg#define TRACE_HINTS(hints) /*nothing*/ 176f2e35a3aSmrg#define TRACE_IDS /*nothing*/ 177f2e35a3aSmrg#define TRACE_OPTS(opts,ress,lens) /*nothing*/ 178f2e35a3aSmrg#define TRACE_TRANS(name,w) /*nothing*/ 179f2e35a3aSmrg#define TRACE_WIN_ATTRS(w) /*nothing*/ 180f2e35a3aSmrg#define TRACE_WM_HINTS(w) /*nothing*/ 181f2e35a3aSmrg#define TRACE_X_ERR(d,e) /*nothing*/ 182f2e35a3aSmrg#define TRACE_XRES() /*nothing*/ 183f2e35a3aSmrg 184f2e35a3aSmrg#endif 185f2e35a3aSmrg 186f2e35a3aSmrg#ifndef TRACE2 187f2e35a3aSmrg#define TRACE2(p) /*nothing*/ 188d522f475Smrg#endif 189d522f475Smrg 1900bd37d32Smrgextern void TraceScreen(XtermWidget /* xw */, int /* whichBuf */); 1910bd37d32Smrg 192492d43a5Smrg/* 193492d43a5Smrg * The whole wnew->screen struct is zeroed in VTInitialize. Use these macros 194492d43a5Smrg * where applicable for copying the pieces from the request widget into the 195492d43a5Smrg * new widget. We do not have to use them for wnew->misc, but the associated 196492d43a5Smrg * traces are very useful for debugging. 197492d43a5Smrg */ 198492d43a5Smrg#if OPT_TRACE 199492d43a5Smrg#define init_Bres(name) \ 200492d43a5Smrg TRACE(("init " #name " = %s\n", \ 201492d43a5Smrg BtoS(wnew->name = request->name))) 2020bd37d32Smrg#define init_Dres(name) \ 2030bd37d32Smrg TRACE(("init " #name " = %f\n", \ 2040bd37d32Smrg wnew->name = request->name)) 205492d43a5Smrg#define init_Dres2(name,i) \ 206492d43a5Smrg TRACE(("init " #name "[%d] = %f\n", i, \ 207492d43a5Smrg wnew->name[i] = request->name[i])) 208492d43a5Smrg#define init_Ires(name) \ 209492d43a5Smrg TRACE(("init " #name " = %d\n", \ 210492d43a5Smrg wnew->name = request->name)) 21101037d57Smrg#define init_Mres(name) \ 21201037d57Smrg TRACE(("init " #name " = %s\n", \ 21301037d57Smrg MtoS(wnew->name = request->name))) 214492d43a5Smrg#define init_Sres(name) \ 215492d43a5Smrg TRACE(("init " #name " = \"%s\"\n", \ 216492d43a5Smrg (wnew->name = x_strtrim(request->name)) != NULL \ 217492d43a5Smrg ? wnew->name : "<null>")) 218492d43a5Smrg#define init_Sres2(name,i) \ 219492d43a5Smrg TRACE(("init " #name "[%d] = \"%s\"\n", i, \ 220492d43a5Smrg (wnew->name(i) = x_strtrim(request->name(i))) != NULL \ 221492d43a5Smrg ? wnew->name(i) : "<null>")) 222492d43a5Smrg#define init_Tres(offset) \ 223492d43a5Smrg TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \ 224492d43a5Smrg fill_Tres(wnew, request, offset))) 225492d43a5Smrg#else 226492d43a5Smrg#define init_Bres(name) wnew->name = request->name 2270bd37d32Smrg#define init_Dres(name) wnew->name = request->name 228492d43a5Smrg#define init_Dres2(name,i) wnew->name[i] = request->name[i] 229492d43a5Smrg#define init_Ires(name) wnew->name = request->name 23001037d57Smrg#define init_Mres(name) wnew->name = request->name 231492d43a5Smrg#define init_Sres(name) wnew->name = x_strtrim(request->name) 232492d43a5Smrg#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i)) 233492d43a5Smrg#define init_Tres(offset) fill_Tres(wnew, request, offset) 234492d43a5Smrg#endif 235492d43a5Smrg 2360bd37d32Smrg/* *INDENT-ON* */ 237492d43a5Smrg 2380bd37d32Smrg#endif /* included_trace_h */ 239