wxWriter(wxTextCtrl* p_log, wxTextCtrl* p_tty) : m_color_white(wxColour(255, 255, 255)) , m_color_yellow(wxColour(255, 255, 0)) , m_color_red(wxColour(255, 0, 0)) , m_log(p_log), m_tty(p_tty), newLog(false), inited(false) { m_log->Bind(EVT_LOG_COMMAND, [this](wxCommandEvent &evt){this->write(evt);}); }
MainFrame(const wxString& title) { wxXmlResource::Get()->LoadFrame(this, NULL, "Frame1"); m_buttonFindAll = XRCCTRL(*this, "m_buttonFindAll", wxButton); m_textCtrlRegex = XRCCTRL(*this, "m_textCtrlRegex", wxTextCtrl); m_textCtrlString = XRCCTRL(*this, "m_textCtrlString", wxTextCtrl); m_textCtrlFindAll = XRCCTRL(*this, "m_textCtrlFindAll", wxTextCtrl); m_textCtrlRegex->Bind(wxEVT_TEXT, [=](wxCommandEvent &event){ std::wstring a = m_textCtrlRegex->GetValue(); auto R = re::compile(a); if (R){ m_textCtrlRegex->SetBackgroundColour(wxColor(0,255,0)); m_textCtrlRegex->Refresh(); m_textCtrlFindAll->Clear(); m_textCtrlFindAll->Refresh(); } else{ m_textCtrlRegex->SetBackgroundColour(wxColor(255, 0, 0)); m_textCtrlRegex->Refresh(); m_textCtrlFindAll->Clear(); m_textCtrlFindAll->AppendText(std::to_string(re::getlasterror())); m_textCtrlFindAll->AppendText("\n"); m_textCtrlFindAll->AppendText(re::getlasterrorstr()); m_textCtrlFindAll->Refresh(); } } ); //------------------------------------------------------------------------------ m_buttonFindAll->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent &event){ m_textCtrlFindAll->Clear(); std::wstring a = m_textCtrlRegex->GetValue(); auto R = re::compile(a); if (R){ std::wstring s = m_textCtrlString->GetValue(); auto v = R->findall(s); for (auto i = v.begin(); i < v.end(); i++){ m_textCtrlFindAll->AppendText(*i); m_textCtrlFindAll->AppendText("\n"); } } m_textCtrlFindAll->Refresh(); }); //------------------------------------------------------------------------------ }