15104ee6eSmrg/* $XTermId: trace.h,v 1.97 2024/12/01 19:54:13 tom Exp $ */ 2d522f475Smrg 320d2c4d2Smrg/* 404b94745Smrg * Copyright 1997-2022,2024 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 504419d26bSmrg#undef if_TRACE 514419d26bSmrg#define if_TRACE(stmt) stmt 524419d26bSmrg 53956cc18dSsnj#undef TRACE 54d522f475Smrg#define TRACE(p) Trace p 55d522f475Smrg 56f2e35a3aSmrg#undef TRACE_VA 57f2e35a3aSmrg#define TRACE_VA(p) TraceVA p 58f2e35a3aSmrg#define TRACE_X_ERR(d,e) TraceXError(d,e) 59f2e35a3aSmrg 6020d2c4d2Smrgextern void TraceClose (void); 6120d2c4d2Smrg 6220d2c4d2Smrg#undef TRACE_CLOSE 6320d2c4d2Smrg#define TRACE_CLOSE TraceClose 6420d2c4d2Smrg 65d522f475Smrg#if OPT_TRACE > 1 66d522f475Smrg#define TRACE2(p) Trace p 67d522f475Smrg#endif 68d522f475Smrg 69f2e35a3aSmrg#define TRACE_L "{{" 70f2e35a3aSmrg#define TRACE_R "}}" 71f2e35a3aSmrg 725307cd1aSmrgextern const char * visibleChars(const Char * /* buf */, size_t /* len */); 73f2e35a3aSmrgextern const char * visibleEventMode(EventMode); 745307cd1aSmrgextern const char * visibleIChars(const IChar * /* buf */, size_t /* len */); 752e4f8982Smrgextern const char * visibleUChar(unsigned); 76e0a2b6dfSmrgextern const char * visibleDblChrset(unsigned /* chrset */); 77d522f475Smrgextern const char * visibleEventType (int); 78f2e35a3aSmrgextern const char * visibleMappingMode (int); 7920d2c4d2Smrgextern const char * visibleNotifyDetail(int /* code */); 800bd37d32Smrgextern const char * visibleNotifyMode (int /* code */); 81f2e35a3aSmrgextern const char * visibleScsCode(DECNRCM_codes /* chrset */); 82956cc18dSsnjextern const char * visibleSelectionTarget(Display * /* d */, Atom /* a */); 832e4f8982Smrgextern const char * visibleTekparse (int); 842e4f8982Smrgextern const char * visibleVTparse (int); 85d522f475Smrgextern const char * visibleXError (int /* code */); 86d522f475Smrg 87913cc679Smrgextern const char * TraceAtomName(Display * /* d */, Atom /* a */); 88913cc679Smrg 89d522f475Smrgextern void TraceArgv(const char * /* tag */, char ** /* argv */); 90956cc18dSsnj#undef TRACE_ARGV 91d522f475Smrg#define TRACE_ARGV(tag,argv) TraceArgv(tag,argv) 92d522f475Smrg 9320d2c4d2Smrgextern const char *trace_who; 94956cc18dSsnj#undef TRACE_CHILD 955104ee6eSmrg#define TRACE_CHILD int tracing_child = (trace_who = "child") != NULL; (void) tracing_child 96d522f475Smrg 975104ee6eSmrgextern void TraceEvent(const char *, XEvent *, String *, const Cardinal *); 98f2e35a3aSmrg#undef TRACE_EVENT 99f2e35a3aSmrg#define TRACE_EVENT(t,e,s,n) TraceEvent(t, (XEvent *)e, s, n) 100f2e35a3aSmrg 101f2e35a3aSmrg#undef TRACE_FALLBACK 102f2e35a3aSmrg#if OPT_RENDERFONT && OPT_WIDE_CHARS 103f2e35a3aSmrgextern void TraceFallback(XtermWidget, const char *, unsigned, int, XftFont *); 104f2e35a3aSmrg#define TRACE_FALLBACK(w,t,c,n,f) TraceFallback(w, t, c, n, f) 105f2e35a3aSmrg#else 106f2e35a3aSmrg#define TRACE_FALLBACK(w,t,c,n,f) /*nothing*/ 107f2e35a3aSmrg#endif 108f2e35a3aSmrg 10920d2c4d2Smrgextern void TraceFocus(Widget, XEvent *); 11020d2c4d2Smrg#undef TRACE_FOCUS 11120d2c4d2Smrg#define TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e) 11220d2c4d2Smrg 113d522f475Smrgextern void TraceSizeHints(XSizeHints *); 114956cc18dSsnj#undef TRACE_HINTS 115d522f475Smrg#define TRACE_HINTS(hints) TraceSizeHints(hints) 116d522f475Smrg 1172eaa94a1Schristosextern void TraceIds(const char * /* fname */, int /* lnum */); 118956cc18dSsnj#undef TRACE_IDS 119d522f475Smrg#define TRACE_IDS TraceIds(__FILE__, __LINE__) 120d522f475Smrg 1210bd37d32Smrgextern void TraceTime(const char * /* fname */, int /* lnum */); 1220bd37d32Smrg#undef TRACE_TIME 1230bd37d32Smrg#define TRACE_TIME TraceTime(__FILE__, __LINE__) 1240bd37d32Smrg 1252eaa94a1Schristosextern void TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal /* count */); 126956cc18dSsnj#undef TRACE_OPTS 127d522f475Smrg#define TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens) 128d522f475Smrg 129d522f475Smrgextern void TraceTranslations(const char *, Widget); 130956cc18dSsnj#undef TRACE_TRANS 131d522f475Smrg#define TRACE_TRANS(name,w) TraceTranslations(name,w) 132d522f475Smrg 1330bd37d32Smrgextern void TraceWindowAttributes(XWindowAttributes *); 1340bd37d32Smrg#undef TRACE_WIN_ATTRS 1350bd37d32Smrg#define TRACE_WIN_ATTRS(a) TraceWindowAttributes(a) 1360bd37d32Smrg 137d522f475Smrgextern void TraceWMSizeHints(XtermWidget); 138956cc18dSsnj#undef TRACE_WM_HINTS 139d522f475Smrg#define TRACE_WM_HINTS(w) TraceWMSizeHints(w) 140d522f475Smrg 141d522f475Smrgextern void TraceXtermResources(void); 142956cc18dSsnj#undef TRACE_XRES 143d522f475Smrg#define TRACE_XRES() TraceXtermResources() 144d522f475Smrg 1450bd37d32Smrgextern XtGeometryResult TraceResizeRequest(const char * /* fn */, int /* ln */, Widget /* w */, unsigned /* reqwide */, unsigned /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */); 146956cc18dSsnj#undef REQ_RESIZE 1472eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 14820d2c4d2Smrg TraceResizeRequest(__FILE__, __LINE__, w, \ 149e39b573cSmrg (reqwide), (reqhigh), \ 15020d2c4d2Smrg (gotwide), (gothigh)) 1512eaa94a1Schristos 1520bd37d32Smrgextern const char * ModifierName(unsigned /* modifier */); 1530bd37d32Smrg#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s" 1540bd37d32Smrg#define ARG_MODIFIER_NAMES(state) \ 1550bd37d32Smrg ModifierName(state & ShiftMask), \ 1560bd37d32Smrg ModifierName(state & LockMask), \ 1570bd37d32Smrg ModifierName(state & ControlMask), \ 1580bd37d32Smrg ModifierName(state & Mod1Mask), \ 1590bd37d32Smrg ModifierName(state & Mod2Mask), \ 1600bd37d32Smrg ModifierName(state & Mod3Mask), \ 1610bd37d32Smrg ModifierName(state & Mod4Mask), \ 1620bd37d32Smrg ModifierName(state & Mod5Mask) 1630bd37d32Smrg 1642eaa94a1Schristos#else 1652eaa94a1Schristos 1662eaa94a1Schristos#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ 1672eaa94a1Schristos XtMakeResizeRequest((Widget) (w), \ 1682eaa94a1Schristos (Dimension) (reqwide), (Dimension) (reqhigh), \ 1692eaa94a1Schristos (gotwide), (gothigh)) 1702eaa94a1Schristos 1714419d26bSmrg#define if_TRACE(stmt) /*nothing*/ 172f2e35a3aSmrg#define TRACE(p) /*nothing*/ 173f2e35a3aSmrg#define TRACE_CLOSE() /*nothing*/ 174f2e35a3aSmrg#define TRACE_ARGV(tag,argv) /*nothing*/ 175f2e35a3aSmrg#define TRACE_CHILD /*nothing*/ 176f2e35a3aSmrg#define TRACE_EVENT(t,e,s,n) /*nothing*/ 177f2e35a3aSmrg#define TRACE_FALLBACK(w,t,c,n,f) /*nothing*/ 178f2e35a3aSmrg#define TRACE_FOCUS(w,e) /*nothing*/ 179f2e35a3aSmrg#define TRACE_HINTS(hints) /*nothing*/ 180f2e35a3aSmrg#define TRACE_IDS /*nothing*/ 181f2e35a3aSmrg#define TRACE_OPTS(opts,ress,lens) /*nothing*/ 182f2e35a3aSmrg#define TRACE_TRANS(name,w) /*nothing*/ 183f2e35a3aSmrg#define TRACE_WIN_ATTRS(w) /*nothing*/ 184f2e35a3aSmrg#define TRACE_WM_HINTS(w) /*nothing*/ 185f2e35a3aSmrg#define TRACE_X_ERR(d,e) /*nothing*/ 186f2e35a3aSmrg#define TRACE_XRES() /*nothing*/ 187f2e35a3aSmrg 188f2e35a3aSmrg#endif 189f2e35a3aSmrg 190f2e35a3aSmrg#ifndef TRACE2 191f2e35a3aSmrg#define TRACE2(p) /*nothing*/ 192d522f475Smrg#endif 193d522f475Smrg 1940bd37d32Smrgextern void TraceScreen(XtermWidget /* xw */, int /* whichBuf */); 1950bd37d32Smrg 196492d43a5Smrg/* 197492d43a5Smrg * The whole wnew->screen struct is zeroed in VTInitialize. Use these macros 198492d43a5Smrg * where applicable for copying the pieces from the request widget into the 199492d43a5Smrg * new widget. We do not have to use them for wnew->misc, but the associated 200492d43a5Smrg * traces are very useful for debugging. 201492d43a5Smrg */ 202492d43a5Smrg#if OPT_TRACE 203492d43a5Smrg#define init_Bres(name) \ 204492d43a5Smrg TRACE(("init " #name " = %s\n", \ 205492d43a5Smrg BtoS(wnew->name = request->name))) 2060bd37d32Smrg#define init_Dres(name) \ 2070bd37d32Smrg TRACE(("init " #name " = %f\n", \ 2080bd37d32Smrg wnew->name = request->name)) 209492d43a5Smrg#define init_Dres2(name,i) \ 210492d43a5Smrg TRACE(("init " #name "[%d] = %f\n", i, \ 211492d43a5Smrg wnew->name[i] = request->name[i])) 212492d43a5Smrg#define init_Ires(name) \ 213492d43a5Smrg TRACE(("init " #name " = %d\n", \ 214492d43a5Smrg wnew->name = request->name)) 21501037d57Smrg#define init_Mres(name) \ 21601037d57Smrg TRACE(("init " #name " = %s\n", \ 21701037d57Smrg MtoS(wnew->name = request->name))) 218492d43a5Smrg#define init_Sres(name) \ 219492d43a5Smrg TRACE(("init " #name " = \"%s\"\n", \ 220492d43a5Smrg (wnew->name = x_strtrim(request->name)) != NULL \ 221492d43a5Smrg ? wnew->name : "<null>")) 222492d43a5Smrg#define init_Sres2(name,i) \ 223492d43a5Smrg TRACE(("init " #name "[%d] = \"%s\"\n", i, \ 224492d43a5Smrg (wnew->name(i) = x_strtrim(request->name(i))) != NULL \ 225492d43a5Smrg ? wnew->name(i) : "<null>")) 226492d43a5Smrg#define init_Tres(offset) \ 227492d43a5Smrg TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \ 228492d43a5Smrg fill_Tres(wnew, request, offset))) 229492d43a5Smrg#else 230492d43a5Smrg#define init_Bres(name) wnew->name = request->name 2310bd37d32Smrg#define init_Dres(name) wnew->name = request->name 232492d43a5Smrg#define init_Dres2(name,i) wnew->name[i] = request->name[i] 233492d43a5Smrg#define init_Ires(name) wnew->name = request->name 23401037d57Smrg#define init_Mres(name) wnew->name = request->name 235492d43a5Smrg#define init_Sres(name) wnew->name = x_strtrim(request->name) 236492d43a5Smrg#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i)) 237492d43a5Smrg#define init_Tres(offset) fill_Tres(wnew, request, offset) 238492d43a5Smrg#endif 239492d43a5Smrg 2400bd37d32Smrg/* *INDENT-ON* */ 241492d43a5Smrg 2420bd37d32Smrg#endif /* included_trace_h */ 243