KiCad PCB EDA Suite
trace_helpers.cpp File Reference

wxLogTrace helper implementation. More...

#include <trace_helpers.h>
#include <wx/tokenzr.h>

Go to the source code of this file.

Macros

#define WXK_(x)    case WXK_##x: return #x;
 

Functions

wxString dump (const wxArrayString &aArray)
 Debug helper for printing wxArrayString contents. More...
 
const char * GetVirtualKeyCodeName (int keycode)
 
wxString GetKeyName (const wxKeyEvent &aEvent)
 
wxString dump (const wxKeyEvent &aEvent)
 Debug helper for printing wxKeyEvent information. More...
 

Variables

const wxChar *const traceFindReplace = wxT( "KICAD_FIND_REPLACE" )
 Flag to enable find and replace debug tracing. More...
 
const wxChar *const kicadTraceCoords = wxT( "KICAD_COORDS" )
 Flag to enable draw panel coordinate debug tracing. More...
 
const wxChar *const kicadTraceKeyEvent = wxT( "KICAD_KEY_EVENTS" )
 Flag to enable wxKeyEvent debug tracing. More...
 
const wxChar *const kicadTraceToolStack = wxT( "KICAD_TOOL_STACK" )
 Flag to enable tracing of the tool handling stack. More...
 
const wxChar *const kicadTraceCoroutineStack = wxT( "KICAD_COROUTINE_STACK" )
 Flag to enable tracing of the coroutine call stack. More...
 
const wxChar *const traceSchLibMem = wxT( "KICAD_SCH_LIB_MEM" )
 Flag to enable schematic library memory deletion debug output. More...
 
const wxChar *const traceFindItem = wxT( "KICAD_FIND_ITEM" )
 Flag to enable find debug tracing. More...
 
const wxChar *const traceSchLegacyPlugin = wxT( "KICAD_SCH_LEGACY_PLUGIN" )
 Flag to enable legacy schematic plugin debug output. More...
 
const wxChar *const traceSchPlugin = wxT( "KICAD_SCH_PLUGIN" )
 Flag to enable legacy schematic plugin debug output. More...
 
const wxChar *const traceGedaPcbPlugin = wxT( "KICAD_GEDA_PLUGIN" )
 Flag to enable GEDA PCB plugin debug output. More...
 
const wxChar *const traceKicadPcbPlugin = wxT( "KICAD_PCB_PLUGIN" )
 Flag to enable GEDA PCB plugin debug output. More...
 
const wxChar *const tracePrinting = wxT( "KICAD_PRINT" )
 Flag to enable print controller debug output. More...
 
const wxChar *const traceAutoSave = wxT( "KICAD_AUTOSAVE" )
 Flag to enable auto save feature debug tracing. More...
 
const wxChar *const tracePathsAndFiles = wxT( "KICAD_PATHS_AND_FILES" )
 Flag to enable path and file name debug output. More...
 
const wxChar *const traceLocale = wxT( "KICAD_LOCALE" )
 Flag to enable locale debug output. More...
 
const wxChar *const traceFonts = wxT( "KICAD_FONTS" )
 Flag to enable locale debug output. More...
 
const wxChar *const traceScreen = wxT( "KICAD_SCREEN" )
 Flag to enable debug output of BASE_SCREEN and it's derivatives. More...
 
const wxChar *const traceZoomScroll = wxT( "KICAD_ZOOM_SCROLL" )
 Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives. More...
 
const wxChar *const traceSymbolResolver = wxT( "KICAD_SYM_RESOLVE" )
 Flag to enable debug output of symbol library resolver results. More...
 
const wxChar *const traceDisplayLocation = wxT( "KICAD_DISPLAY_LOCATION" )
 Flag to enable debug output of display positioning logic. More...
 
const wxChar *const traceSchSheetPaths = wxT( "KICAD_SCH_SHEET_PATHS" )
 Flag to enable debug output of schematic symbol sheet path manipulation code. More...
 
const wxChar *const traceEnvVars = wxT( "KICAD_ENV_VARS" )
 Flag to enable debug output of environment variable operations. More...
 
const wxChar *const traceGalProfile = wxT( "KICAD_GAL_PROFILE" )
 Flag to enable debug output of GAL performance profiling. More...
 
const wxChar *const traceKiCad2Step = wxT( "KICAD2STEP" )
 Flag to enable KiCad2Step debug tracing. More...
 

Detailed Description

wxLogTrace helper implementation.

Definition in file trace_helpers.cpp.

Macro Definition Documentation

◆ WXK_

#define WXK_ (   x)     case WXK_##x: return #x;

Function Documentation

◆ dump() [1/2]

wxString dump ( const wxArrayString &  aArray)

Debug helper for printing wxArrayString contents.

Parameters
aArrayis the string array to output.
Returns
the wxArrayString contents in a formatted string for debugging output.

Definition at line 60 of file trace_helpers.cpp.

61{
62 wxString tmp;
63
64 for( unsigned i = 0; i < aArray.GetCount(); i++ )
65 {
66 if( aArray[i].IsEmpty() )
67 tmp << wxT( "\"\" " );
68 else
69 tmp << aArray[i] << wxT( " " );
70 }
71
72 return tmp;
73}

Referenced by TOOL_DISPATCHER::DispatchWxEvent(), LIBEVAL::COMPILER::generateUCode(), TOOL_DISPATCHER::GetToolEvent(), FOOTPRINTS_LISTBOX::OnChar(), LIBRARY_LISTBOX::OnChar(), SYMBOLS_LISTBOX::OnChar(), EDA_BASE_FRAME::OnCharHook(), and GPCB_FPL_CACHE::parseParameters().

◆ dump() [2/2]

wxString dump ( const wxKeyEvent &  aEvent)

Debug helper for printing wxKeyEvent information.

Parameters
aEventis the wxKeyEvent to generate the print string from.
Returns
the wxKeyEvent information.

Definition at line 234 of file trace_helpers.cpp.

235{
236 wxString msg;
237 wxString eventType = wxS( "unknown" );
238
239 if( aEvent.GetEventType() == wxEVT_KEY_DOWN )
240 eventType = wxS( "KeyDown" );
241 else if( aEvent.GetEventType() == wxEVT_KEY_UP )
242 eventType = wxS( "KeyUp" );
243 else if( aEvent.GetEventType() == wxEVT_CHAR )
244 eventType = wxS( "Char" );
245 else if( aEvent.GetEventType() == wxEVT_CHAR_HOOK )
246 eventType = wxS( "Hook" );
247
248 // event key_name KeyCode modifiers Unicode raw_code raw_flags pos
249 msg.Printf( "%7s %15s %5d %c%c%c%c"
250#if wxUSE_UNICODE
251 "%5d (U+%04x)"
252#else
253 " none "
254#endif
255#ifdef wxHAS_RAW_KEY_CODES
256 " %7lu 0x%08lx"
257#else
258 " not-set not-set"
259#endif
260 " (%5d,%5d)",
261 eventType,
262 GetKeyName( aEvent ),
263 aEvent.GetKeyCode(),
264 aEvent.ControlDown() ? 'C' : '-',
265 aEvent.AltDown() ? 'A' : '-',
266 aEvent.ShiftDown() ? 'S' : '-',
267 aEvent.MetaDown() ? 'M' : '-'
268#if wxUSE_UNICODE
269 , aEvent.GetUnicodeKey()
270 , aEvent.GetUnicodeKey()
271#endif
272#ifdef wxHAS_RAW_KEY_CODES
273 , (unsigned long) aEvent.GetRawKeyCode()
274 , (unsigned long) aEvent.GetRawKeyFlags()
275#endif
276 , aEvent.GetX()
277 , aEvent.GetY()
278 );
279
280 return msg;
281}
wxString GetKeyName(const wxKeyEvent &aEvent)

References GetKeyName().

◆ GetKeyName()

wxString GetKeyName ( const wxKeyEvent &  aEvent)

Definition at line 209 of file trace_helpers.cpp.

210{
211 int keycode = aEvent.GetKeyCode();
212 const char* virt = GetVirtualKeyCodeName( keycode );
213
214 if( virt )
215 return virt;
216
217 if( keycode > 0 && keycode < 32 )
218 return wxString::Format( "Ctrl-%c", (unsigned char)('A' + keycode - 1) );
219
220 if( keycode >= 32 && keycode < 128 )
221 return wxString::Format( "'%c'", (unsigned char)keycode );
222
223#if wxUSE_UNICODE
224 int uc = aEvent.GetUnicodeKey();
225
226 if( uc != WXK_NONE )
227 return wxString::Format( "'%c'", uc );
228#endif
229
230 return "unknown";
231}
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
const char * GetVirtualKeyCodeName(int keycode)

References Format(), and GetVirtualKeyCodeName().

Referenced by dump().

◆ GetVirtualKeyCodeName()

const char * GetVirtualKeyCodeName ( int  keycode)

Definition at line 88 of file trace_helpers.cpp.

89{
90 switch ( keycode )
91 {
92#define WXK_(x) \
93 case WXK_##x: return #x;
94
95 WXK_(BACK)
96 WXK_(TAB)
97 WXK_(RETURN)
98 WXK_(ESCAPE)
99 WXK_(SPACE)
100 WXK_(DELETE)
101 WXK_(START)
102 WXK_(LBUTTON)
103 WXK_(RBUTTON)
104 WXK_(CANCEL)
105 WXK_(MBUTTON)
106 WXK_(CLEAR)
107 WXK_(SHIFT)
108 WXK_(ALT)
109 WXK_(CONTROL)
110 WXK_(MENU)
111 WXK_(PAUSE)
112 WXK_(CAPITAL)
113 WXK_(END)
114 WXK_(HOME)
115 WXK_(LEFT)
116 WXK_(UP)
117 WXK_(RIGHT)
118 WXK_(DOWN)
119 WXK_(SELECT)
120 WXK_(PRINT)
121 WXK_(EXECUTE)
122 WXK_(SNAPSHOT)
123 WXK_(INSERT)
124 WXK_(HELP)
125 WXK_(NUMPAD0)
126 WXK_(NUMPAD1)
127 WXK_(NUMPAD2)
128 WXK_(NUMPAD3)
129 WXK_(NUMPAD4)
130 WXK_(NUMPAD5)
131 WXK_(NUMPAD6)
132 WXK_(NUMPAD7)
133 WXK_(NUMPAD8)
134 WXK_(NUMPAD9)
135 WXK_(MULTIPLY)
136 WXK_(ADD)
138 WXK_(SUBTRACT)
139 WXK_(DECIMAL)
140 WXK_(DIVIDE)
141 WXK_(F1)
142 WXK_(F2)
143 WXK_(F3)
144 WXK_(F4)
145 WXK_(F5)
146 WXK_(F6)
147 WXK_(F7)
148 WXK_(F8)
149 WXK_(F9)
150 WXK_(F10)
151 WXK_(F11)
152 WXK_(F12)
153 WXK_(F13)
154 WXK_(F14)
155 WXK_(F15)
156 WXK_(F16)
157 WXK_(F17)
158 WXK_(F18)
159 WXK_(F19)
160 WXK_(F20)
161 WXK_(F21)
162 WXK_(F22)
163 WXK_(F23)
164 WXK_(F24)
165 WXK_(NUMLOCK)
166 WXK_(SCROLL)
167 WXK_(PAGEUP)
168 WXK_(PAGEDOWN)
169 WXK_(NUMPAD_SPACE)
170 WXK_(NUMPAD_TAB)
171 WXK_(NUMPAD_ENTER)
172 WXK_(NUMPAD_F1)
173 WXK_(NUMPAD_F2)
174 WXK_(NUMPAD_F3)
175 WXK_(NUMPAD_F4)
176 WXK_(NUMPAD_HOME)
177 WXK_(NUMPAD_LEFT)
178 WXK_(NUMPAD_UP)
179 WXK_(NUMPAD_RIGHT)
180 WXK_(NUMPAD_DOWN)
181 WXK_(NUMPAD_PAGEUP)
182 WXK_(NUMPAD_PAGEDOWN)
183 WXK_(NUMPAD_END)
184 WXK_(NUMPAD_BEGIN)
185 WXK_(NUMPAD_INSERT)
186 WXK_(NUMPAD_DELETE)
187 WXK_(NUMPAD_EQUAL)
188 WXK_(NUMPAD_MULTIPLY)
189 WXK_(NUMPAD_ADD)
190 WXK_(NUMPAD_SEPARATOR)
191 WXK_(NUMPAD_SUBTRACT)
192 WXK_(NUMPAD_DECIMAL)
193 WXK_(NUMPAD_DIVIDE)
194
195 WXK_(WINDOWS_LEFT)
196 WXK_(WINDOWS_RIGHT)
197#ifdef __WXOSX__
198 WXK_(RAW_CONTROL)
199#endif
200#undef WXK_
201
202 default:
203 return nullptr;
204 }
205}
@ ADD
Definition: am_param.h:150
static VECTOR2D CLEAR
#define WXK_(x)
#define SEPARATOR
Definition: wx_combobox.cpp:27

References ADD, CLEAR, END, INSERT, LEFT, RIGHT, SELECT, SEPARATOR, SUBTRACT, and WXK_.

Referenced by GetKeyName().