void SEditorColourSet::SetFileMasks(HighlightLanguage lang, const wxString& masks, const wxString& separator) { if (lang != HL_NONE) { m_Sets[lang].m_FileMasks = GetArrayFromString(masks.Lower(), separator); // let's add these filemasks in the file filters master list ;) FileFilters::Add(wxString::Format(_("%s files"), m_Sets[lang].m_Langs.c_str()), masks); } }
void ExternalDepsDlg::FillExternal() { wxListBox* lst = XRCCTRL(*this, "lstExternalFiles", wxListBox); lst->Clear(); wxArrayString array = GetArrayFromString(m_pTarget->GetExternalDeps()); for (unsigned int i = 0; i < array.GetCount(); ++i) { lst->Append(array[i]); } }
bool MSVC7Loader::ParseInputString(const wxString& Input, wxArrayString& Output) { /* This function will parse an input string recursively * with separators (',' and ';') */ wxArrayString Array1, Array2; if (Input.IsEmpty()) return false; Array1 = GetArrayFromString(Input, _T(",")); for (size_t i = 0; i < Array1.GetCount(); ++i) { if (Array1[i].Find(_T(";")) != -1) { Array2 = GetArrayFromString(Array1[i], _T(";")); for (size_t j = 0; j < Array2.GetCount(); ++j) Output.Add(Array2[j]); } else Output.Add(Array1[i]); } return true; }
bool FileFilters::GetFilterNameFromIndex(const wxString& FiltersList, int Index, wxString& FilterName) { // we return the name (not the mask) bool bFound = false; // the List will contain 2 entries per type (description, mask) wxArrayString List = GetArrayFromString(FiltersList, _T("|"), true); int LoopEnd = static_cast<int>(List.GetCount()); if (2*Index < LoopEnd) { FilterName = List[2*Index]; bFound = true; } return bFound; } // end of GetFilterStringFromIndex
void LogManager::Log(const wxString& msg, int i, Logger::level lv) { // The '\f' FormFeed is used as window clear if( msg.Find(_T('\f')) != wxNOT_FOUND ) { ClearLog(i); wxArrayString subString = GetArrayFromString(msg, _T('\f')); LogInternal(subString.Last(), i, lv); } else { LogInternal(msg, i, lv); } }
void AdvancedCompilerOptionsDlg::SaveCommands(int cmd, int ext) { if (cmd == -1 || ext == -1) return; if (CompilerTool* tool = GetCompilerTool(cmd, ext)) { wxTextCtrl* text = XRCCTRL(*this, "txtCommand", wxTextCtrl); wxTextCtrl* gen = XRCCTRL(*this, "txtGenerated", wxTextCtrl); if (text->GetValue() != tool->command) // last command was changed; save it tool->command = text->GetValue(); wxString gens = GetStringFromArray(tool->generatedFiles, _T("\n"), false); if (gen->GetValue() != gens) // last genfiles are changed; save it tool->generatedFiles = GetArrayFromString(gen->GetValue(), _T("\n")); } }
bool EditorLexerLoader::DoLangAttributesLexerStyles(TiXmlElement* attribs, const char *attributeName, std::set<int> &styles) { styles.clear(); wxString str = wxString ( attribs->Attribute(attributeName), wxConvUTF8 ); wxArrayString strarray = GetArrayFromString(str, _T(",")); for ( unsigned int i = 0; i < strarray.Count(); ++i ) { long style; strarray[i].ToLong(&style); styles.insert((unsigned int)style); } return !str.IsEmpty(); }
WizCompilerPanel::WizCompilerPanel(const wxString& compilerID, const wxString& validCompilerIDs, wxWizard* parent, const wxBitmap& bitmap, bool allowCompilerChange, bool allowConfigChange) : WizPageBase(_T("CompilerPage"), parent, bitmap), m_AllowConfigChange(allowConfigChange) { m_pCompilerPanel = new CompilerPanel(this, GetParent()); wxArrayString valids = GetArrayFromString(validCompilerIDs, _T(";"), true); wxString def = compilerID; if (def.IsEmpty()) def = CompilerFactory::GetDefaultCompilerID(); int id = 0; wxComboBox* cmb = m_pCompilerPanel->GetCompilerCombo(); cmb->Clear(); for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i) { Compiler* compiler = CompilerFactory::GetCompiler(i); if (compiler) { for (size_t n = 0; n < valids.GetCount(); ++n) { // match not only if IDs match, but if ID inherits from it too if (CompilerFactory::CompilerInheritsFrom(compiler, valids[n])) { cmb->Append(compiler->GetName()); if (compiler->GetID().IsSameAs(def)) id = (cmb->GetCount() - 1) < 0 ? 0 : (cmb->GetCount() - 1); break; } } } } cmb->SetSelection(id); cmb->Enable(allowCompilerChange); m_pCompilerPanel->EnableConfigurationTargets(m_AllowConfigChange); ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("scripts")); m_pCompilerPanel->SetWantDebug(cfg->ReadBool(_T("/generic_wizard/want_debug"), true)); m_pCompilerPanel->SetDebugName(cfg->Read(_T("/generic_wizard/debug_name"), _T("Debug"))); m_pCompilerPanel->SetDebugOutputDir(cfg->Read(_T("/generic_wizard/debug_output"), _T("bin") + wxString(wxFILE_SEP_PATH) + _T("Debug"))); m_pCompilerPanel->SetDebugObjectOutputDir(cfg->Read(_T("/generic_wizard/debug_objects_output"), _T("obj") + wxString(wxFILE_SEP_PATH) + _T("Debug"))); m_pCompilerPanel->SetWantRelease(cfg->ReadBool(_T("/generic_wizard/want_release"), true)); m_pCompilerPanel->SetReleaseName(cfg->Read(_T("/generic_wizard/release_name"), _T("Release"))); m_pCompilerPanel->SetReleaseOutputDir(cfg->Read(_T("/generic_wizard/release_output"), _T("bin") + wxString(wxFILE_SEP_PATH) + _T("Release"))); m_pCompilerPanel->SetReleaseObjectOutputDir(cfg->Read(_T("/generic_wizard/release_objects_output"), _T("obj") + wxString(wxFILE_SEP_PATH) + _T("Release"))); }
bool FileFilters::GetFilterIndexFromName(const wxString& FiltersList, const wxString& FilterName, int& Index) { bool bFound = false; // the List will contain 2 entries per type (description, mask) wxArrayString List = GetArrayFromString(FiltersList, _T("|"), true); int LoopEnd = static_cast<int>(List.GetCount()); for(int idxList = 0; idxList < LoopEnd; idxList+=2) { if (List[idxList] == FilterName) { Index = idxList/2; bFound = true; break; } } // end for : idx : idxList return bFound; } // end of GetFilterIndexFromName
void SpellCheckerConfig::DetectDictionaryPath() { wxArrayString dictPaths; dictPaths.Add(m_DictPath); Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dictPaths[0]); if (platform::windows) { wxString programs = wxT("C:\\Program Files"); wxGetEnv(wxT("ProgramFiles"), &programs); dictPaths.Add(programs + wxT("\\Mozilla Firefox\\dictionaries")); dictPaths.Add(programs + wxT("\\Mozilla\\Firefox\\dictionaries")); dictPaths.Add(programs + wxT("\\Mozilla Thunderbird\\dictionaries")); dictPaths.Add(programs + wxT("\\Mozilla\\Thunderbird\\dictionaries")); wxString libreOffice = wxFindFirstFile(programs + wxT("\\*LibreOffice*"), wxDIR); wxString openOffice = wxFindFirstFile(programs + wxT("\\*OpenOffice*"), wxDIR); wxArrayString langs = GetArrayFromString(wxT("en;fr;es;de")); for (size_t i = 0; i < langs.GetCount(); ++i) { if (!libreOffice.IsEmpty()) dictPaths.Add(libreOffice + wxT("\\share\\extensions\\dict-") + langs[i]); if (!openOffice.IsEmpty()) dictPaths.Add(openOffice + wxT("\\share\\extensions\\dict-") + langs[i]); } } else { dictPaths.Add(wxT("/usr/share/hunspell")); dictPaths.Add(wxT("/usr/share/myspell/dicts")); dictPaths.Add(wxT("/usr/share/myspell")); } dictPaths.Add(m_pPlugin->GetOnlineCheckerConfigPath()); for (size_t i = 0; i < dictPaths.GetCount(); ++i) { if ( wxDirExists(dictPaths[i]) && !wxFindFirstFile(dictPaths[i] + wxFILE_SEP_PATH + wxT("*.dic"), wxFILE).IsEmpty() ) { if (i != 0) m_DictPath = dictPaths[i]; Manager::Get()->GetLogManager()->DebugLog(_T("Detected dict path: ") + m_DictPath); break; } } }
WizBuildTargetPanel::WizBuildTargetPanel(const wxString& targetName, bool isDebug, wxWizard* parent, const wxBitmap& bitmap, bool showCompiler, const wxString& compilerID, const wxString& validCompilerIDs, bool allowCompilerChange) : WizPageBase(_T("BuildTargetPage"), parent, bitmap) { m_pBuildTargetPanel = new BuildTargetPanel(this); m_pBuildTargetPanel->SetTargetName(targetName); m_pBuildTargetPanel->SetEnableDebug(isDebug); m_pBuildTargetPanel->ShowCompiler(showCompiler); if (showCompiler) { wxArrayString valids = GetArrayFromString(validCompilerIDs, _T(";"), true); wxString def = compilerID; if (def.IsEmpty()) def = CompilerFactory::GetDefaultCompiler()->GetName(); int id = 0; wxComboBox* cmb = m_pBuildTargetPanel->GetCompilerCombo(); cmb->Clear(); for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i) { for (size_t n = 0; n < valids.GetCount(); ++n) { Compiler* compiler = CompilerFactory::GetCompiler(i); if (compiler) { if (compiler->GetID().Matches(valids[n])) { cmb->Append(compiler->GetName()); if (compiler->GetID().IsSameAs(def)) id = cmb->GetCount(); break; } } } } cmb->SetSelection(id); cmb->Enable(allowCompilerChange); } }
void DebuggerTree::BuildTreeCDB(Watch* watch, const wxString& infoText) { //Local variables // hThisInstance = 0x00400000 // hPrevInstance = 0x00000000 // lpszArgument = 0x00151ef5 "" // nCmdShow = 10 // hwnd = 0x7ffd8000 // messages = struct tagMSG // wincl = struct tagWNDCLASSEXA wxTreeItemId parent = m_pTree->GetRootItem(); wxTreeItemId node = parent; wxArrayString lines = GetArrayFromString(infoText, _T('\n'), false); for (unsigned int i = 0; i < lines.GetCount(); ++i) { size_t thiscol = lines[i].find_first_not_of(_T(" \t")); size_t nextcol = i < lines.GetCount() - 1 ? lines[i + 1].find_first_not_of(_T(" \t")) : wxString::npos; bool opbrace = false; bool clbrace = false; if (thiscol < nextcol) { // add child node parent = node; opbrace = true; } else if (thiscol > nextcol) { // go one level up parent = m_pTree->GetItemParent(parent); clbrace = true; } if (opbrace) lines[i].Append(_T(" = {")); if (clbrace) lines[i].Append(_T("}")); } wxString str = GetStringFromArray(lines, _T(",")); ParseEntry(m_RootEntry, watch, str); }
wxString cbFindFileInPATH(const wxString &filename) { wxString pathValues; wxGetEnv(_T("PATH"), &pathValues); if (pathValues.empty()) return wxEmptyString; const wxString &sep = platform::windows ? _T(";") : _T(":"); wxChar pathSep = wxFileName::GetPathSeparator(); const wxArrayString &pathArray = GetArrayFromString(pathValues, sep); for (size_t i = 0; i < pathArray.GetCount(); ++i) { if (wxFileExists(pathArray[i] + pathSep + filename)) { if (pathArray[i].AfterLast(pathSep).IsSameAs(_T("bin"))) return pathArray[i]; } } return wxEmptyString; }
void ProjectOptionsDlg::OnAddScript(wxCommandEvent& /*event*/) { wxListBox* ctrl = XRCCTRL(*this, "lstPreScripts", wxListBox); if (!ctrl) return; wxFileName fname; if (ctrl->GetSelection()) fname.Assign(ctrl->GetStringSelection()); else if (ctrl->GetCount()) fname.Assign(ctrl->GetString(ctrl->GetCount() - 1)); fname.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, m_Project->GetBasePath()); EditPathDlg dlg(this, fname.GetFullName(), wxEmptyString,//fname.GetPath(), _("Add script(s)"), _("Select script file(s)"), false, true, _("Script files (*.script)|*.script")); PlaceWindow(&dlg); if (dlg.ShowModal() != wxID_OK) return; wxArrayString paths = GetArrayFromString(dlg.GetPath()); for (size_t i = 0; i < paths.GetCount(); ++i) { fname.Assign(paths[i]); fname.MakeRelativeTo(m_Project->GetBasePath()); ctrl->Append(fname.GetFullPath()); ctrl->SetSelection(ctrl->GetCount()-1); wxTreeCtrl* tc = XRCCTRL(*this, "tcOverview", wxTreeCtrl); wxTreeItemId sel = tc->GetSelection(); CompileOptionsBase* base = sel == tc->GetRootItem() ? static_cast<CompileOptionsBase*>(m_Project) : static_cast<CompileOptionsBase*>(m_Project->GetBuildTarget(tc->GetItemText(sel))); base->AddBuildScript(fname.GetFullPath()); } }
void DefaultMimeHandler::OnAttach() { // load configuration WX_CLEAR_ARRAY(m_MimeTypes); ConfigManager* conf = Manager::Get()->GetConfigManager(_T("mime_types")); wxArrayString list = conf->EnumerateKeys(_T("/")); for (unsigned int i = 0; i < list.GetCount(); ++i) { wxArrayString array = GetArrayFromString(conf->Read(list[i]), _T(";"), false); if (array.GetCount() < 3) continue; cbMimeType* mt = new cbMimeType; mt->useEditor = (array[0] == _T("true")); mt->useAssoc = (array[1] == _T("true")); mt->programIsModal = (array[2] == _T("true")); mt->wildcard = array[3]; mt->program = (array.GetCount() == 5 ? array[4] : _T("")); mt->program.Trim(); if (!mt->useEditor && !mt->useAssoc && mt->program.IsEmpty()) delete mt; else m_MimeTypes.Add(mt); } m_Html = new EmbeddedHtmlPanel(Manager::Get()->GetAppWindow()); CodeBlocksDockEvent evt(cbEVT_ADD_DOCK_WINDOW); evt.pWindow = m_Html; evt.name = _T("DefMimeHandler_HTMLViewer"); evt.title = _("HTML viewer"); evt.dockSide = CodeBlocksDockEvent::dsFloating; evt.desiredSize.Set(350, 250); evt.floatingSize.Set(350, 250); evt.minimumSize.Set(150, 150); evt.shown = false; Manager::Get()->ProcessEvent(evt); }
bool xmlFile::CWElement(wxString& filename) { if(!m_pWorkingElement) return false; TiXmlElement* curElement = m_pWorkingElement; wxArrayString elements = GetArrayFromString(filename, _T('/')); for(size_t i=0; i < elements.GetCount(); i++) { if(elements[i] == _T(".")) continue; if(elements[i] == _T("..")) { if(!CWElementToParent()) { m_pWorkingElement = curElement; return false; } } else { TiXmlElement* tmp = m_pWorkingElement->FirstChildElement(cbU2C(elements[i])); if(tmp) { m_pWorkingElement = tmp; } else { m_pWorkingElement = curElement; return false; } } } return ( curElement == m_pWorkingElement ? false :true); }
wxArrayString MSVC10Loader::GetPreprocessors(const TiXmlElement* e) { wxArrayString sResult; if (e) { wxString preproc = GetText(e); wxArrayString preprocWithMacros; if (!preproc.IsEmpty()) preprocWithMacros = GetArrayFromString(preproc, _T(";")); for (size_t i=0; i<preprocWithMacros.Count(); ++i) { wxString sPreproc = preprocWithMacros.Item(i); // Specific: for ItemGroups (not Dollar, but percentage) sPreproc.Replace(wxT("%(PreprocessorDefinitions)"), wxEmptyString); // not supported if (!sPreproc.Trim().IsEmpty()) sResult.Add(sPreproc); } } return sResult; }
wxArrayString MSVC10Loader::GetOptions(const TiXmlElement* e) { wxArrayString sResult; if (e) { wxString opts = GetText(e); wxArrayString optsWithMacros; if (!opts.IsEmpty()) optsWithMacros = GetArrayFromString(opts, _T(" ")); for (size_t i=0; i<optsWithMacros.Count(); ++i) { wxString sOpt = optsWithMacros.Item(i); // Specific: for ItemGroups (not Dollar, but percentage) sOpt.Replace(wxT("%(AdditionalOptions)"), wxEmptyString); // not supported if (!sOpt.Trim().IsEmpty()) sResult.Add(sOpt); } } return sResult; }
wxArrayString MSVC10Loader::GetArray(const TiXmlElement* e, wxString delim) { wxArrayString sResult; if (e) { wxString val = GetText(e); // Specific: for ItemGroups (not Dollar, but percentage) val.Replace(_T("%(PreprocessorDefinitions)"), wxEmptyString); // not supported val.Replace(_T("%(AdditionalOptions)"), wxEmptyString); // not supported val.Replace(_T("%(DisableSpecificWarnings)"), wxEmptyString); // not supported if (!val.IsEmpty()){ wxArrayString aVal = GetArrayFromString(val, delim); for (size_t i=0; i<aVal.Count(); ++i) { val = aVal.Item(i); if (!val.Trim().IsEmpty()) sResult.Add(val); } } } return sResult; }
wxArrayString MSVC10Loader::GetLibs(const TiXmlElement* e) { wxArrayString sResult; wxString val; if (e) val = GetText(e); else val=_T("%(AdditionalDependencies)"); // Specific: for ItemGroups (not Dollar, but percentage) val.Replace(_T("%(AdditionalDependencies)"), g_AdditionalDependencies); if (!val.IsEmpty()) { wxArrayString aVal = GetArrayFromString(val, _T(";")); for (size_t i=0; i<aVal.Count(); ++i) { val = aVal.Item(i); if (!val.Trim().IsEmpty()) sResult.Add(val); } } return sResult; }
wxArrayString MSVC10Loader::GetLibs(const TiXmlElement* e) { wxArrayString sResult; if (e) { wxString libs = GetText(e); wxArrayString libsWithMacros; if (!libs.IsEmpty()) libsWithMacros = GetArrayFromString(libs, _T(";")); for (size_t i=0; i<libsWithMacros.Count(); ++i) { wxString sLib = libsWithMacros.Item(i); // Specific: for ItemGroups (not Dollar, but percentage) sLib.Replace(wxT("%(AdditionalDependencies)"), wxEmptyString); // not supported if (!sLib.Trim().IsEmpty()) sResult.Add(sLib); } } return sResult; }
void SpellCheckerConfig::DetectThesaurusPath() { wxArrayString thesPaths; thesPaths.Add(m_ThesPath); Manager::Get()->GetMacrosManager()->ReplaceEnvVars(thesPaths[0]); if (platform::windows) { wxString programs = wxT("C:\\Program Files"); wxGetEnv(wxT("ProgramFiles"), &programs); wxString libreOffice = wxFindFirstFile(programs + wxT("\\*LibreOffice*"), wxDIR); wxString openOffice = wxFindFirstFile(programs + wxT("\\*OpenOffice*"), wxDIR); wxArrayString langs = GetArrayFromString(wxT("en;fr;es;de")); for (size_t i = 0; i < langs.GetCount(); ++i) { if (!libreOffice.IsEmpty()) thesPaths.Add(libreOffice + wxT("\\share\\extensions\\dict-") + langs[i]); if (!openOffice.IsEmpty()) thesPaths.Add(openOffice + wxT("\\share\\extensions\\dict-") + langs[i]); } } else { thesPaths.Add(wxT("/usr/share/myspell/dicts")); thesPaths.Add(wxT("/usr/share/mythes")); } thesPaths.Add(m_pPlugin->GetOnlineCheckerConfigPath()); for (size_t i = 0; i < thesPaths.GetCount(); ++i) { if ( wxDirExists(thesPaths[i]) && !wxFindFirstFile(thesPaths[i] + wxFILE_SEP_PATH + wxT("th*.dat"), wxFILE).IsEmpty() ) { if (i != 0) m_ThesPath = thesPaths[i]; Manager::Get()->GetLogManager()->DebugLog(_T("Detected thes path: ") + m_ThesPath); break; } } }
wxString FileFilters::GetFilterString(const wxString& ext) { size_t count = 0; wxString ret; for (FileFiltersMap::iterator it = s_Filters.begin(); it != s_Filters.end(); ++it) { if (!ext.IsEmpty()) { // filter based on parameter bool match = false; wxArrayString array = GetArrayFromString(it->second, _T(";"), true); for (size_t i = 0; i < array.GetCount(); ++i) { if (ext.Matches(array[i])) { match = true; break; } } if (!match) continue; // filtered } ++count; if (!ret.IsEmpty()) ret << _T('|'); ret << it->first << _T('|') << it->second; } // last filter is always "All" if (!ret.IsEmpty()) ret << _T('|'); ret << GetFilterAll(); s_LastFilterAllIndex = count; return ret; }
wxArrayString MSVC10Loader::GetDirectories(const TiXmlElement* e) { wxArrayString sResult; if (e) { wxString dirs = GetText(e); wxArrayString dirsWithMacros; if (!dirs.IsEmpty()) dirsWithMacros = GetArrayFromString(dirs, _T(";")); for (size_t i=0; i<dirsWithMacros.Count(); ++i) { wxString sDir = dirsWithMacros.Item(i); // Specific: for ItemGroups (not Dollar, but percentage) sDir.Replace(wxT("%(AdditionalIncludeDirectories)"), wxEmptyString); // not supported sDir.Replace(wxT("%(AdditionalLibraryDirectories)"), wxEmptyString); // not supported if (!sDir.Trim().IsEmpty()) sResult.Add(sDir); } } return sResult; }
void EditorTweaks::DoAlignAuto() { cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if (!ed) return; cbStyledTextCtrl* stc = ed->GetControl(); if (!stc) return; int line_start = wxSCI_INVALID_POSITION; int line_end = wxSCI_INVALID_POSITION; if (!GetSelectionLines(line_start, line_end)) return; wxArrayString lines; for (int i = line_start; i <= line_end; ++i) lines.Add(stc->GetLine(i)); if (lines.GetCount() < 2) return; int lexer = stc->GetLexer(); wxArrayString out; for (size_t i = 0; i < lines.GetCount(); ++i) { lines[i].Replace(wxT("\t"), wxT(" ")); // buffer assignment operators and commas in C++ if (lexer == wxSCI_LEX_CPP) { const wxString op = wxT("=<>!+-*/%&^| "); // do not split compound operators for (int j = lines[i].Length() - 2; j >= 0; --j) { if ( lines[i][j] == wxT(',') || (lines[i][j] == wxT('=') && lines[i][j + 1] != wxT('=')) || (lines[i][j + 1] == wxT('=') && op.Find(lines[i][j]) == wxNOT_FOUND) ) { lines[i].insert(j + 1, wxT(' ')); } } } // initialize output strings with their current indentation out.Add(ed->GetLineIndentString(line_start + i)); } // loop through number of columns size_t numCols = 1; for (size_t i = 0; i < numCols; ++i) { // add the next token for (size_t j = 0; j < lines.GetCount(); ++j) { wxArrayString lnParts = GetArrayFromString(lines[j], wxT(" ")); if (i < lnParts.GetCount()) out[j].Append(lnParts[i]); // set actual number of columns if (lnParts.GetCount() > numCols) numCols = lnParts.GetCount(); } // find the column size size_t colPos = 0; for (size_t j = 0; j < out.GetCount(); ++j) { if (out[j].Length() > colPos) colPos = out[j].Length(); } // buffer output lines to column size + 1 for (size_t j = 0; j < out.GetCount(); ++j) { while (out[j].Length() <= colPos) out[j].Append(wxT(' ')); } } // replace only the lines that have been modified stc->BeginUndoAction(); for (size_t i = 0; i < out.GetCount(); ++i) { stc->SetSelectionVoid(stc->PositionFromLine(line_start + i), stc->GetLineEndPosition(line_start + i)); if (stc->GetSelectedText() != out[i].Trim()) stc->ReplaceSelection(out[i]); } stc->LineEnd(); // remove selection (if last line was not replaced) stc->EndUndoAction(); AlignerLastUsedAuto = true; AlignerLastUsed = true; }
void EditorColourSet::Load() { // no need for syntax highlighting if batch building if (Manager::IsBatchBuild()) return; static bool s_notifiedUser = false; wxString key; ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor")); // read the theme name m_Name = cfg->Read(_T("/colour_sets/") + m_Name + _T("/name"), m_Name); int x = 0; for (OptionSetsMap::iterator it = m_Sets.begin(); it != m_Sets.end(); ++it) { if (it->first == HL_NONE || it->first == HL_AUTO) continue; // look for old-style configuration key.Clear(); key << _T("/colour_sets/") << m_Name << _T("/set") << wxString::Format(_T("%d"), x++); if (cfg->Exists(key + _T("/name"))) { // old-style configuration // delete it and tell the user about it cfg->DeleteSubPath(key); if (!s_notifiedUser) { cbMessageBox(_("The way editor syntax highlighting configuration is saved, has changed.\n" "Syntax highlighting for all supported languages will revert to defaults now.\n" "We 're sorry for the inconvenience..."), _("Information"), wxICON_INFORMATION); s_notifiedUser = true; } continue; } // make sure we didn't create it accidentally cfg->DeleteSubPath(key); // new-style configuration key key.Clear(); key << _T("/colour_sets/") << m_Name << _T('/') << it->first; if (!cfg->Exists(key + _T("/name"))) { // make sure we didn't create it accidentally cfg->DeleteSubPath(key); continue; } for (unsigned int i = 0; i < it->second.m_Colours.GetCount(); ++i) { wxString tmpKey; tmpKey << key << _T("/style") << wxString::Format(_T("%u"), i); if (!cfg->Exists(tmpKey + _T("/name"))) { // make sure we didn't create it accidentally cfg->DeleteSubPath(tmpKey); continue; } wxString name = cfg->Read(tmpKey + _T("/name")); for (size_t j = 0; j < it->second.m_Colours.GetCount(); ++j) { OptionColour* opt = it->second.m_Colours.Item(j); if (!opt || opt->name != name) continue; if (cfg->Exists(tmpKey + _T("/fore"))) opt->fore = cfg->ReadColour(tmpKey + _T("/fore"), opt->fore); if (cfg->Exists(tmpKey + _T("/back"))) opt->back = cfg->ReadColour(tmpKey + _T("/back"), opt->back); if (cfg->Exists(tmpKey + _T("/bold"))) opt->bold = cfg->ReadBool(tmpKey + _T("/bold"), opt->bold); if (cfg->Exists(tmpKey + _T("/italics"))) opt->italics = cfg->ReadBool(tmpKey + _T("/italics"), opt->italics); if (cfg->Exists(tmpKey + _T("/underlined"))) opt->underlined = cfg->ReadBool(tmpKey + _T("/underlined"), opt->underlined); if (cfg->Exists(tmpKey + _T("/isStyle"))) opt->isStyle = cfg->ReadBool(tmpKey + _T("/isStyle"), opt->isStyle); } } wxString tmpkey; for (int i = 0; i <= wxSCI_KEYWORDSET_MAX; ++i) { tmpkey.Printf(_T("%s/editor/keywords/set%d"), key.c_str(), i); if (cfg->Exists(tmpkey)) it->second.m_Keywords[i] = cfg->Read(tmpkey, wxEmptyString); } tmpkey.Printf(_T("%s/editor/filemasks"), key.c_str()); if (cfg->Exists(tmpkey)) it->second.m_FileMasks = GetArrayFromString(cfg->Read(tmpkey, wxEmptyString), _T(",")); } }
UpdateRec* ReadConf(const IniParser& ini, int* recCount, const wxString& currentServer, const wxString& appPath) { *recCount = 0; int groupsCount = ini.GetGroupsCount(); if (groupsCount == 0) return 0; UpdateRec* list = new UpdateRec[ini.GetGroupsCount()]; for (int i = 0; i < groupsCount; ++i) { UpdateRec& rec = list[i]; rec.title = ini.GetGroupName(i); // fix title // devpaks.org has changed the title to contain some extra info // e.g.: [libunicows Library version: 1.1.1 Devpak revision: 1sid] int pos = rec.title.Lower().Find(_T("library version:")); if (pos != -1) { int revpos = rec.title.Lower().Find(_T("devpak revision:")); if (revpos != -1) { rec.revision = rec.title.Mid(revpos).AfterFirst(_T(':')).Trim(false); rec.revision.Replace(_T("\t"), _T(" ")); rec.revision = rec.revision.BeforeFirst(_T(' ')); } rec.title.Truncate(pos); rec.title = rec.title.Trim(false); rec.title = rec.title.Trim(true); } rec.name = ini.GetKeyValue(i, _T("Name")); rec.desc = ini.GetKeyValue(i, _T("Description")); rec.remote_file = ini.GetKeyValue(i, _T("RemoteFilename")); rec.local_file = ini.GetKeyValue(i, _T("LocalFilename")); rec.groups = GetArrayFromString(ini.GetKeyValue(i, _T("Group")), _T(",")); rec.install_path = ini.GetKeyValue(i, _T("InstallPath")); rec.version = ini.GetKeyValue(i, _T("Version")); ini.GetKeyValue(i, _T("Size")).ToLong(&rec.bytes); rec.date = ini.GetKeyValue(i, _T("Date")); rec.installable = ini.GetKeyValue(i, _T("Execute")) == _T("1"); // read .entry file (if exists) rec.entry = (!rec.name.IsEmpty() ? rec.name : wxFileName(rec.local_file).GetName()) + _T(".entry"); IniParser p; p.ParseFile(appPath + rec.entry); rec.installed_version = p.GetValue(_T("Setup"), _T("AppVersion")); rec.downloaded = wxFileExists(appPath + _T("/") + rec.local_file); rec.installed = !rec.installed_version.IsEmpty(); // calculate size rec.size = GetSizeString(rec.bytes); // fix-up if (rec.name.IsEmpty()) rec.name = rec.title; rec.desc.Replace(_T("<CR>"), _T("\n")); rec.desc.Replace(_T("<LF>"), _T("\r")); wxURL url(rec.remote_file); if (!url.GetServer().IsEmpty()) { rec.remote_server = url.GetScheme() + _T("://") + url.GetServer(); int pos = rec.remote_file.Find(url.GetServer()); if (pos != wxNOT_FOUND) rec.remote_file.Remove(0, pos + url.GetServer().Length() + 1); } else rec.remote_server = currentServer; } *recCount = groupsCount; return list; }
bool ParseCDBWatchValue(cb::shared_ptr<GDBWatch> watch, wxString const &value) { wxArrayString lines = GetArrayFromString(value, wxT('\n')); watch->SetDebugValue(value); watch->MarkChildsAsRemoved(); if (lines.GetCount() == 0) return false; static wxRegEx unexpected_error(wxT("^Unexpected token '.+'$")); static wxRegEx resolve_error(wxT("^Couldn't resolve error at '.+'$")); // search for errors for (unsigned ii = 0; ii < lines.GetCount(); ++ii) { if (unexpected_error.Matches(lines[ii]) || resolve_error.Matches(lines[ii]) || lines[ii] == wxT("No pointer for operator* '<EOL>'")) { watch->SetValue(lines[ii]); return true; } } if (lines.GetCount() == 1) { wxArrayString tokens = GetArrayFromString(lines[0], wxT(' ')); if (tokens.GetCount() < 2) return false; int type_token = 0; if (tokens[0] == wxT("class") || tokens[0] == wxT("struct")) type_token = 1; if (static_cast<int>(tokens.GetCount()) < type_token + 2) return false; int value_start = type_token + 1; if (tokens[type_token + 1] == wxT('*')) { watch->SetType(tokens[type_token] + tokens[type_token + 1]); value_start++; } else watch->SetType(tokens[type_token]); if(value_start >= static_cast<int>(tokens.GetCount())) return false; watch->SetValue(tokens[value_start]); watch->RemoveMarkedChildren(); return true; } else { wxArrayString tokens = GetArrayFromString(lines[0], wxT(' ')); if (tokens.GetCount() < 2) return false; bool set_type = true; if (tokens.GetCount() > 2) { if (tokens[0] == wxT("struct") || tokens[0] == wxT("class")) { if (tokens[2] == wxT('*') || tokens[2].StartsWith(wxT("["))) { watch->SetType(tokens[1] + tokens[2]); set_type = false; } } else { if (tokens[1] == wxT('*') || tokens[1].StartsWith(wxT("["))) { watch->SetType(tokens[0] + tokens[1]); watch->SetValue(lines[1]); return true; } } } if (set_type) watch->SetType(tokens[1]); static wxRegEx class_line(wxT("[ \\t]*\\+(0x[0-9a-f]+)[ \\t]([a-zA-Z0-9_]+)[ \\t]+:[ \\t]+(.+)")); if (!class_line.IsValid()) { int *p = NULL; *p = 0; } else { if (!class_line.Matches(wxT(" +0x000 a : 10"))) { int *p = NULL; *p = 0; } } for (unsigned ii = 1; ii < lines.GetCount(); ++ii) { if (class_line.Matches(lines[ii])) { cb::shared_ptr<GDBWatch> w = AddChild(watch, class_line.GetMatch(lines[ii], 2)); w->SetValue(class_line.GetMatch(lines[ii], 3)); w->SetDebugValue(lines[ii]); } } watch->RemoveMarkedChildren(); return true; } return false; }
bool MSVC7WorkspaceLoader::Open(const wxString& filename, wxString& Title) { bool askForCompiler = false; bool askForTargets = false; switch (cbMessageBox(_("Do you want the imported projects to use the default compiler?\n" "(If you answer No, you will be asked for each and every project" " which compiler to use...)"), _("Question"), wxICON_QUESTION | wxYES_NO | wxCANCEL)) { case wxID_YES: askForCompiler = false; break; case wxID_NO: askForCompiler = true; break; case wxID_CANCEL: return false; } switch (cbMessageBox(_("Do you want to import all configurations (e.g. Debug/Release) from the " "imported projects?\n" "(If you answer No, you will be asked for each and every project" " which configurations to import...)"), _("Question"), wxICON_QUESTION | wxYES_NO | wxCANCEL)) { case wxID_YES: askForTargets = false; break; case wxID_NO: askForTargets = true; break; case wxID_CANCEL: return false; } wxFileInputStream file(filename); if (!file.Ok()) return false; // error opening file??? wxArrayString comps; wxTextInputStream input(file); // read "header" if (!file.Eof()) { // skip unicode BOM, if present EncodingDetector detector(filename); if (detector.IsOK() && detector.UsesBOM()) { int skipBytes = detector.GetBOMSizeInBytes(); for (int i = 0; i < skipBytes; ++i) { char c; file.Read(&c, 1); } } wxString line = input.ReadLine(); // skip initial empty lines (if any) while (line.IsEmpty() && !file.Eof()) { line = input.ReadLine(); } comps = GetArrayFromString(line, _T(",")); line = comps[0]; line.Trim(true); line.Trim(false); if (line != _T("Microsoft Visual Studio Solution File")) { Manager::Get()->GetLogManager()->DebugLog(_T("Unsupported format.")); return false; } line = comps.GetCount() > 1 ? comps[1] : wxString(wxEmptyString); line.Trim(true); line.Trim(false); wxString _version = line.AfterLast(' '); // want the version number if ((_version != _T("7.00")) && (_version != _T("8.00"))) Manager::Get()->GetLogManager()->DebugLog(_T("Version not recognized. Will try to parse though...")); } ImportersGlobals::UseDefaultCompiler = !askForCompiler; ImportersGlobals::ImportAllTargets = !askForTargets; wxProgressDialog progress(_("Importing MSVC 7 solution"), _("Please wait while importing MSVC 7 solution..."), 100, 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); int count = 0; wxArrayString keyvalue; cbProject* project = 0; cbProject* firstproject = 0; wxString uuid; bool depSection = false; // ProjectDependencies section? bool slnConfSection = false; // SolutionConfiguration section? bool projConfSection = false; // ProjectConfiguration section? bool global = false; // global section or project section? wxFileName wfname = filename; wfname.Normalize(); Manager::Get()->GetLogManager()->DebugLog(_T("Workspace dir: ") + wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)); while (!file.Eof()) { wxString line = input.ReadLine(); line.Trim(true); line.Trim(false); if (line.StartsWith(_T("Project("))) { // example wanted line: //Project("{UUID of the solution}") = "project name to display", "project filename", "project UUID". // UUID type 4 for projects (i.e. random based), UUID type 1 for solutions (i.e. time+host based) keyvalue = GetArrayFromString(line, _T("=")); if (keyvalue.GetCount() != 2) continue; // ignore keyvalue[0], i.e. solution UUID/GUID // the second part contains the project title and filename comps = GetArrayFromString(keyvalue[1], _T(",")); if (comps.GetCount() < 3) continue; // read project title and trim quotes wxString prjTitle = comps[0]; prjTitle.Trim(true); prjTitle.Trim(false); if (prjTitle.IsEmpty()) continue; if (prjTitle.GetChar(0) == _T('\"')) { prjTitle.Truncate(prjTitle.Length() - 1); prjTitle.Remove(0, 1); } // read project filename and trim quotes wxString prjFile = comps[1]; prjFile.Trim(true); prjFile.Trim(false); if (prjFile.IsEmpty()) continue; if (prjFile.GetChar(0) == _T('\"')) { prjFile.Truncate(prjFile.Length() - 1); prjFile.Remove(0, 1); } // read project UUID, i.e. "{35AFBABB-DF05-43DE-91A7-BB828A874015}" uuid = comps[2]; uuid.Replace(_T("\""), _T("")); // remove quotes ++count; wxFileName fname(UnixFilename(prjFile)); fname.Normalize(wxPATH_NORM_ALL, wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR), wxPATH_NATIVE); #if wxCHECK_VERSION(2, 9, 0) Manager::Get()->GetLogManager()->DebugLog(F(_T("Found project '%s' in '%s'"), prjTitle.wx_str(), fname.GetFullPath().wx_str())); #else Manager::Get()->GetLogManager()->DebugLog(F(_T("Found project '%s' in '%s'"), prjTitle.c_str(), fname.GetFullPath().c_str())); #endif int percentage = ((int)file.TellI())*100 / (int)(file.GetLength()); if (!progress.Update(percentage, _("Importing project: ") + prjTitle)) break; project = Manager::Get()->GetProjectManager()->LoadProject(fname.GetFullPath(), false); if (!firstproject) firstproject = project; if (project) registerProject(uuid, project); } else if (line.StartsWith(_T("GlobalSection(ProjectDependencies)"))) { depSection = true; global = true; } else if (line.StartsWith(_T("ProjectSection(ProjectDependencies)"))) { depSection = true; global = false; } else if (line.StartsWith(_T("GlobalSection(ProjectConfiguration)"))) { projConfSection = true; } else if (line.StartsWith(_T("GlobalSection(SolutionConfiguration)"))) { slnConfSection = true; } else if (line.StartsWith(_T("EndGlobalSection")) || line.StartsWith(_T("EndProjectSection"))) { depSection = false; projConfSection = false; slnConfSection = false; } else if (depSection) { // start reading a dependency keyvalue = GetArrayFromString(line, _T("=")); if (keyvalue.GetCount() != 2) continue; if (global) { // {31635C8-67BF-4808-A918-0FBF822771BD}.0 = {658BFA12-8417-49E5-872A-33F0973544DC} // i.e. project on the left of '=' depend on the project on the right keyvalue[0]= keyvalue[0].BeforeFirst(_T('.')); addDependency(keyvalue[0], keyvalue[1]); } else { // {F87429BF-4583-4A67-BD6F-6CA8AA27702A} = {F87429BF-4583-4A67-BD6F-6CA8AA27702A} // i.e. both uuid are the dependency addDependency(uuid, keyvalue[1]); } } else if (slnConfSection) { // either "Debug = Debug" in V8 or "ConfigName.0 = Debug" in V7 // ignore every on the left of equal sign line = line.AfterLast('='); line.Trim(true); line.Trim(false); addWorkspaceConfiguration(line); } else if (projConfSection && line.StartsWith(_T("{"))) { // {X}.Debug TA.ActiveCfg = Debug TA|Win32 ---> match solution configuration to project configuration or just say what is the active config? // {X}.Debug TA.Build.0 = Debug TA|Win32 ---> we have to build (others are not build) keyvalue = GetArrayFromString(line, _T("=")); wxArrayString key = GetArrayFromString(keyvalue[0], _T(".")); wxArrayString value = GetArrayFromString(keyvalue[1], _T("|")); if (key[2] == _T("Build")) addConfigurationMatching(key[0], key[1], value[0]); } } Manager::Get()->GetProjectManager()->SetProject(firstproject); updateProjects(); ImportersGlobals::ResetDefaults(); Title = wxFileName(filename).GetName() + _(" workspace"); return count != 0; }
void SpellCheckerPlugin::OnCamelCase(cb_unused wxCommandEvent &event) { cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if (!ed || !m_pSpellChecker->IsInitialized()) return; cbStyledTextCtrl *stc = ed->GetControl(); if (!stc) return; // take only the first word from the selection int selstart = stc->GetSelectionStart(); while (selstart < stc->GetLength()) { if ( !m_pSpellHelper->IsWhiteSpace(stc->GetCharAt(selstart)) ) break; ++selstart; } // and scan back for the actual word start while (selstart > 0) { if ( m_pSpellHelper->IsWhiteSpace(stc->GetCharAt(selstart - 1)) ) break; --selstart; } if (selstart > stc->GetSelectionEnd()) return; int selend = selstart; while (selend < stc->GetLength()) { if ( m_pSpellHelper->IsWhiteSpace(stc->GetCharAt(++selend)) ) break; } if (selend - selstart < 4) // too small return; else if (selend - selstart > GetWordStartsLimit) // max limit (DoGetWordStarts() is recursive, so watch out) selend = selstart + GetWordStartsLimit; wxString text = stc->GetTextRange(selstart, selend); wxArrayString prefixes = GetArrayFromString(wxT("Get;Set;Do;On;Is;wx")); prefixes.Add(wxEmptyString); // check without prefix prefixes.Add(wxT("p")); // less common prefix, check last for (size_t i = 0; i < prefixes.GetCount(); ++i) { wxString word = text; if (!prefixes[i].IsEmpty()) // try with prefix { if (!text.Lower().StartsWith(prefixes[i].Lower(), &word)) continue; // no, try next prefix } wxString camelWord; for (size_t j = 0; j < word.Length() / 2; ++j) // 0 index number of words to break into { wxArrayInt wordStarts; if (DoGetWordStarts(word.Lower(), wordStarts, j)) { for (size_t k = 0; k < word.Length(); ++k) // make CamelCase { if (wordStarts.Index(k) == wxNOT_FOUND) camelWord << word.Lower()[k]; else camelWord << word.Upper()[k]; } break; } } if (!camelWord.IsEmpty()) { if (i != prefixes.GetCount()) camelWord.Prepend(prefixes[i]); if (text == camelWord) return; // already formed, so do nothing stc->BeginUndoAction(); stc->DeleteRange(selstart, text.Length()); stc->InsertText(selstart, camelWord); stc->SetSelectionStart(selstart); stc->SetSelectionEnd(selend); stc->EndUndoAction(); return; // exit } } }