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 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 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...
 

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 57 of file trace_helpers.cpp.

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

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 231 of file trace_helpers.cpp.

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

References GetKeyName().

◆ GetKeyName()

wxString GetKeyName ( const wxKeyEvent &  aEvent)

Definition at line 206 of file trace_helpers.cpp.

207 {
208  int keycode = aEvent.GetKeyCode();
209  const char* virt = GetVirtualKeyCodeName( keycode );
210 
211  if( virt )
212  return virt;
213 
214  if( keycode > 0 && keycode < 32 )
215  return wxString::Format( "Ctrl-%c", (unsigned char)('A' + keycode - 1) );
216 
217  if( keycode >= 32 && keycode < 128 )
218  return wxString::Format( "'%c'", (unsigned char)keycode );
219 
220 #if wxUSE_UNICODE
221  int uc = aEvent.GetUnicodeKey();
222 
223  if( uc != WXK_NONE )
224  return wxString::Format( "'%c'", uc );
225 #endif
226 
227  return "unknown";
228 }
const char * GetVirtualKeyCodeName(int keycode)
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

References Format(), and GetVirtualKeyCodeName().

Referenced by dump().

◆ GetVirtualKeyCodeName()

const char* GetVirtualKeyCodeName ( int  keycode)

Definition at line 85 of file trace_helpers.cpp.

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

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

Referenced by GetKeyName().