void EnvVarsTableDlg::OnButtonOk(wxCommandEvent& event) { EvnVarList vars; std::map<wxString, wxString> envSets; wxString content = m_textCtrlDefault->GetText(); wxString name = wxT("Default"); content.Trim().Trim(false); envSets[name] = content; for(size_t i = 1; i < m_notebook1->GetPageCount(); i++) { if(i == (size_t)m_notebook1->GetSelection()) { vars.SetActiveSet(m_notebook1->GetPageText(i)); } EnvVarSetPage* page = (EnvVarSetPage*)m_notebook1->GetPage(i); wxString content = page->m_textCtrl->GetText(); wxString name = m_notebook1->GetPageText(i); content.Trim().Trim(false); envSets[name] = content; } vars.SetEnvVarSets(envSets); EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars); // Notify that the environment variables were modified clCommandEvent eventSave(wxEVT_ENVIRONMENT_VARIABLES_MODIFIED); EventNotifier::Get()->AddPendingEvent(eventSave); event.Skip(); }
bool EnvironmentConfig::Load() { bool loaded = ConfigurationToolBase::Load( wxT("config/environment_variables.xml") ); if(loaded) { // make sure that we are using the new format wxXmlNode *node = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("ArchiveObject")); if(node) { node = XmlUtils::FindFirstByTagName(node, wxT("StringMap")); if(node) { // this is an old version, convert it to the new format EvnVarList vars; std::map<wxString, wxString> envSets; wxString content; wxXmlNode *child = node->GetChildren(); while(child) { if(child->GetName() == wxT("MapEntry")) { wxString key = child->GetPropVal(wxT("Key"), wxT("")); wxString val = child->GetPropVal(wxT("Value"), wxT("")); content << key << wxT("=") << val << wxT("\n"); } child = child->GetNext(); } envSets[wxT("Default")] = content.Trim().Trim(false); vars.SetEnvVarSets(envSets); SetSettings(vars); } } } return loaded; }
void EnvVarsTableDlg::OnButtonOk( wxCommandEvent& event ) { EvnVarList vars; std::map<wxString, wxString> envSets; wxString content = m_textCtrlDefault->GetText(); wxString name = wxT("Default"); content.Trim().Trim(false); envSets[name] = content; for (size_t i=1; i<m_notebook1->GetPageCount(); i++) { if (i == (size_t)m_notebook1->GetSelection()) { vars.SetActiveSet(m_notebook1->GetPageText(i)); } EnvVarSetPage *page = (EnvVarSetPage*) m_notebook1->GetPage(i); wxString content = page->m_textCtrl->GetText(); wxString name = m_notebook1->GetPageText(i); content.Trim().Trim(false); envSets[name] = content; } vars.SetEnvVarSets(envSets); EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars); event.Skip(); }
WorkspaceSettingsDlg::WorkspaceSettingsDlg(wxWindow* parent, LocalWorkspace* localWorkspace) : WorkspaceSettingsBase(parent) , m_localWorkspace(localWorkspace) { m_ccPage = new CodeCompletionPage(m_notebook1, CodeCompletionPage::TypeWorkspace); m_notebook1->AddPage(m_ccPage, wxT("Code Completion"), false); EvnVarList vars; EnvironmentConfig::Instance()->ReadObject(wxT("Variables"), &vars); std::map<wxString, wxString> envSets = vars.GetEnvVarSets(); wxString activePage = vars.GetActiveSet(); m_choiceEnvSets->Clear(); std::map<wxString, wxString>::iterator iter = envSets.begin(); int useActiveSetIndex = m_choiceEnvSets->Append(wxGetTranslation(USE_GLOBAL_SETTINGS)); for(; iter != envSets.end(); iter++) { m_choiceEnvSets->Append(iter->first); } // select the current workspace active set name wxString activeEnvSet; wxString tmpSet = localWorkspace->GetActiveEnvironmentSet(); if(tmpSet == _("<Use Active Set>")) { tmpSet = wxGetTranslation(USE_GLOBAL_SETTINGS); } int where = m_choiceEnvSets->FindString(tmpSet); if(where == wxNOT_FOUND) { activeEnvSet = activePage; m_choiceEnvSets->SetSelection(useActiveSetIndex); } else { activeEnvSet = tmpSet; m_choiceEnvSets->SetSelection(where); } if(activeEnvSet.IsEmpty() == false) { vars.SetActiveSet(activeEnvSet); EnvironmentConfig::Instance()->SetSettings(vars); } wxString envvars = WorkspaceST::Get()->GetEnvironmentVariabels(); envvars.Trim().Trim(false); m_textCtrlWspEnvVars->SetValue(envvars); SetName("WorkspaceSettingsDlg"); WindowAttrManager::Load(this); }
wxArrayString EnvironmentConfig::GetActiveSetEnvNames(bool includeWorkspace, const wxString& project) { //read the environments variables EvnVarList vars; ReadObject(wxT("Variables"), &vars); wxArrayString envnames; // get the active environment variables set EnvMap variables = vars.GetVariables(wxEmptyString, includeWorkspace, project, wxEmptyString); for(size_t i=0; i<variables.GetCount(); ++i) { wxString key, val; variables.Get(i, key, val); envnames.Add( key ); } return envnames; }
EnvVarsTableDlg::EnvVarsTableDlg( wxWindow* parent ) : EnvVarsTableDlgBase( parent ) { EvnVarList vars; EnvironmentConfig::Instance()->ReadObject(wxT("Variables"), &vars); std::map<wxString, wxString> envSets = vars.GetEnvVarSets(); wxString activePage = vars.GetActiveSet(); wxStyledTextCtrl *sci = m_textCtrlDefault; sci->StyleClearAll(); sci->SetLexer(wxSTC_LEX_NULL); wxFont defFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont font(defFont.GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); for (int i=0; i<=wxSTC_STYLE_DEFAULT; i++) { sci->StyleSetBackground(i, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); sci->StyleSetForeground(i, *wxBLACK); sci->StyleSetFont(i, font); sci->SetWrapMode(wxSTC_WRAP_WORD); } WindowAttrManager::Load(this, wxT("EnvVarsTableDlg"), NULL); std::map<wxString, wxString>::iterator iter = envSets.begin(); for (; iter != envSets.end(); iter++) { wxString name = iter->first; wxString content = iter->second; if (name == wxT("Default")) { m_textCtrlDefault->SetText(content); } else { DoAddPage(name, content, false); } } m_notebook1->SetSelection(0); for (size_t i=0; i<m_notebook1->GetPageCount(); i++) { if (m_notebook1->GetPageText(i) == activePage) { m_notebook1->GetPage(i)->SetFocus(); m_notebook1->SetSelection(i); break; } } }
EnvVarsTableDlg::EnvVarsTableDlg(wxWindow* parent) : EnvVarsTableDlgBase(parent) { EvnVarList vars; EnvironmentConfig::Instance()->ReadObject(wxT("Variables"), &vars); std::map<wxString, wxString> envSets = vars.GetEnvVarSets(); wxString activePage = vars.GetActiveSet(); wxStyledTextCtrl* sci = m_textCtrlDefault; LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("text"); if(lexer) { lexer->Apply(sci); } WindowAttrManager::Load(this, wxT("EnvVarsTableDlg"), NULL); std::map<wxString, wxString>::iterator iter = envSets.begin(); for(; iter != envSets.end(); iter++) { wxString name = iter->first; wxString content = iter->second; if(name == wxT("Default")) { m_textCtrlDefault->SetText(content); } else { DoAddPage(name, content, false); } } m_notebook1->SetSelection(0); for(size_t i = 0; i < m_notebook1->GetPageCount(); i++) { if(m_notebook1->GetPageText(i) == activePage) { m_notebook1->GetPage(i)->SetFocus(); m_notebook1->SetSelection(i); break; } } }
void CodeLiteApp::MSWReadRegistry() { #ifdef __WXMSW__ EvnVarList vars; EnvironmentConfig::Instance()->Load(); EnvironmentConfig::Instance()->ReadObject(wxT("Variables"), &vars); ///////////////////////////////////////////////////////////////// // New way of registry: // Read the registry INI file ///////////////////////////////////////////////////////////////// // Update PATH environment variable with the install directory and // MinGW default installation (if exists) wxString pathEnv; wxGetEnv(wxT("PATH"), &pathEnv); wxString codeliteInstallDir; codeliteInstallDir << ManagerST::Get()->GetInstallDir() << wxT(";"); pathEnv.Prepend(codeliteInstallDir); // Load the registry file wxString iniFile; iniFile << ManagerST::Get()->GetInstallDir() << wxFileName::GetPathSeparator() << wxT("registry.ini"); if(wxFileName::FileExists(iniFile)) { clRegistry::SetFilename(iniFile); clRegistry registry; m_parserPaths.Clear(); wxString strWx, strMingw, strUnitTestPP; // registry.Read(wxT("wx"), strWx); registry.Read(wxT("mingw"), strMingw); registry.Read(wxT("unittestpp"), strUnitTestPP); // Supprot for wxWidgets if(strWx.IsEmpty() == false) { // we have WX installed on this machine, set the path of WXWIN & WXCFG to point to it EnvMap envs = vars.GetVariables(wxT("Default"), false, wxT("")); if(!envs.Contains(wxT("WXWIN"))) { vars.AddVariable(wxT("Default"), wxT("WXWIN"), strWx); vars.AddVariable(wxT("Default"), wxT("PATH"), wxT("$(WXWIN)\\lib\\gcc_dll;$(PATH)")); } if(!envs.Contains(wxT("WXCFG"))) vars.AddVariable(wxT("Default"), wxT("WXCFG"), wxT("gcc_dll\\mswu")); EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars); wxSetEnv(wxT("WX_INCL_HOME"), strWx + wxT("\\include")); } // Support for UnitTest++ if(strUnitTestPP.IsEmpty() == false) { // we have UnitTest++ installed on this machine EnvMap envs = vars.GetVariables(wxT("Default"), false, wxT("")); if(!envs.Contains(wxT("UNIT_TEST_PP_SRC_DIR"))) { vars.AddVariable(wxT("Default"), wxT("UNIT_TEST_PP_SRC_DIR"), strUnitTestPP); } EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars); } // Support for MinGW if(strMingw.IsEmpty() == false) { // Make sure that codelite's MinGW comes first before any other // MinGW installation that might exist on the machine strMingw << wxFileName::GetPathSeparator() << wxT("bin;"); pathEnv.Prepend(strMingw); } wxSetEnv(wxT("PATH"), pathEnv); } #endif }
bool CodeLiteApp::OnInit() { // Set the log file verbosity FileLogger::OpenLog("codelite.log", clConfig::Get().Read("LogVerbosity", FileLogger::Error)); CL_DEBUG(wxT("Starting codelite...")); #if defined(__WXGTK__) || defined(__WXMAC__) // block signal pipe sigset_t mask_set; sigemptyset(&mask_set); sigaddset(&mask_set, SIGPIPE); sigprocmask(SIG_SETMASK, &mask_set, NULL); // Handle sigchld CodeLiteBlockSigChild(); #ifdef __WXGTK__ // Insall signal handlers signal(SIGSEGV, WaitForDebugger); signal(SIGABRT, WaitForDebugger); #endif #endif wxSocketBase::Initialize(); // #if wxUSE_ON_FATAL_EXCEPTION // //trun on fatal exceptions handler // wxHandleFatalExceptions(true); // #endif #ifdef __WXMSW__ // as described in http://jrfonseca.dyndns.org/projects/gnu-win32/software/drmingw/ // load the exception handler dll so we will get Dr MinGW at runtime m_handler = LoadLibrary(wxT("exchndl.dll")); // Enable this process debugging priviliges // EnableDebugPriv(); #endif #ifdef USE_POSIX_LAYOUT wxStandardPaths::Get().IgnoreAppSubDir("bin"); #endif // Init resources and add the PNG handler wxSystemOptions::SetOption(_T("msw.remap"), 0); wxSystemOptions::SetOption("msw.notebook.themed-background", 0); wxXmlResource::Get()->InitAllHandlers(); wxImage::AddHandler(new wxPNGHandler); wxImage::AddHandler(new wxCURHandler); wxImage::AddHandler(new wxICOHandler); wxImage::AddHandler(new wxXPMHandler); wxImage::AddHandler(new wxGIFHandler); InitXmlResource(); wxLog::EnableLogging(false); wxString homeDir(wxEmptyString); // parse command line wxCmdLineParser parser; parser.SetDesc(cmdLineDesc); parser.SetCmdLine(wxAppBase::argc, wxAppBase::argv); if(parser.Parse() != 0) { return false; } if(parser.Found(wxT("h"))) { // print usage parser.Usage(); return false; } if(parser.Found(wxT("v"))) { // print version #ifdef __WXMSW__ ::wxMessageBox(wxString() << "CodeLite IDE v" << clGitRevision, "CodeLite"); #else wxPrintf("CodeLite IDE v%s\n", clGitRevision); #endif return false; } if(parser.Found(wxT("n"))) { // Load codelite without plugins SetPluginLoadPolicy(PP_None); } wxString plugins; if(parser.Found(wxT("p"), &plugins)) { wxArrayString pluginsArr = ::wxStringTokenize(plugins, wxT(",")); // Trim and make lower case for(size_t i = 0; i < pluginsArr.GetCount(); i++) { pluginsArr.Item(i).Trim().Trim(false).MakeLower(); } // Load codelite without plugins SetAllowedPlugins(pluginsArr); SetPluginLoadPolicy(PP_FromList); } wxString newBaseDir(wxEmptyString); if(parser.Found(wxT("b"), &newBaseDir)) { #if defined(__WXMSW__) homeDir = newBaseDir; #else wxLogDebug("Ignoring the Windows-only --basedir option as not running Windows"); #endif } wxString newDataDir(wxEmptyString); if(parser.Found(wxT("d"), &newDataDir)) { clStandardPaths::Get().SetUserDataDir(newDataDir); } // Copy gdb pretty printers from the installation folder to a writeable location // this is needed because python complies the files and in most cases the user // running codelite has no write permissions to /usr/share/codelite/... DoCopyGdbPrinters(); // Since GCC 4.8.2 gcc has a default colored output // which breaks codelite output parsing // to disable this, we need to set GCC_COLORS to an empty // string. // https://sourceforge.net/p/codelite/bugs/946/ // http://gcc.gnu.org/onlinedocs/gcc/Language-Independent-Options.html ::wxSetEnv("GCC_COLORS", ""); #if defined(__WXGTK__) if(homeDir.IsEmpty()) { SetAppName(wxT("codelite")); homeDir = clStandardPaths::Get() .GetUserDataDir(); // By default, ~/Library/Application Support/codelite or ~/.codelite if(!wxFileName::Exists(homeDir)) { wxLogNull noLog; wxFileName::Mkdir(homeDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); wxCHECK_MSG(wxFileName::DirExists(homeDir), false, "Failed to create the requested data dir"); } // Create the directory structure wxLogNull noLog; wxMkdir(homeDir); wxMkdir(homeDir + wxT("/lexers/")); wxMkdir(homeDir + wxT("/rc/")); wxMkdir(homeDir + wxT("/images/")); wxMkdir(homeDir + wxT("/templates/")); wxMkdir(homeDir + wxT("/config/")); wxMkdir(homeDir + wxT("/tabgroups/")); // copy the settings from the global location if needed wxString installPath(INSTALL_DIR, wxConvUTF8); if(!CopySettings(homeDir, installPath)) return false; ManagerST::Get()->SetInstallDir(installPath); } else { wxFileName fn(homeDir); fn.MakeAbsolute(); ManagerST::Get()->SetInstallDir(fn.GetFullPath()); } #elif defined(__WXMAC__) SetAppName(wxT("codelite")); homeDir = clStandardPaths::Get().GetUserDataDir(); if(!wxFileName::Exists(homeDir)) { wxLogNull noLog; wxFileName::Mkdir(homeDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); wxCHECK_MSG(wxFileName::DirExists(homeDir), false, "Failed to create the requested data dir"); } { wxLogNull noLog; // Create the directory structure wxMkdir(homeDir); wxMkdir(homeDir + wxT("/lexers/")); wxMkdir(homeDir + wxT("/rc/")); wxMkdir(homeDir + wxT("/images/")); wxMkdir(homeDir + wxT("/templates/")); wxMkdir(homeDir + wxT("/config/")); wxMkdir(homeDir + wxT("/tabgroups/")); } wxString installPath(MacGetBasePath()); ManagerST::Get()->SetInstallDir(installPath); // copy the settings from the global location if needed CopySettings(homeDir, installPath); #else //__WXMSW__ if(homeDir.IsEmpty()) { // did we got a basedir from user? # ifdef USE_POSIX_LAYOUT homeDir = wxStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR); # else homeDir = ::wxGetCwd(); # endif } wxFileName fnHomdDir(homeDir + wxT("/")); // try to locate the menu/rc.xrc file wxFileName fn(homeDir + wxT("/rc"), wxT("menu.xrc")); if(!fn.FileExists()) { // we got wrong home directory wxFileName appFn(wxAppBase::argv[0]); homeDir = appFn.GetPath(); } if(fnHomdDir.IsRelative()) { fnHomdDir.MakeAbsolute(); homeDir = fnHomdDir.GetPath(); } ManagerST::Get()->SetInstallDir(homeDir); #endif // Update codelite revision and Version EditorConfigST::Get()->Init(clGitRevision, wxT("2.0.2")); // Make sure we have an instance if the keyboard manager allocated before we create the main frame class // (the keyboard manager needs to connect to the main frame events) clKeyboardManager::Get(); ManagerST::Get()->SetOriginalCwd(wxGetCwd()); ::wxSetWorkingDirectory(homeDir); // Load all of the XRC files that will be used. You can put everything // into one giant XRC file if you wanted, but then they become more // diffcult to manage, and harder to reuse in later projects. // The menubar if(!wxXmlResource::Get()->Load(DoFindMenuFile(ManagerST::Get()->GetInstallDir(), wxT("2.0")))) return false; // keep the startup directory ManagerST::Get()->SetStartupDirectory(::wxGetCwd()); // set the performance output file name PERF_OUTPUT(wxString::Format(wxT("%s/codelite.perf"), wxGetCwd().c_str()).mb_str(wxConvUTF8)); // Initialize the configuration file locater ConfFileLocator::Instance()->Initialize(ManagerST::Get()->GetInstallDir(), ManagerST::Get()->GetStartupDirectory()); Manager* mgr = ManagerST::Get(); // set the CTAGS_REPLACEMENT environment variable wxSetEnv(wxT("CTAGS_REPLACEMENTS"), ManagerST::Get()->GetStartupDirectory() + wxT("/ctags.replacements")); long style = wxSIMPLE_BORDER; #if defined(__WXMSW__) || defined(__WXGTK__) style |= wxFRAME_NO_TASKBAR; #else // Mac wxUnusedVar(style); #endif // read the last frame size from the configuration file // Initialise editor configuration files #ifdef __WXMSW__ { wxLogNull noLog; wxFileName::Mkdir(clStandardPaths::Get().GetUserDataDir(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); } #endif EditorConfigST::Get()->SetInstallDir(mgr->GetInstallDir()); EditorConfig* cfg = EditorConfigST::Get(); if(!cfg->Load()) { CL_ERROR(wxT("Failed to load configuration file: %s/config/codelite.xml"), wxGetCwd().c_str()); return false; } ColoursAndFontsManager::Get().Load(); #ifdef __WXGTK__ bool redirect = clConfig::Get().Read("RedirectLogOutput", true); if(redirect) { // Redirect stdout/error to a file wxFileName stdout_err(clStandardPaths::Get().GetUserDataDir(), "codelite-stdout-stderr.log"); FILE* new_stdout = ::freopen(stdout_err.GetFullPath().mb_str(wxConvISO8859_1).data(), "a+b", stdout); FILE* new_stderr = ::freopen(stdout_err.GetFullPath().mb_str(wxConvISO8859_1).data(), "a+b", stderr); wxUnusedVar(new_stderr); wxUnusedVar(new_stdout); } #endif // check for single instance if(!IsSingleInstance(parser, ManagerST::Get()->GetOriginalCwd())) { return false; } //--------------------------------------------------------- // Set environment variable for CodeLiteDir (make it first // on the list so it can be used by other variables) //--------------------------------------------------------- EvnVarList vars; EnvironmentConfig::Instance()->Load(); EnvironmentConfig::Instance()->ReadObject(wxT("Variables"), &vars); vars.InsertVariable(wxT("Default"), wxT("CodeLiteDir"), ManagerST::Get()->GetInstallDir()); EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars); //--------------------------------------------------------- #ifdef __WXMSW__ // Read registry values MSWReadRegistry(); #endif GeneralInfo inf; cfg->ReadObject(wxT("GeneralInfo"), &inf); // Set up the locale if appropriate if(EditorConfigST::Get()->GetOptions()->GetUseLocale()) { int preferredLocale = wxLANGUAGE_ENGLISH; // The locale had to be saved as the canonical locale name, as the wxLanguage enum wasn't consistent between wx // versions wxString preferredLocalename = EditorConfigST::Get()->GetOptions()->GetPreferredLocale(); if(!preferredLocalename.IsEmpty()) { const wxLanguageInfo* info = wxLocale::FindLanguageInfo(preferredLocalename); if(info) { preferredLocale = info->Language; if(preferredLocale == wxLANGUAGE_UNKNOWN) { preferredLocale = wxLANGUAGE_ENGLISH; } } } #if defined(__WXGTK__) // Cater for a --prefix= build. This gets added automatically to the search path for catalogues. // So hack in the standard ones too, otherwise wxstd.mo will be missed wxLocale::AddCatalogLookupPathPrefix(wxT("/usr/share/locale")); wxLocale::AddCatalogLookupPathPrefix(wxT("/usr/local/share/locale")); #elif defined(__WXMSW__) # ifdef USE_POSIX_LAYOUT wxLocale::AddCatalogLookupPathPrefix(wxStandardPaths::Get().GetDataDir() + wxT("/share/locale")); # else wxLocale::AddCatalogLookupPathPrefix(ManagerST::Get()->GetInstallDir() + wxT("\\locale")); # endif #endif // This has to be done before the catalogues are added, as otherwise the wrong one (or none) will be found m_locale.Init(preferredLocale); bool codelitemo_found = m_locale.AddCatalog(wxT("codelite")); if(!codelitemo_found) { m_locale.AddCatalog(wxT("CodeLite")); // Hedge bets re our spelling } if(!codelitemo_found) { // I wanted to 'un-init' the locale if no translations were found // as otherwise, in a RTL locale, menus, dialogs etc will be displayed RTL, in English... // However I couldn't find a way to do this } } // Append the binary's dir to $PATH. This makes codelite-cc available even for a --prefix= installation #if defined(__WXMSW__) wxChar pathsep(wxT(';')); #else wxChar pathsep(wxT(':')); #endif wxString oldpath; wxGetEnv(wxT("PATH"), &oldpath); wxFileName execfpath(wxStandardPaths::Get().GetExecutablePath()); wxSetEnv(wxT("PATH"), oldpath + pathsep + execfpath.GetPath()); wxString newpath; wxGetEnv(wxT("PATH"), &newpath); // If running under Cygwin terminal, adjust the environment variables AdjustPathForCygwinIfNeeded(); // If running under Cygwin terminal, adjust the environment variables AdjustPathForMSYSIfNeeded(); // Create the main application window clMainFrame::Initialize(parser.GetParamCount() == 0); m_pMainFrame = clMainFrame::Get(); m_pMainFrame->Show(TRUE); SetTopWindow(m_pMainFrame); long lineNumber(0); parser.Found(wxT("l"), &lineNumber); if(lineNumber > 0) { lineNumber--; } else { lineNumber = 0; } for(size_t i = 0; i < parser.GetParamCount(); i++) { wxString argument = parser.GetParam(i); // convert to full path and open it wxFileName fn(argument); fn.MakeAbsolute(ManagerST::Get()->GetOriginalCwd()); if(fn.GetExt() == wxT("workspace")) { ManagerST::Get()->OpenWorkspace(fn.GetFullPath()); } else { clMainFrame::Get()->GetMainBook()->OpenFile(fn.GetFullPath(), wxEmptyString, lineNumber); } } wxLogMessage(wxString::Format(wxT("Install path: %s"), ManagerST::Get()->GetInstallDir().c_str())); wxLogMessage(wxString::Format(wxT("Startup Path: %s"), ManagerST::Get()->GetStartupDirectory().c_str())); #ifdef __WXGTK__ // Needed on GTK if(clMainFrame::Get()->GetMainBook()->GetActiveEditor() == NULL) { clMainFrame::Get()->GetOutputPane()->GetBuildTab()->SetFocus(); } #endif // Especially with the OutputView open, CodeLite was consuming 50% of a cpu, mostly in updateui // The next line limits the frequency of UpdateUI events to every 100ms wxUpdateUIEvent::SetUpdateInterval(100); return TRUE; }
void EnvironmentConfig::ApplyEnv(wxStringMap_t *overrideMap, const wxString &project, const wxString &config) { // We lock the CS here and it will be released in UnApplyEnv // this is safe to call without Locker since the UnApplyEnv // will always be called after ApplyEnv (ApplyEnv and UnApplyEnv are // protected functions that can only be called from EnvSetter class // which always call UnApplyEnv in its destructor) m_cs.Enter(); ++m_envApplied; if ( m_envApplied > 1 ) { //CL_DEBUG("Thread-%d: Applying environment variables... (not needed)", (int)wxThread::GetCurrentId()); return; } //CL_DEBUG("Thread-%d: Applying environment variables...", (int)wxThread::GetCurrentId()); //read the environments variables EvnVarList vars; ReadObject(wxT("Variables"), &vars); // get the active environment variables set EnvMap variables = vars.GetVariables(wxEmptyString, true, project, config); // if we have an "override map" place all the entries from the override map // into the global map before applying the environment if(overrideMap) { wxStringMap_t::iterator it = overrideMap->begin(); for(; it != overrideMap->end(); it++) { variables.Put(it->first, it->second); } } m_envSnapshot.clear(); for (size_t i=0; i<variables.GetCount(); i++) { wxString key, val; variables.Get(i, key, val); //keep old value before changing it wxString oldVal(wxEmptyString); if( wxGetEnv(key, &oldVal) == false ) { oldVal = __NO_SUCH_ENV__; } // keep the old value, however, don't override it if it // already exists as it might cause the variable to grow in size... // Simple case: // PATH=$(PATH);\New\Path // PATH=$(PATH);\Another\New\Path // If we replace the value, PATH will contain the original PATH + \New\Path if ( m_envSnapshot.count( key ) == 0 ) { m_envSnapshot.insert( std::make_pair( key, oldVal ) ); } // Incase this line contains other environment variables, expand them before setting this environment variable wxString newVal = DoExpandVariables(val); //set the new value wxSetEnv(key, newVal); } }