KiCad PCB EDA Suite
trace_helpers.cpp File Reference

wxLogTrace helper implementation. More...

#include <trace_helpers.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 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...
 

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

52 {
53  wxString tmp;
54 
55  for( unsigned i = 0; i < aArray.GetCount(); i++ )
56  {
57  if( aArray[i].IsEmpty() )
58  tmp << wxT( "\"\" " );
59  else
60  tmp << aArray[i] << wxT( " " );
61  }
62 
63  return tmp;
64 }
size_t i
Definition: json11.cpp:597

References i.

Referenced by TOOL_DISPATCHER::DispatchWxEvent(), FOOTPRINTS_LISTBOX::OnChar(), LIBRARY_LISTBOX::OnChar(), COMPONENTS_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 225 of file trace_helpers.cpp.

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

References GetKeyName().

◆ GetKeyName()

wxString GetKeyName ( const wxKeyEvent &  aEvent)

Definition at line 200 of file trace_helpers.cpp.

201 {
202  int keycode = aEvent.GetKeyCode();
203  const char* virt = GetVirtualKeyCodeName( keycode );
204 
205  if( virt )
206  return virt;
207 
208  if( keycode > 0 && keycode < 32 )
209  return wxString::Format( "Ctrl-%c", (unsigned char)('A' + keycode - 1) );
210 
211  if( keycode >= 32 && keycode < 128 )
212  return wxString::Format( "'%c'", (unsigned char)keycode );
213 
214 #if wxUSE_UNICODE
215  int uc = aEvent.GetUnicodeKey();
216 
217  if( uc != WXK_NONE )
218  return wxString::Format( "'%c'", uc );
219 #endif
220 
221  return "unknown";
222 }
const char * GetVirtualKeyCodeName(int keycode)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

References Format(), and GetVirtualKeyCodeName().

Referenced by dump().

◆ GetVirtualKeyCodeName()

const char* GetVirtualKeyCodeName ( int  keycode)

Definition at line 79 of file trace_helpers.cpp.

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

References ADD, CLEAR, DIVIDE, and WXK_.

Referenced by GetKeyName().