bool CodeBlocksApp::InitXRCStuff() { if ( !Manager::LoadResource(_T("resources.zip")) ) { wxString msg; msg.Printf(_T("Cannot find resources...\n" "%s was configured to be installed in '%s'.\n" "Please use the command-line switch '--prefix' or " "set the CODEBLOCKS_DATA_DIR environment variable " "to point where %s is installed,\n" "or try re-installing the application..."), appglobals::AppName.wx_str(), ConfigManager::ReadDataPath().wx_str(), appglobals::AppName.wx_str()); cbMessageBox(msg); return false; } return true; }
//////////////////////////////////////////////////////////////////////////////// // callback for script plugins context menu entries //////////////////////////////////////////////////////////////////////////////// void OnScriptModuleMenu(int id) { ModuleMenuCallbacks::iterator it; it = s_MenuCallbacks.find(id); if (it != s_MenuCallbacks.end()) { MenuCallback& callback = it->second; SqPlus::SquirrelFunction<void> f(callback.object, "OnModuleMenuClicked"); if (!f.func.IsNull()) { try { f(callback.menuIndex); } catch (SquirrelError e) { cbMessageBox(cbC2U(e.desc), _("Script error"), wxICON_ERROR); } } } }
void cbWorkspace::Load() { wxString fname = m_Filename.GetFullPath(); #if wxCHECK_VERSION(2, 9, 0) Manager::Get()->GetLogManager()->DebugLog(F(_T("Loading workspace \"%s\""), fname.wx_str())); #else Manager::Get()->GetLogManager()->DebugLog(F(_T("Loading workspace \"%s\""), fname.c_str())); #endif if (!m_Filename.FileExists()) { Manager::Get()->GetLogManager()->DebugLog(_T("File does not exist.")); if (!m_IsDefault) { wxString msg; msg.Printf(_("Workspace '%s' does not exist..."), fname.c_str()); cbMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); // workspace wasn't loaded succesfully m_IsOK = false; return; } } if (FileTypeOf(fname) == ftCodeBlocksWorkspace) { IBaseWorkspaceLoader* pWsp = new WorkspaceLoader; wxString Title; m_IsOK = pWsp && (pWsp->Open(fname, Title) || m_IsDefault); if(!Title.IsEmpty()) { m_Title = Title; } delete pWsp; } m_Filename.SetExt(FileFilters::WORKSPACE_EXT); SetModified(false); }
void wxsToolBarEditor::OnDelClick(wxCommandEvent& event) { int Selection = m_Content->GetSelection(); if ( Selection == wxNOT_FOUND ) return; if ( cbMessageBox(_("Are you sure to delete this item?"), _("Deleting wxToolBar item"), wxYES_NO) == wxID_YES ) { m_Content->Delete(Selection); if ( (int)m_Content->GetCount() == Selection ) Selection--; if ( Selection > 0 ) { m_Content->SetSelection(Selection); SelectItem((ToolBarItem*)m_Content->GetClientObject(Selection)); } else { m_Content->SetSelection(wxNOT_FOUND); SelectItem(0); } } }
bool EditorBase::QueryClose() { if ( GetModified() ) { wxString msg; msg.Printf(_("File %s is modified...\nDo you want to save the changes?"), GetFilename().c_str()); switch (cbMessageBox(msg, _("Save file"), wxICON_QUESTION | wxYES_NO | wxCANCEL)) { case wxID_YES: if (!Save()) return false; break; case wxID_NO: break; case wxID_CANCEL: default: return false; } SetModified(false); } return true; }
void BacktraceDlg::OnSwitchFrame(cb_unused wxCommandEvent& event) { if (!IsSwitchFrameEnabled()) return; if (m_list->GetSelectedItemCount() == 0) return; // find selected item index int index = m_list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); // read the frame number from the first column long realFrameNr; if (m_list->GetItemText(index).ToLong(&realFrameNr)) { // switch to this frame cbDebuggerPlugin *plugin = Manager::Get()->GetDebuggerManager()->GetActiveDebugger(); if (plugin) plugin->SwitchToFrame(realFrameNr); } else cbMessageBox(_("Couldn't find out the frame number!"), _("Error"), wxICON_ERROR); }
void WorkspaceBrowserF::JumpToToken(TokenF* pToken) { if (pToken) { LineAddress jumpStart; LineAddress jumpFinish; if(cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor()) { cbStyledTextCtrl* control = ed->GetControl(); int curLine = control->LineFromPosition(control->GetCurrentPos()); jumpStart.Init(ed->GetFilename(), curLine, false); } EditorManager* edMan = Manager::Get()->GetEditorManager(); if (cbEditor* ed = edMan->Open(pToken->m_Filename)) { ed->GotoLine(pToken->m_LineStart - 1); wxFocusEvent ev(wxEVT_SET_FOCUS); ev.SetWindow(this); #if wxCHECK_VERSION(2, 9, 0) ed->GetControl()->GetEventHandler()->AddPendingEvent(ev); #else ed->GetControl()->AddPendingEvent(ev); #endif // Track jump history cbStyledTextCtrl* control = ed->GetControl(); int curLine = control->LineFromPosition(control->GetCurrentPos()); jumpFinish.Init(ed->GetFilename(), curLine, true); m_NativeParser->GetJumpTracker()->TakeJump(jumpStart, jumpFinish); m_NativeParser->GetFortranProject()->CheckEnableToolbar(); } else { cbMessageBox(wxString::Format(_("Declaration not found: %s"), pToken->m_DisplayName.c_str()), _("Warning"), wxICON_WARNING); } } }
//////////////////////////////////////////////////////////////////////////////// // execute a script plugin (script-bound function) //////////////////////////////////////////////////////////////////////////////// int ExecutePlugin(const wxString& name) { // look for script plugin ScriptPlugins::iterator it = s_ScriptPlugins.find(name); if (it != s_ScriptPlugins.end()) { // found; execute it SquirrelObject& o = it->second; SqPlus::SquirrelFunction<int> f(o, "Execute"); if (!f.func.IsNull()) { try { f(); } catch (SquirrelError e) { cbMessageBox(cbC2U(e.desc), _("Script error"), wxICON_ERROR); } } } return -1; }
void SaveCCDebugInfo(const wxString& fileDesc, const wxString& content) { wxString fname; wxFileDialog dlg (Manager::Get()->GetAppWindow(), fileDesc, _T(""), _T(""), _T("Text files (*.txt)|*.txt|Any file (*)|*"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); PlaceWindow(&dlg); if (dlg.ShowModal() != wxID_OK) return; // Opening the file migth have failed, verify: wxFile f(dlg.GetPath(), wxFile::write); if (f.IsOpened()) { f.Write(content); // write buffer to file f.Close(); // release file handle } else cbMessageBox(_("Cannot create file ") + fname, _("CC Debug Info")); }
/*! \brief Process the output from OpenOCD. This is a virtual function and can be overidden by a plugin, so each plugin can have it's own output processing. \param output wxString containing output data from stdout and stderr streams. */ void OpenOCDDriver::ParseOutput(const wxString& output) { // Display first dialog box error wxString trimLeft; trimLeft = output.Left(6); wxString err(_T("Error:")); if (trimLeft == err) { if (m_FirstErr == false) { // Only dialog box first error because they may be more than 1 m_FirstErr = true; cbMessageBox(output, _("OpenOCD Error"), wxICON_STOP); } } if (m_rs == Programming) { trimLeft = output.Left(5); if (trimLeft == _T("wrote")) { Stop(); } } }
void NewFromTemplateDlg::OnDiscardScript(cb_unused wxCommandEvent& event) { wxListCtrl* list = GetVisibleListCtrl(); if (!list) return; long index = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (index == -1) return; ListItemData* data = (ListItemData*)list->GetItemData(index); if (!data) return; wxString script = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + data->plugin->GetScriptFilename(data->wizPluginIndex); if (wxFileExists(script)) { if (cbMessageBox(_("Are you sure you want to discard all local modifications to this script?"), _("Confirmation"), wxICON_QUESTION | wxYES_NO, this) == wxID_YES) { if (wxRemoveFile(script)) list->SetItemTextColour(index, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } } }
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); } } }
void CodeBlocksApp::OnBatchBuildDone(CodeBlocksEvent& event) { event.Skip(); // the event comes more than once. deal with it... static bool one_time_only = false; if (!m_Batch || one_time_only) return; one_time_only = true; cbCompilerPlugin* compiler = static_cast<cbCompilerPlugin*>(event.GetPlugin()); m_BatchExitCode = compiler->GetExitCode(); if (m_BatchNotify) { wxString msg; if (m_BatchExitCode == 0) msg << _("Batch build ended.\n"); else msg << _("Batch build stopped with errors.\n"); msg << wxString::Format(_("Process exited with status code %d."), m_BatchExitCode); cbMessageBox(msg, appglobals::AppName, m_BatchExitCode == 0 ? wxICON_INFORMATION : wxICON_WARNING, m_pBatchBuildDialog); } else wxBell(); if (m_pBatchBuildDialog && m_BatchWindowAutoClose) { if (m_pBatchBuildDialog->IsModal()) m_pBatchBuildDialog->EndModal(wxID_OK); else { m_pBatchBuildDialog->Destroy(); m_pBatchBuildDialog = nullptr; } } }
void ToolsPlus::OnSettings(wxCommandEvent& event) { cbMessageBox(_("Settings...")); }
void EditPathDlg::OnBrowse(wxCommandEvent& /*event*/) { wxFileName path; wxArrayString multi; wxString val = XRCCTRL(*this, "txtPath", wxTextCtrl)->GetValue(); int idx = val.Find(DEFAULT_ARRAY_SEP); if (idx != -1) val.Remove(idx); wxFileName fname(val); if (m_WantDir) { // try to "decode" custom var wxString bkp = val; Manager::Get()->GetMacrosManager()->ReplaceEnvVars(val); fname = val; fname.MakeAbsolute(m_Basepath); m_Path = fname.GetFullPath(); path = ChooseDirectory(this, m_Message, (m_Path.IsEmpty() ? s_LastPath : m_Path), m_Basepath, false, m_ShowCreateDirButton); if (path.GetFullPath().IsEmpty()) return; // if it was a custom var, see if we can re-insert it if (bkp != val) { wxString tmp = path.GetFullPath(); if (tmp.Replace(val, bkp) != 0) { // done here XRCCTRL(*this, "txtPath", wxTextCtrl)->SetValue(tmp); return; } } } else { wxFileDialog dlg(this, m_Message, (fname.GetPath().IsEmpty() ? s_LastPath : fname.GetPath()), fname.GetFullName(), m_Filter, wxFD_CHANGE_DIR | (m_AllowMultiSel ? wxFD_MULTIPLE : 0) ); PlaceWindow(&dlg); if (dlg.ShowModal() == wxID_OK) { if (m_AllowMultiSel) dlg.GetPaths(multi); else path = dlg.GetPath(); } else return; } if (m_AllowMultiSel && multi.GetCount() != 0 && !multi[0].IsEmpty()) s_LastPath = multi[0]; else if (!path.GetFullPath().IsEmpty()) s_LastPath = path.GetFullPath(); wxString result; if (m_AskMakeRelative && !m_Basepath.IsEmpty()) { // ask the user if he wants it to be kept as relative if (cbMessageBox(_("Keep this as a relative path?"), _("Question"), wxICON_QUESTION | wxYES_NO, this) == wxID_YES) { if (m_AllowMultiSel) { for (unsigned int i = 0; i < multi.GetCount(); ++i) { path = multi[i]; path.MakeRelativeTo(m_Basepath); multi[i] = path.GetFullPath(); } result = GetStringFromArray(multi); } else { path.MakeRelativeTo(m_Basepath); result = path.GetFullPath(); } } else { if (m_AllowMultiSel) result = GetStringFromArray(multi); else result = path.GetFullPath(); } } else // always absolute path { if (m_AllowMultiSel) result = GetStringFromArray(multi); else result = path.GetFullPath(); } // finally set the path XRCCTRL(*this, "txtPath", wxTextCtrl)->SetValue(result); }
bool FileManager::WriteWxStringToFile(wxFile& f, const wxString& data, wxFontEncoding encoding, bool bom) { const char* mark = 0; size_t mark_length = 0; if (bom) { switch (encoding) { case wxFONTENCODING_UTF8: mark = "\xEF\xBB\xBF"; mark_length = 3; break; case wxFONTENCODING_UTF16BE: mark = "\xFE\xFF"; mark_length = 2; break; case wxFONTENCODING_UTF16LE: mark = "\xFF\xFE"; mark_length = 2; break; case wxFONTENCODING_UTF32BE: mark = "\x00\x00\xFE\xFF"; mark_length = 4; break; case wxFONTENCODING_UTF32LE: mark = "\xFF\xFE\x00\x00"; mark_length = 4; break; case wxFONTENCODING_SYSTEM: default: break; } if(f.Write(mark, mark_length) != mark_length) return false; } if (data.length() == 0) return true; #if defined(UNICODE) || defined(_UNICODE) size_t inlen = data.Len(), outlen = 0; wxCharBuffer mbBuff; if ( encoding == wxFONTENCODING_UTF7 ) { wxMBConvUTF7 conv; mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } else if ( encoding == wxFONTENCODING_UTF8 ) { wxMBConvUTF8 conv; mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } else if ( encoding == wxFONTENCODING_UTF16BE ) { wxMBConvUTF16BE conv; mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } else if ( encoding == wxFONTENCODING_UTF16LE ) { wxMBConvUTF16LE conv; mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } else if ( encoding == wxFONTENCODING_UTF32BE ) { wxMBConvUTF32BE conv; mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } else if ( encoding == wxFONTENCODING_UTF32LE ) { wxMBConvUTF32LE conv; mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } else { // try wxEncodingConverter first, even it it only works for // wxFONTENCODING_ISO8859_1..15, wxFONTENCODING_CP1250..1257 and wxFONTENCODING_KOI8 // but it's much, much faster than wxCSConv (at least on linux) wxEncodingConverter conv; // should be long enough char* tmp = new char[2*inlen]; #if wxCHECK_VERSION(2, 9, 0) if(conv.Init(wxFONTENCODING_UNICODE, encoding) && conv.Convert(data.wx_str(), tmp)) #else if(conv.Init(wxFONTENCODING_UNICODE, encoding) && conv.Convert(data.c_str(), tmp)) #endif { mbBuff = tmp; outlen = strlen(mbBuff); // should be correct, because Convert has returned true } else { // try wxCSConv, if nothing else works wxCSConv conv(encoding); mbBuff = conv.cWC2MB(data.c_str(), inlen, &outlen); } delete[] tmp; } // if conversion to chosen encoding succeeded, we write the file to disk if(outlen > 0) { return f.Write(mbBuff, outlen) == outlen; } // if conversion to chosen encoding does not succeed, we try UTF-8 instead size_t size = 0; wxCSConv conv(encoding); wxCharBuffer buf = data.mb_str(conv); if(!buf || !(size = strlen(buf))) { buf = data.mb_str(wxConvUTF8); if(!buf || !(size = strlen(buf))) { cbMessageBox(_T( "The file could not be saved because it contains characters " "that can neither be represented in your current code page, " "nor be converted to UTF-8.\n" "The latter should actually not be possible.\n\n" "Please check your language/encoding settings and try saving again." ), _("Failure"), wxICON_WARNING | wxOK ); return false; } else { InfoWindow::Display(_("Encoding Changed"), _("The saved document contained characters\n" "which were illegal in the selected encoding.\n\n" "The file's encoding has been changed to UTF-8\n" "to prevent you from losing data."), 8000); } } return f.Write(buf, size); #else // For ANSI builds, dump the char* to file. return f.Write(data.c_str(), data.Length()) == data.Length(); #endif }
void ProjectManager::EndLoadingWorkspace() { if (!m_IsLoadingWorkspace) return; m_IsLoadingWorkspace = false; if (!m_pWorkspace) return; if (m_pWorkspace->IsOK()) { if (m_pProjectToActivate) { SetProject(m_pProjectToActivate, true); m_pProjectToActivate = nullptr; } m_ui->FinishLoadingWorkspace(m_pActiveProject, m_pWorkspace->GetTitle()); // sort out any global user vars that need to be defined now (in a batch) :) Manager::Get()->GetUserVariableManager()->Arrogate(); int numNotes = 0; // and now send the project loaded events // since we were loading a workspace, these events were not sent before for (size_t i = 0; i < m_pProjects->GetCount(); ++i) { cbProject* project = m_pProjects->Item(i); // notify plugins that the project is loaded // moved here from cbProject::Open() because code-completion // kicks in too early and the perceived loading time is long... CodeBlocksEvent event(cbEVT_PROJECT_OPEN); event.SetProject(project); Manager::Get()->GetPluginManager()->NotifyPlugins(event); // since we 're iterating anyway, let's count the project notes that should be displayed if (project->GetShowNotesOnLoad() && !project->GetNotes().IsEmpty()) ++numNotes; } // finally, display projects notes (if appropriate) if (numNotes) { if (numNotes == 1 || // if only one project has notes, don't bother asking cbMessageBox(wxString::Format(_("%d projects contain notes that should be displayed on-load.\n" "Do you want to display them now, one after the other?"), numNotes), _("Display project notes?"), wxICON_QUESTION | wxYES_NO) == wxID_YES) { for (size_t i = 0; i < m_pProjects->GetCount(); ++i) { cbProject* project = m_pProjects->Item(i); if (project->GetShowNotesOnLoad()) project->ShowNotes(true); } } } WorkspaceChanged(); } else CloseWorkspace(); }
void HelpPlugin::LaunchHelp(const wxString &c_helpfile, bool isExecutable, bool openEmbeddedViewer, HelpCommon::StringCase keyCase, const wxString &defkeyword, const wxString &c_keyword) { const static wxString http_prefix(_T("http://")); const static wxString man_prefix(_T("man:")); wxString helpfile(c_helpfile); // Patch by Yorgos Pagles: Use the new attributes to calculate the keyword wxString keyword = c_keyword.IsEmpty() ? defkeyword : c_keyword; if(keyCase == HelpCommon::UpperCase) { keyword.MakeUpper(); } else if (keyCase == HelpCommon::LowerCase) { keyword.MakeLower(); } helpfile.Replace(_T("$(keyword)"), keyword); Manager::Get()->GetMacrosManager()->ReplaceMacros(helpfile); if (isExecutable) { Manager::Get()->GetLogManager()->DebugLog(_T("Executing ") + helpfile); wxExecute(helpfile); return; } // Support C::B scripts if (wxFileName(helpfile).GetExt() == _T("script")) { if (Manager::Get()->GetScriptingManager()->LoadScript(helpfile)) { // help scripts must contain a function with the following signature: // function SearchHelp(keyword) try { SqPlus::SquirrelFunction<void> f("SearchHelp"); f(keyword); } catch (SquirrelError& e) { Manager::Get()->GetScriptingManager()->DisplayErrors(&e); } } else { Manager::Get()->GetLogManager()->DebugLog(_T("Couldn't run script")); } return; } // Operate on help html file links inside embedded viewer if (openEmbeddedViewer && wxFileName(helpfile).GetExt().Mid(0, 3).CmpNoCase(_T("htm")) == 0) { Manager::Get()->GetLogManager()->DebugLog(_T("Launching ") + helpfile); cbMimePlugin* p = Manager::Get()->GetPluginManager()->GetMIMEHandlerForFile(helpfile); if (p) { p->OpenFile(helpfile); } else { reinterpret_cast<MANFrame *>(m_manFrame)->LoadPage(helpfile); ShowMANViewer(); } return; } // Operate on help http (web) links if (helpfile.Mid(0, http_prefix.size()).CmpNoCase(http_prefix) == 0) { Manager::Get()->GetLogManager()->DebugLog(_T("Launching ") + helpfile); wxLaunchDefaultBrowser(helpfile); return; } // Operate on man pages if (helpfile.Mid(0, man_prefix.size()).CmpNoCase(man_prefix) == 0) { if (reinterpret_cast<MANFrame *>(m_manFrame)->SearchManPage(c_helpfile, keyword)) { Manager::Get()->GetLogManager()->DebugLog(_T("Couldn't find man page")); } else { Manager::Get()->GetLogManager()->DebugLog(_T("Launching man page")); } ShowMANViewer(); return; } wxFileName the_helpfile = wxFileName(helpfile); Manager::Get()->GetLogManager()->DebugLog(_T("Help File is ") + helpfile); if (!(the_helpfile.FileExists())) { wxString msg; msg << _("Couldn't find the help file:\n") << the_helpfile.GetFullPath() << _("\n") << _("Do you want to run the associated program anyway?"); if (!(cbMessageBox(msg, _("Warning"), wxICON_WARNING | wxYES_NO | wxNO_DEFAULT) == wxID_YES)); return; } wxString ext = the_helpfile.GetExt(); #ifdef __WXMSW__ // Operate on help files with keyword search (windows only) if (!keyword.IsEmpty()) { if (ext.CmpNoCase(_T("hlp")) == 0) { wxWinHelpController HelpCtl; HelpCtl.Initialize(helpfile); HelpCtl.KeywordSearch(keyword); return; } if (ext.CmpNoCase(_T("chm")) == 0) { LaunchCHMThread *p_thread = new LaunchCHMThread(helpfile, keyword); p_thread->Create(); p_thread->Run(); return; } } #endif // Just call it with the associated program wxFileType *filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(ext); if (!filetype) { cbMessageBox(_("Couldn't find an associated program to open:\n") + the_helpfile.GetFullPath(), _("Warning"), wxOK | wxICON_EXCLAMATION); return; } wxExecute(filetype->GetOpenCommand(helpfile)); delete filetype; }
void CompilerSettingsDlg::EndModal(int retCode) { if (retCode == wxID_OK) { // tab "Batch builds" #ifdef __WXMSW__ /* TODO: remove preprocessor when Associations::SetXXX are supported on non-Windows platforms */ ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app")); wxString bbargs = XRCCTRL(*this, "txtBatchBuildsCmdLine", wxTextCtrl)->GetValue(); if (bbargs != cfg->Read(_T("/batch_build_args"), appglobals::DefaultBatchBuildArgs)) { cfg->Write(_T("/batch_build_args"), bbargs); Associations::SetBatchBuildOnly(); } #endif //#ifdef __WXMSW__ // batch build plugins ConfigManager *bbcfg = Manager::Get()->GetConfigManager(_T("plugins")); wxArrayString bbplugins; wxCheckListBox* clb = XRCCTRL(*this, "chkBBPlugins", wxCheckListBox); for (size_t i = 0; i < clb->GetCount(); ++i) { if (clb->IsChecked(i)) { const PluginElementsArray& plugins = Manager::Get()->GetPluginManager()->GetPlugins(); for (size_t n = 0; n < plugins.GetCount(); ++n) { PluginElement* elem = plugins[n]; if (!elem) continue; if (elem->info.title == clb->GetString(i)) { bbplugins.Add(wxFileName(elem->fileName).GetFullName()); break; } } } } const wxString compiler(platform::windows ? _T("compiler.dll") : _T("libcompiler.so")); if (bbplugins.Index(compiler) == wxNOT_FOUND) { bbplugins.Add(compiler); cbMessageBox(_("The compiler plugin must always be loaded for batch builds!\n" "Automatically re-enabled."), _("Warning"), wxICON_WARNING, this); } bbcfg->Write(_T("/batch_build_plugins"), bbplugins); // finally, apply settings in all plugins' panels for (size_t i = 0; i < m_PluginPanels.GetCount(); ++i) { cbConfigurationPanel* panel = m_PluginPanels[i]; panel->OnApply(); } } else { // finally, cancel settings in all plugins' panels for (size_t i = 0; i < m_PluginPanels.GetCount(); ++i) { cbConfigurationPanel* panel = m_PluginPanels[i]; panel->OnCancel(); } } wxScrollingDialog::EndModal(retCode); }
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 CfgMgrBldr::SwitchTo(const wxString& fileName) { doc = new TiXmlDocument(); if (!TinyXML::LoadDocument(fileName, doc)) { doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes")); doc->InsertEndChild(TiXmlElement("CodeBlocksConfig")); doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version); } if (doc->ErrorId()) cbThrow(wxString::Format(_T("TinyXML error: %s\nIn file: %s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), fileName.c_str(), doc->ErrorRow(), doc->ErrorCol())); TiXmlElement* docroot = doc->FirstChildElement("CodeBlocksConfig"); if (doc->ErrorId()) cbThrow(wxString::Format(_T("TinyXML error: %s\nIn file: %s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), fileName.c_str(), doc->ErrorRow(), doc->ErrorCol())); const char *vers = docroot->Attribute("version"); if (!vers || atoi(vers) != 1) cbMessageBox(_("ConfigManager encountered an unknown config file version. Continuing happily."), _("Warning"), wxICON_WARNING); doc->ClearError(); wxString info; #ifndef __GNUC__ info.Printf(_T( " application info:\n" "\t svn_revision:\t%u\n" "\t build_date:\t%s, %s "), ConfigManager::GetRevisionNumber(), wxT(__DATE__), wxT(__TIME__)); #else info.Printf(_T( " application info:\n" "\t svn_revision:\t%u\n" "\t build_date:\t%s, %s\n" "\t gcc_version:\t%d.%d.%d "), ConfigManager::GetRevisionNumber(), wxT(__DATE__), wxT(__TIME__), __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); #endif if (platform::windows) info.append(_T("\n\t Windows ")); if (platform::linux) info.append(_T("\n\t Linux ")); if (platform::macosx) info.append(_T("\n\t Mac OS X ")); if (platform::unix) info.append(_T("\n\t Unix ")); info.append(platform::unicode ? _T("Unicode ") : _T("ANSI ")); TiXmlComment c; c.SetValue((const char*) info.mb_str()); TiXmlNode *firstchild = docroot->FirstChild(); if (firstchild && firstchild->ToComment()) { docroot->RemoveChild(firstchild); firstchild = docroot->FirstChild(); } if (firstchild) docroot->InsertBeforeChild(firstchild, c); else docroot->InsertEndChild(c); }
void ProcessingDlg::ApplyResults(bool addOnly) { ResultArray Results; m_FoundResults.GetAllResults(Results); if ( Results.Count() == 0 ) { cbMessageBox(_("Didn't found any library")); return; } wxArrayString Names; wxArrayInt Selected; wxString PreviousVar; for ( size_t i=0; i<Results.Count(); ++i ) { wxString& Name = Results[i]->Description.IsEmpty() ? Results[i]->LibraryName : Results[i]->Description; Names.Add( wxString::Format(_T("%s : %s"), Results[i]->ShortCode.c_str(), Name.c_str())); if ( PreviousVar != Results[i]->ShortCode ) { Selected.Add((int)i); PreviousVar = Results[i]->ShortCode; } } LibSelectDlg Dlg( this, Names, addOnly ); Dlg.SetSelections( Selected ); if ( Dlg.ShowModal() == wxID_OK ) { // Fetch selected libraries Selected = Dlg.GetSelections(); // Clear all results if requested if ( Dlg.GetClearAllPrevious() ) { m_KnownResults[rtDetected].Clear(); } // Here we will store names of libraries set-up so far // by checking entries we will be able to find out whether // we have to clear previous settings wxArrayString AddedLibraries; for ( size_t i = 0; i<Selected.Count(); i++ ) { wxString Library = Results[Selected[i]]->ShortCode; if ( true ) { // Here we set-up internal libraries configuration if ( Dlg.GetClearSelectedPrevious() ) { if ( AddedLibraries.Index(Library)==wxNOT_FOUND ) { // Ok, have to delete previosu results since this is the first // occurence of this library in new set ResultArray& Previous = m_KnownResults[rtDetected].GetShortCode(Library); for ( size_t j=0; j<Previous.Count(); j++ ) { delete Previous[j]; } Previous.Clear(); } AddedLibraries.Add(Library); } else if ( Dlg.GetDontClearPrevious() ) { // Find and remove duplicates ResultArray& Previous = m_KnownResults[rtDetected].GetShortCode(Library); for ( size_t j=0; j<Previous.Count(); j++ ) { if ( *Previous[j] == *Results[Selected[i]] ) { delete Previous[j]; Previous.RemoveAt(j--); } } } // Add the result m_KnownResults[rtDetected].GetShortCode(Library).Add(new LibraryResult(*Results[Selected[i]])); } if ( Dlg.GetSetupGlobalVars() ) { // Here we set-up global variables Results[Selected[i]]->SetGlobalVar(); } } } }
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(",")); } }
void ToolsPlus::OnRunTarget(wxCommandEvent& event) { int ID=event.GetId(); wxString commandstr; wxString consolename; wxString workingdir; bool windowed=false; bool console=false; if (ID>=ID_ContextMenu_0&&ID<=ID_ContextMenu_49) { m_interpnum=m_contextvec[ID-ID_ContextMenu_0]; commandstr=m_ic.interps[m_interpnum].command; consolename=m_ic.interps[m_interpnum].name; windowed=(m_ic.interps[m_interpnum].mode==_("W")); console=(m_ic.interps[m_interpnum].mode==_("C")); workingdir=m_ic.interps[m_interpnum].wdir; } else if (ID>=ID_SubMenu_0&&ID<=ID_SubMenu_49) { m_interpnum=ID-ID_SubMenu_0; commandstr=m_ic.interps[m_interpnum].command; consolename=m_ic.interps[m_interpnum].name; windowed=(m_ic.interps[m_interpnum].mode==_("W")); console=(m_ic.interps[m_interpnum].mode==_("C")); workingdir=m_ic.interps[m_interpnum].wdir; m_wildcard=m_ic.interps[m_interpnum].wildcards; if (m_ic.interps[m_interpnum].command.Find(_("$file"))>0 || m_ic.interps[m_interpnum].command.Find(_("$path"))>0) { m_RunTarget=wxEmptyString; EditorManager* edMan = Manager::Get()->GetEditorManager(); if (edMan && edMan->GetActiveEditor() && edMan->GetActiveEditor()->GetFilename()) { wxFileName activefile(edMan->GetActiveEditor()->GetFilename()); wxString filename=activefile.GetFullPath(); wxString name=activefile.GetFullName(); if (WildCardListMatch(m_ic.interps[m_interpnum].wildcards,name)) m_RunTarget=filename; } if (m_RunTarget==wxEmptyString) OnSetTarget(event); if (!wxFileName::FileExists(m_RunTarget)) { LogMessage(_("Tools Plus plugin: ")+m_RunTarget+_(" not found")); return; } } if (m_ic.interps[m_interpnum].command.Find(_("$dir"))>0) { OnSetDirTarget(event); if (!wxFileName::DirExists(m_RunTarget)) { LogMessage(_("Tools Plus plugin: ")+m_RunTarget+_(" not found")); return; } if (m_RunTarget==_T("")) return; } if (m_ic.interps[m_interpnum].command.Find(_("$mpaths"))>0) { OnSetMultiTarget(event); if (m_RunTarget==_T("")) return; } } else { LogMessage(wxString::Format(_("WARNING: Unprocessed Tools Plus Menu Message: ID %i, IDbase %i, IDend %i, num items on menu %i"),ID,ID_ContextMenu_0,ID_ContextMenu_49,(int)m_contextvec.size())); return; } m_RunTarget.Replace(_T("*"),_T(" ")); bool setdir=true; commandstr.Replace(_("$file"),wxFileName(m_RunTarget).GetShortPath()); commandstr.Replace(_("$relfile"),wxFileName(m_RunTarget).GetFullName()); commandstr.Replace(_("$fname"),wxFileName(m_RunTarget).GetName()); commandstr.Replace(_("$fext"),wxFileName(m_RunTarget).GetExt()); commandstr.Replace(_("$dir"),wxFileName(m_RunTarget).GetShortPath()); commandstr.Replace(_("$reldir"),wxFileName(m_RunTarget).GetFullName()); commandstr.Replace(_("$path"),wxFileName(m_RunTarget).GetShortPath()); commandstr.Replace(_("$relpath"),wxFileName(m_RunTarget).GetFullPath()); if (commandstr.Replace(_("$mpaths"),m_RunTarget)>0) setdir=false; // substitute user prompted values in the format: $inputstr{Enter your message} int promptind=commandstr.Find(_("$inputstr{")); wxString substitution; while (promptind>=0) { int promptend=commandstr.Mid(promptind+10).Find(_("}")); if (promptend<=0) { cbMessageBox(_("Malformed $inputstr in command line -- no closing '}' found: ")+commandstr); return; } else promptend++; wxTextEntryDialog ted(NULL,commandstr.Mid(promptind+10,promptend-1),consolename,_T(""),wxOK|wxCANCEL); if (ted.ShowModal()==wxID_OK) substitution=ted.GetValue(); else return; commandstr=commandstr.Left(promptind)+substitution+commandstr.Mid(promptind+10+promptend); int nextind=commandstr.Mid(promptind+substitution.Len()).Find(_("$inputstr")); if (nextind>=0) promptind+=nextind+substitution.Len(); else promptind=-1; } commandstr.Replace(_("$interpreter"),wxFileName(m_ic.interps[m_interpnum].command).GetShortPath()); workingdir.Replace(_("$parentdir"),wxFileName(m_RunTarget).GetPath()); if (wxFileName::DirExists(m_RunTarget)) workingdir.Replace(_("$dir"),wxFileName(m_RunTarget).GetFullPath()); if (Manager::Get()->GetMacrosManager()) { Manager::Get()->GetMacrosManager()->RecalcVars(0, 0, 0); // hack to force-update macros Manager::Get()->GetMacrosManager()->ReplaceMacros(commandstr); Manager::Get()->GetMacrosManager()->ReplaceMacros(workingdir); } wxString olddir=wxGetCwd(); if (setdir && workingdir!=_T("")) { if (!wxSetWorkingDirectory(workingdir)) { LogMessage(_("Tools Plus Plugin: Can't change to working directory to ")+workingdir); return; } } LogMessage(wxString::Format(_("Launching '%s': %s (in %s)"), consolename.c_str(), commandstr.c_str(), workingdir.c_str())); if (windowed) { wxArrayString astr; m_shellmgr->LaunchProcess(commandstr,consolename,_("Piped Process Control"),astr); ShowConsole(); } else if (console) { wxString cmdline; #ifndef __WXMSW__ // for non-win platforms, use m_ConsoleTerm to run the console app wxString term = Manager::Get()->GetConfigManager(_T("app"))->Read(_T("/console_terminal"), DEFAULT_CONSOLE_TERM); term.Replace(_T("$TITLE"), _T("'") + consolename + _T("'")); cmdline<< term << _T(" "); #define CONSOLE_RUNNER "cb_console_runner" #else #define CONSOLE_RUNNER "cb_console_runner.exe" #endif wxString baseDir = ConfigManager::GetExecutableFolder(); if (wxFileExists(baseDir + wxT("/" CONSOLE_RUNNER))) cmdline << baseDir << wxT("/" CONSOLE_RUNNER " "); cmdline<<commandstr; if (!wxExecute(cmdline)) cbMessageBox(_("Command Launch Failed: ")+commandstr); } else { if (!wxExecute(commandstr)) cbMessageBox(_("Command Launch Failed: ")+commandstr); } wxSetWorkingDirectory(olddir); }
void ExpressionTester::OnButton2Click(wxCommandEvent& /*event*/) { cbMessageBox( Expression::Parser::GetHelpString() ); }
void DebuggerTree::OnDeleteAllWatches(wxCommandEvent& event) { if (cbMessageBox(_("Are you sure you want to delete all watches?"), _("Question"), wxICON_QUESTION | wxYES_NO) == wxID_YES) DeleteAllWatches(); }
AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); if (platform::windows) { if ( wxDirExists(_T("C:\\Program Files\\Intel\\Compiler")) ) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); } } } int version = 0; while ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) ) { wxString iccEnvVar; if (version==0) { // Try default w/o version number iccEnvVar = _T("ICPP_COMPILER"); version = 8; } else if (version>15) break; // exit while-loop else { // Try ICPP_COMPILER80 ... ICPP_COMPILER12 iccEnvVar.Printf(wxT("ICPP_COMPILER%d0"), version); version++; } // Read the ICPP_COMPILER[XX] environment variable if ( !wxGetEnv(iccEnvVar, &m_MasterPath) ) m_MasterPath.Clear(); } // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (!vcComp) continue; // compiler not registered? try next one wxString vcMasterNoMacros = vcComp->GetMasterPath(); Manager::Get()->GetMacrosManager()->ReplaceMacros(vcMasterNoMacros); if ( !wxFileExists(vcMasterNoMacros + sep + wxT("bin") + sep + vcComp->GetPrograms().C) && !wxFileExists(vcMasterNoMacros + sep + vcComp->GetPrograms().C) ) continue; // this MSVC is not installed; try next one const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND) m_ExtraPaths.Add(vcMasterPath); if ( !vcMasterPath.EndsWith(wxT("bin")) && m_ExtraPaths.Index(vcMasterPath + sep + wxT("bin")) == wxNOT_FOUND ) { m_ExtraPaths.Add(vcMasterPath + sep + wxT("bin")); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if ( m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i]) ) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) AddIncludeDir(vcIncludeDirs[i]); if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) AddResourceIncludeDir(vcIncludeDirs[i]); } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if ( m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i]) ) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } if ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) ) { // Just a final guess for the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } else if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a MSVC compiler installed.\n\n" "The ICC compiler requires MSVC for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrGuessed) ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrGuessed) ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ) m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("ia32")); if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ) m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("intel64")); if ( wxDirExists(m_MasterPath + sep + _T("include")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("include")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("lib")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib"), 0); if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32"), 0); if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); if ( !path.IsEmpty() && wxDirExists(path) ) { int version = 9; while ( true ) { wxString idbPath = path + sep + _T("IDB") + sep + wxString::Format(_T("%d.0"), version) + sep + _T("IA32"); if ( wxDirExists(idbPath) ) { path = idbPath; // found break; // exit while-loop } else if (version>15) break; // exit while-loop else version++; } } } else { dbg = _T("idb"); path = _T("/opt/intel/idb/9.0"); if ( wxDirExists(_T("/opt/intel")) ) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if ( wxFileExists(path + sep + _T("bin") + sep + dbg) ) m_ExtraPaths.Add(path); return ret; }
void ConfigManager::DeleteSubPath(const wxString& thePath) { if (doc->ErrorId()) { cbMessageBox(wxString(_T("### TinyXML error:\n")) << cbC2U(doc->ErrorDesc())); doc->ClearError(); } wxString path(thePath); to_lower(path); Collapse(path); wxString illegal(_T(" :.,;!\"\'$%&()[]<>{}?*+-|#")); size_t i; while ((i = path.find_first_of(illegal)) != wxString::npos) path[i] = _T('_'); if (path.Last() == _T('/')) path.RemoveLast(); if (path.IsSameAs(_T("/"))) // this function will refuse to remove root! return; TiXmlElement* parent = pathNode ? pathNode : root; if (path.find(_T('/')) != wxString::npos) { wxString sub; do { sub = path.BeforeFirst(_T('/')); path = path.AfterFirst(_T('/')); if (sub.IsEmpty()) parent = root; else if (sub.IsSameAs(_T("."))) ; else if (parent != root && sub.IsSameAs(_T(".."))) parent = parent->Parent()->ToElement(); else { TiXmlElement* n = parent->FirstChildElement(cbU2C(sub)); if (n) parent = n; else return; } } while (path.find(_T('/')) != wxString::npos); } if (!path.IsEmpty()) { if (TiXmlNode *toRemove = parent->FirstChild(cbU2C(path))) { toRemove->Clear(); parent->RemoveChild(toRemove); } } }
AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); wxString extraDir = _T(""); if (platform::windows) { if (wxDirExists(_T("C:\\Program Files\\Intel\\Compiler"))) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (vcComp) { if (vcComp->AutoDetectInstallationDir() == adrDetected) { const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND && wxDirExists(vcMasterPath)) { m_ExtraPaths.Add(vcMasterPath); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if (m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i])) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddIncludeDir(vcIncludeDirs[i]); } if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddResourceIncludeDir(vcIncludeDirs[i]); } } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if (m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i])) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } } } if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a working MSVC compiler.\n\n" "This compiler requires MS compiler for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } } } // Read the ICPP_COMPILER90 environment variable wxGetEnv(_T("ICPP_COMPILER90"), &m_MasterPath); extraDir = sep + _T("IA32");// Intel also provides compiler for Itanium processors if (m_MasterPath.IsEmpty()) { // just a guess the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); m_LibDirs.Insert(m_MasterPath + sep + _T("Lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); path += _T("IDB\\9.0\\IA32"); } else { dbg = _T("idb"); path= _T("/opt/intel/idb/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if (wxFileExists(path + sep + _T("bin") + sep + dbg)) m_ExtraPaths.Add(path); return ret; }
void ConfigManager::MigrateFolders() { #ifdef __linux__ // if the old config-folder (~/.codeblocks) does not exist, we have nothing to do. if (!wxDirExists(wxStandardPaths::Get().GetUserDataDir())) return; // ConfigManager::config_folder might be the portable-path but we want to migrate the standard-conform folder, // but only if it not aöready exists wxString newConfigFolder = wxString::FromUTF8(g_build_filename (g_get_user_config_dir(), "codeblocks", NULL)); // if the new config folder already exist, we step out immediately if (wxDirExists(newConfigFolder)) return; wxString oldConfigFolder = wxStandardPaths::Get().GetUserDataDir(); wxString oldDataFolder = oldConfigFolder + wxFILE_SEP_PATH + _T("share") + wxFILE_SEP_PATH + _T("codeblocks"); wxString newDataFolder = wxString::FromUTF8(g_build_filename (g_get_user_data_dir(), NULL)) + wxFILE_SEP_PATH + _T("codeblocks"); wxString msg; msg = F(_("The places where the configuration files and user-data files are stored\n" "have been changed to be more standard-conform.\n" "\n" "Now moving \"%s\"\n" "to \"%s\"\n" "and \"%s\"\n" "to \"%s\".\n"), oldDataFolder.wx_str(), newDataFolder.wx_str(), oldConfigFolder.wx_str(), newConfigFolder.wx_str()); cbMessageBox(msg, _("Try to migrate config-folder ..."), wxICON_INFORMATION); bool success = true; if (wxDirExists(oldDataFolder)) { // make sure the target-folder exists CreateDirRecursively(newDataFolder); success = wxRenameFile(oldDataFolder, newDataFolder); wxRmdir(oldConfigFolder + wxFILE_SEP_PATH + _T("share")); } if (success) { // make sure the target-folder exists CreateDirRecursively(newConfigFolder); success = wxRenameFile(oldConfigFolder, newConfigFolder); } if (!success) { msg = F(_("Error moving \"%s\"\n" "to \"%s\"\n" "or \"%s\"\n" "to \"%s\".\n\n" "Please check the folders manually (access rights?) !\n" "A new configuration will be created from scratch!"), oldDataFolder.wx_str(), newDataFolder.wx_str(), oldConfigFolder.wx_str(), newConfigFolder.wx_str()); cbMessageBox(msg, _("Error migrating config-folder ..."), wxICON_ERROR); } #endif // __linux__ }