SearchData TaskPanel::DoGetSearchData() { SearchData data; data.SetDisplayScope(true); data.SetRegularExpression(true); data.SetMatchCase(false); data.SetMatchWholeWord(false); data.SetEncoding(m_choiceEncoding->GetStringSelection()); data.SetOwner(this); wxString sfind; // Load all info from disk TasksPanelData d; EditorConfigST::Get()->ReadObject(wxT("TasksPanelData"), &d); std::map<wxString, wxString>::const_iterator iter = d.GetTasks().begin(); for(; iter != d.GetTasks().end(); iter++) { wxString name = iter->first; wxString regex = iter->second; bool enabled = (d.GetEnabledItems().Index(iter->first) != wxNOT_FOUND); regex.Trim().Trim(false); wxRegEx re(regex); if(enabled && !regex.IsEmpty() && re.IsValid()) sfind << wxT("(") << regex << wxT(")|"); } if(sfind.empty() == false) sfind.RemoveLast(); data.SetFindString(sfind); wxString rootDir = m_scope->GetStringSelection(); wxArrayString rootDirs; rootDirs.push_back(rootDir); data.SetRootDirs(rootDirs); wxArrayString files; if(rootDir == wxGetTranslation(SEARCH_IN_WORKSPACE)) { ManagerST::Get()->GetWorkspaceFiles(files); } else if(rootDir == wxGetTranslation(SEARCH_IN_PROJECT)) { ManagerST::Get()->GetActiveProjectFiles(files); } else if(rootDir == wxGetTranslation(SEARCH_IN_CURR_FILE_PROJECT)) { ManagerST::Get()->GetActiveFileProjectFiles(files); } data.SetFiles(files); data.SetExtensions(wxT("*.*")); return data; }
SearchData TaskPanel::DoGetSearchData() { SearchData data; data.SetDisplayScope(true); data.SetRegularExpression(true); data.SetMatchCase(false); data.SetMatchWholeWord(false); data.SetEncoding(m_choiceEncoding->GetStringSelection()); data.SetOwner(this); wxString sfind; // Load all info from disk TasksPanelData d; EditorConfigST::Get()->ReadObject(wxT("TasksPanelData"), &d); wxStringMap_t::const_iterator iter = d.GetTasks().begin(); for(; iter != d.GetTasks().end(); iter++) { wxString name = iter->first; wxString regex = iter->second; bool enabled = (d.GetEnabledItems().Index(iter->first) != wxNOT_FOUND); regex.Trim().Trim(false); wxRegEx re(regex); if(enabled && !regex.IsEmpty() && re.IsValid()) sfind << wxT("(") << regex << wxT(")|"); } if(sfind.empty() == false) sfind.RemoveLast(); data.SetFindString(sfind); wxString rootDir = clWorkspaceManager::Get().GetWorkspace()->GetFileName().GetPath(); wxArrayString rootDirs; rootDirs.push_back(rootDir); data.SetRootDirs(rootDirs); data.SetExtensions(wxT("*.*")); return data; }
SearchData FindInFilesDialog::DoGetSearchData() { SearchData data; wxString findStr(m_data.GetFindString()); if(m_findString->GetValue().IsEmpty() == false) { findStr = m_findString->GetValue(); } data.SetFindString(findStr); m_data.SetFlags(GetSearchFlags()); size_t flags = m_data.GetFlags(); // If the 'Skip comments' is ON, remove the // 'colour comments' flag if(flags & wxFRD_SKIP_COMMENTS) { flags &= ~wxFRD_COLOUR_COMMENTS; } data.SetMatchCase((flags & wxFRD_MATCHCASE) != 0); data.SetMatchWholeWord((flags & wxFRD_MATCHWHOLEWORD) != 0); data.SetRegularExpression((flags & wxFRD_REGULAREXPRESSION) != 0); data.SetDisplayScope((flags & wxFRD_DISPLAYSCOPE) != 0); data.SetEncoding(m_choiceEncoding->GetStringSelection()); data.SetSkipComments(flags & wxFRD_SKIP_COMMENTS); data.SetSkipStrings(flags & wxFRD_SKIP_STRINGS); data.SetColourComments(flags & wxFRD_COLOUR_COMMENTS); wxArrayString rootDirs; for(size_t i = 0; i < m_listPaths->GetCount(); ++i) { rootDirs.push_back(m_listPaths->GetString(i)); } if(rootDirs.IsEmpty()) { wxString dir = m_dirPicker->GetPath(); if(dir.IsEmpty() == false) { rootDirs.push_back(dir); } } data.SetRootDirs(rootDirs); wxArrayString files; for(size_t i = 0; i < rootDirs.GetCount(); ++i) { const wxString& rootDir = rootDirs.Item(i); // Check both translations and otherwise: the history may contain either if((rootDir == wxGetTranslation(SEARCH_IN_WORKSPACE)) || (rootDir == SEARCH_IN_WORKSPACE)) { ManagerST::Get()->GetWorkspaceFiles(files); } else if((rootDir == wxGetTranslation(SEARCH_IN_PROJECT)) || (rootDir == SEARCH_IN_PROJECT)) { ManagerST::Get()->GetActiveProjectFiles(files); } else if((rootDir == wxGetTranslation(SEARCH_IN_CURR_FILE_PROJECT)) || (rootDir == SEARCH_IN_CURR_FILE_PROJECT)) { ManagerST::Get()->GetActiveFileProjectFiles(files); } else if((rootDir == wxGetTranslation(SEARCH_IN_CURRENT_FILE)) || (rootDir == SEARCH_IN_CURRENT_FILE)) { LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor(); if(editor) { files.Add(editor->GetFileName().GetFullPath()); } } else if((rootDir == wxGetTranslation(SEARCH_IN_OPEN_FILES)) || (rootDir == SEARCH_IN_OPEN_FILES)) { std::vector<LEditor*> editors; clMainFrame::Get()->GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_IncludeDetached); for(size_t n = 0; n < editors.size(); ++n) { LEditor* editor = dynamic_cast<LEditor*>(*(editors.begin() + n)); if(editor) { files.Add(editor->GetFileName().GetFullPath()); } } } } data.SetFiles(files); data.UseNewTab(m_checkBoxSeparateTab->IsChecked()); data.SetExtensions(m_fileTypes->GetValue()); return data; }
SearchData FindInFilesDialog::DoGetSearchData() { SearchData data; wxString findStr(m_data.GetFindString()); if(!m_findString->GetValue().IsEmpty()) { findStr = m_findString->GetValue(); } data.SetFindString(findStr); data.SetReplaceWith(m_replaceString->GetValue()); m_data.SetFlags(GetSearchFlags()); size_t flags = m_data.GetFlags(); // If the 'Skip comments' is ON, remove the // 'colour comments' flag if(flags & wxFRD_SKIP_COMMENTS) { flags &= ~wxFRD_COLOUR_COMMENTS; } data.SetMatchCase((flags & wxFRD_MATCHCASE) != 0); data.SetMatchWholeWord((flags & wxFRD_MATCHWHOLEWORD) != 0); data.SetRegularExpression((flags & wxFRD_REGULAREXPRESSION) != 0); data.SetDisplayScope((flags & wxFRD_DISPLAYSCOPE) != 0); data.SetEncoding(m_choiceEncoding->GetStringSelection()); data.SetSkipComments(flags & wxFRD_SKIP_COMMENTS); data.SetSkipStrings(flags & wxFRD_SKIP_STRINGS); data.SetColourComments(flags & wxFRD_COLOUR_COMMENTS); data.SetEnablePipeSupport(flags & wxFRD_ENABLE_PIPE_SUPPORT); wxArrayString searchWhere = m_listPaths->GetStrings(); wxArrayString files; wxArrayString rootDirs; for(size_t i = 0; i < searchWhere.GetCount(); ++i) { const wxString& rootDir = searchWhere.Item(i); // Check both translations and otherwise: the history may contain either if((rootDir == wxGetTranslation(SEARCH_IN_WORKSPACE)) || (rootDir == SEARCH_IN_WORKSPACE)) { if(!clWorkspaceManager::Get().IsWorkspaceOpened()) continue; clWorkspaceManager::Get().GetWorkspace()->GetWorkspaceFiles(files); } else if((rootDir == wxGetTranslation(SEARCH_IN_PROJECT)) || (rootDir == SEARCH_IN_PROJECT)) { if(!clWorkspaceManager::Get().IsWorkspaceOpened()) continue; if(clWorkspaceManager::Get().GetWorkspace()->IsProjectSupported()) { // get the active project files clWorkspaceManager::Get().GetWorkspace()->GetProjectFiles("", files); } else { // search the entire workspace clWorkspaceManager::Get().GetWorkspace()->GetWorkspaceFiles(files); } } else if((rootDir == wxGetTranslation(SEARCH_IN_CURR_FILE_PROJECT)) || (rootDir == SEARCH_IN_CURR_FILE_PROJECT)) { if(!clWorkspaceManager::Get().IsWorkspaceOpened()) continue; IEditor* editor = clGetManager()->GetActiveEditor(); if(!editor) continue; if(clWorkspaceManager::Get().GetWorkspace()->IsProjectSupported()) { wxString projectName = clWorkspaceManager::Get().GetWorkspace()->GetProjectFromFile(editor->GetFileName()); clWorkspaceManager::Get().GetWorkspace()->GetProjectFiles(projectName, files); } else { // search the entire workspace clWorkspaceManager::Get().GetWorkspace()->GetWorkspaceFiles(files); } } else if((rootDir == wxGetTranslation(SEARCH_IN_CURRENT_FILE)) || (rootDir == SEARCH_IN_CURRENT_FILE)) { LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor(); if(editor) { files.Add(editor->GetFileName().GetFullPath()); } } else if((rootDir == wxGetTranslation(SEARCH_IN_OPEN_FILES)) || (rootDir == SEARCH_IN_OPEN_FILES)) { std::vector<LEditor*> editors; clMainFrame::Get()->GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_IncludeDetached); for(size_t n = 0; n < editors.size(); ++n) { LEditor* editor = dynamic_cast<LEditor*>(*(editors.begin() + n)); if(editor) { files.Add(editor->GetFileName().GetFullPath()); } } } else if(wxFileName::DirExists(searchWhere.Item(i))) { rootDirs.Add(searchWhere.Item(i)); } } // Remove duplicates wxStringSet_t filesSet; wxArrayString uniqueFiles; std::for_each(files.begin(), files.end(), [&](const wxString& file) { if(filesSet.count(file) == 0) { filesSet.insert(file); uniqueFiles.Add(file); } }); files.swap(uniqueFiles); data.SetFiles(files); // list of files data.SetRootDirs(rootDirs); // folders data.UseNewTab(false); data.SetExtensions(m_fileTypes->GetValue()); return data; }