void DialogSearchReplace::FindReplace(bool (SearchReplaceEngine::*func)()) { TransferDataFromWindow(); if (settings->find.empty()) return; c->search->Configure(*settings); try { (c->search->*func)(); } catch (std::exception const& e) { wxMessageBox(to_wx(e.what()), "Error", wxOK | wxICON_ERROR | wxCENTER, this); return; } config::mru->Add("Find", settings->find); if (has_replace) config::mru->Add("Replace", settings->replace_with); OPT_SET("Tool/Search Replace/Match Case")->SetBool(settings->match_case); OPT_SET("Tool/Search Replace/RegExp")->SetBool(settings->use_regex); OPT_SET("Tool/Search Replace/Skip Comments")->SetBool(settings->ignore_comments); OPT_SET("Tool/Search Replace/Skip Tags")->SetBool(settings->skip_tags); OPT_SET("Tool/Search Replace/Field")->SetInt(static_cast<int>(settings->field)); OPT_SET("Tool/Search Replace/Affect")->SetInt(static_cast<int>(settings->limit_to)); UpdateDropDowns(); }
///////////// // Find next void DialogSearchReplace::OnFindNext (wxCommandEvent &event) { // Variables wxString LookFor = FindEdit->GetValue(); if (LookFor.IsEmpty()) return; // Setup Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); Search.matchCase = CheckMatchCase->IsChecked(); Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled(); Search.LookFor = LookFor; Search.CanContinue = true; Search.affect = Affect->GetSelection(); Search.field = Field->GetSelection(); Search.FindNext(); if (hasReplace) { wxString ReplaceWith = ReplaceEdit->GetValue(); Search.ReplaceWith = ReplaceWith; Options.AddToRecentList(ReplaceWith,_T("Recent replace")); } // Add to history Options.AddToRecentList(LookFor,_T("Recent find")); UpdateDropDowns(); }
void DialogSearchReplace::FindReplace(int mode) { if (mode < 0 || mode > 2) return; // Variables wxString LookFor = FindEdit->GetValue(); if (!LookFor) return; // Setup Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); Search.matchCase = CheckMatchCase->IsChecked(); Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled(); Search.LookFor = LookFor; Search.CanContinue = true; Search.affect = Affect->GetSelection(); Search.field = Field->GetSelection(); // Find if (mode == 0) { Search.FindNext(); if (hasReplace) { wxString ReplaceWith = ReplaceEdit->GetValue(); Search.ReplaceWith = ReplaceWith; config::mru->Add("Replace", from_wx(ReplaceWith)); } } // Replace else { wxString ReplaceWith = ReplaceEdit->GetValue(); Search.ReplaceWith = ReplaceWith; if (mode == 1) Search.ReplaceNext(); else Search.ReplaceAll(); config::mru->Add("Replace", from_wx(ReplaceWith)); } // Add to history config::mru->Add("Find", from_wx(LookFor)); UpdateDropDowns(); }