void ThreadSearch::RunThreadSearch(const wxString& text, bool isCtxSearch/*=false*/) { if ( !IsAttached() ) return; ThreadSearchFindData findData = m_FindData; // User may prefer to set default options for contextual search if ( (isCtxSearch == true) && (m_UseDefValsForThreadSearch == true) ) { findData.SetMatchCase(true); findData.SetMatchWord(true); findData.SetStartWord(false); findData.SetRegEx (false); } // m_SearchedWord was set in BuildModuleMenu findData.SetFindText(text); // Displays m_pThreadSearchView in manager m_pViewManager->ShowView(true); // Runs the search through a worker thread m_pThreadSearchView->ThreadedSearch(findData); }
void ThreadSearchView::OnCboSearchExprEnter(wxCommandEvent &/*event*/) { // Event handler used when user clicks on enter after typing // in combo box text control. // Runs a multi threaded search. ThreadSearchFindData findData = m_ThreadSearchPlugin.GetFindData(); findData.SetFindText(m_pCboSearchExpr->GetValue()); ThreadedSearch(findData); }
void ThreadSearchView::OnBtnSearchClick(wxCommandEvent &/*event*/) { // User clicked on Search/Cancel // m_ThreadSearchEventsArray is shared by two threads, we // use m_MutexSearchEventsArray to have a safe access. // As button action depends on m_ThreadSearchEventsArray, // we lock the mutex to process it correctly. if ( m_MutexSearchEventsArray.Lock() == wxMUTEX_NO_ERROR ) { int nbEvents = m_ThreadSearchEventsArray.GetCount(); m_MutexSearchEventsArray.Unlock(); if ( m_pFindThread != NULL ) { // A threaded search is running... UpdateSearchButtons(false); StopThread(); } else if ( nbEvents > 0 ) { // A threaded search has run but the events array is // not completely processed... UpdateSearchButtons(false); if ( ClearThreadSearchEventsArray() == false ) { cbMessageBox(_("Failed to clear events array."), _("Error"), wxICON_ERROR); } } else { // We start the thread search ThreadSearchFindData findData = m_ThreadSearchPlugin.GetFindData(); findData.SetFindText(m_pCboSearchExpr->GetValue()); ThreadedSearch(findData); } } }