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

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

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

References i.

Referenced by SCH_FIND_COLLECTOR::Collect(), TOOL_DISPATCHER::DispatchWxEvent(), EDA_DRAW_FRAME::OnCharHook(), EDA_DRAW_PANEL::OnCharHook(), EDA_DRAW_PANEL::OnKeyEvent(), 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 223 of file trace_helpers.cpp.

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

References GetKeyName().

◆ GetKeyName()

wxString GetKeyName ( const wxKeyEvent &  aEvent)

Definition at line 198 of file trace_helpers.cpp.

199 {
200  int keycode = aEvent.GetKeyCode();
201  const char* virt = GetVirtualKeyCodeName( keycode );
202 
203  if( virt )
204  return virt;
205 
206  if( keycode > 0 && keycode < 32 )
207  return wxString::Format( "Ctrl-%c", (unsigned char)('A' + keycode - 1) );
208 
209  if( keycode >= 32 && keycode < 128 )
210  return wxString::Format( "'%c'", (unsigned char)keycode );
211 
212 #if wxUSE_UNICODE
213  int uc = aEvent.GetUnicodeKey();
214 
215  if( uc != WXK_NONE )
216  return wxString::Format( "'%c'", uc );
217 #endif
218 
219  return "unknown";
220 }
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 77 of file trace_helpers.cpp.

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

References ADD, DIVIDE, and WXK_.

Referenced by GetKeyName().