void wxExViMacros::StartRecording(const std::string& macro) { if (m_IsRecording || macro.empty()) { return; } m_IsRecording = true; m_IsModified = true; if (macro.size() == 1) { // We only use lower case macro's, to be able to // append to them using. m_Macro = macro; std::transform(m_Macro.begin(), m_Macro.end(), m_Macro.begin(), ::tolower); // Clear macro if it is lower case // (otherwise append to the macro). if (wxIslower(macro[0])) { m_Macros[m_Macro].clear(); } } else { m_Macro = macro; m_Macros[m_Macro].clear(); } wxExFrame::StatusText(m_Macro, "PaneMacro"); wxLogStatus(_("Macro recording")); }
bool wxKeyTextCtrl::ParseString(const wxChar* s, int len, int &mod, int &key) { mod = key = 0; if (!s || !len) return false; wxString a = wxT('\t'); a.append(s, len); wxAcceleratorEntry ae; #ifndef __WXMAC__ #define check_meta(str) do { \ wxString meta = str; \ for(int ml = 0; (ml = a.find(meta, ml)) != wxString::npos; ml++) { \ if(!ml || a[ml-1] == wxT('-') || a[ml-1] == wxT('+')) { \ mod |= wxMOD_META; \ a.erase(ml, meta.size()); \ ml = -1; \ } \ } \ } while(0) check_meta(wxT("Meta-")); check_meta(wxT("Meta+")); check_meta(_("Meta-")); check_meta(_("Meta+")); #endif // wx disallows standalone modifiers // unlike ToString(), this generates a debug message rather than // an assertion error, so it's easy to ignore and expensive to avoid // beforehand. Instead, check for them on failure if (!ae.FromString(a)) { a.MakeUpper(); #define chk_str(n, k) do { \ wxString t = n; \ if(a.size() > t.size() && a.substr(a.size() - t.size()) == t) { \ a.replace(a.size() - t.size(), t.size(), wxT("F1")); \ wxString ss(s); \ if(ae.FromString(a)) { \ mod |= ae.GetFlags(); \ key = k; \ return true; \ } \ a.replace(a.size() - 2, 2, n); \ } \ } while(0) chk_str(wxT("ALT"), WXK_ALT); chk_str(wxT("SHIFT"), WXK_SHIFT); chk_str(wxT("CTRL"), WXK_CONTROL); chk_str(wxT("CONTROL"), WXK_CONTROL); chk_str(_("ALT"), WXK_ALT); chk_str(_("SHIFT"), WXK_SHIFT); chk_str(_("CTRL"), WXK_CONTROL); chk_str(_("CONTROL"), WXK_CONTROL); return false; } mod |= ae.GetFlags(); key = ae.GetKeyCode(); // wx makes key lower-case, but key events return upper case if (key < WXK_START && wxIslower(key)) key = wxToupper(key); return true; }