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

51 {
52  wxString tmp;
53 
54  for( unsigned i = 0; i < aArray.GetCount(); i++ )
55  {
56  if( aArray[i].IsEmpty() )
57  tmp << wxT( "\"\" " );
58  else
59  tmp << aArray[i] << wxT( " " );
60  }
61 
62  return tmp;
63 }
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 224 of file trace_helpers.cpp.

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

References GetKeyName().

◆ GetKeyName()

wxString GetKeyName ( const wxKeyEvent &  aEvent)

Definition at line 199 of file trace_helpers.cpp.

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

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

References ADD, CLEAR, DIVIDE, and WXK_.

Referenced by GetKeyName().