void CBProfilerConfigDlg::LoadSettings()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cbprofiler"));

    // Values to be used many times along
    bool annSource = cfg->ReadBool(_T("/ann_source_chk"), false);
    bool minCount  = cfg->ReadBool(_T("/min_count_chk"),  false);

    // Output Options
    XRCCTRL(*this, "chkAnnSource",       wxCheckBox)->SetValue(annSource);
    XRCCTRL(*this, "txtAnnSource",       wxTextCtrl)->SetValue(cfg->Read(_T("/ann_source_txt"),        wxEmptyString));
    XRCCTRL(*this, "chkBrief",           wxCheckBox)->SetValue(cfg->ReadBool(_T("/brief"),             false));
    XRCCTRL(*this, "chkFileInfo",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/file_info"),         false));
    XRCCTRL(*this, "chkUnusedFunctions", wxCheckBox)->SetValue(cfg->ReadBool(_T("/unused_functions"),  false));
    XRCCTRL(*this, "chkStaticCallGraph", wxCheckBox)->SetValue(cfg->ReadBool(_T("/static_call_graph"), false));

    // Analysis Options
    XRCCTRL(*this, "chkNoStatic",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/no_static"),         false));
    XRCCTRL(*this, "chkMinCount",        wxCheckBox)->SetValue(minCount);
    XRCCTRL(*this, "spnMinCount",        wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/min_count_spn"),      0));

    // Miscellaneous Options
    XRCCTRL(*this, "chkSum",             wxCheckBox)->SetValue(cfg->ReadBool(_T("/sum"),               false));

    // Extra Options
    XRCCTRL(*this, "txtExtra",           wxTextCtrl)->SetValue(cfg->Read(_T("/extra_txt"),             wxEmptyString));

    // Enable/Disable the TextCtrl(s) as well as SpinCtrl(s)
    XRCCTRL(*this, "txtAnnSource",       wxTextCtrl)->Enable(annSource);
    XRCCTRL(*this, "spnMinCount",        wxSpinCtrl)->Enable(minCount);
}
/** Load the definition of the comments for each language.
 *  @param languages Array of languages.
 *  @see LanguageDef
 */
int LoadSettings(LanguageDef languages[NB_FILETYPES_MAX])
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("codestat"));
    int nb_languages = cfg->ReadInt(_T("/nb_languages"), 0);

    // If no comment styles exist, use and save default ones
    if (nb_languages == 0)
    {
       nb_languages = LoadDefaultSettings(languages);
    }
    // else, load the user settings
    else
    {
        if (nb_languages > NB_FILETYPES_MAX)
           nb_languages = NB_FILETYPES_MAX;
        for (int i=0; i<nb_languages; ++i)
        {
            wxString extensions;
            languages[i].name = cfg->Read(wxString::Format(_T("/l%d/name"),i), _T(""));
            extensions = cfg->Read(wxString::Format(_T("/l%d/ext"),i), _T(""));
            languages[i].ext.Clear();
            wxStringTokenizer tkz(extensions);
            while (tkz.HasMoreTokens())
               languages[i].ext.Add(tkz.GetNextToken());
            languages[i].single_line_comment = cfg->Read(wxString::Format(_T("/l%d/single_line_comment"),i), _T(""));
            languages[i].multiple_line_comment[0] = cfg->Read(wxString::Format(_T("/l%d/multiple_line_comment_begin"),i), _T(""));
            languages[i].multiple_line_comment[1] = cfg->Read(wxString::Format(_T("/l%d/multiple_line_comment_end"),i), _T(""));
        }
    }
    return nb_languages;
}
// ----------------------------------------------------------------------------
// DoOnFileOpen:
// in case we are opening a project (bProject == true) we do not want to interfere
// with 'last type of files' (probably the call was open (existing) project on the
// start here page --> so we know it's a project --> set the filter accordingly
// but as said don't force the 'last used type of files' to change, that should
// only change when an open file is carried out (so (source) file <---> project (file) )
// TODO : when regular file open and user manually sets filter to project files --> will change
//      the last type : is that expected behaviour ???
// ----------------------------------------------------------------------------
void ThreadSearchFrame::DoOnFileOpen(bool bProject)
// ----------------------------------------------------------------------------
{
    wxString Filters = FileFilters::GetFilterString();
    // the value returned by GetIndexForFilterAll() is updated by GetFilterString()
    int StoredIndex = FileFilters::GetIndexForFilterAll();
    wxString Path;
    ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("app"));
    if(mgr)
    {
        if(!bProject)
        {
            wxString Filter = mgr->Read(_T("/file_dialogs/file_new_open/filter"));
            if(!Filter.IsEmpty())
            {
                FileFilters::GetFilterIndexFromName(Filters, Filter, StoredIndex);
            }
            Path = mgr->Read(_T("/file_dialogs/file_new_open/directory"), Path);
        }
        else
        {
            FileFilters::GetFilterIndexFromName(Filters, _("Code::Blocks project files"), StoredIndex);
        }
    }
    wxFileDialog* dlg = new wxFileDialog(this,
                            _("Open file"),
                            Path,
                            wxEmptyString,
                            Filters,
                            wxFD_OPEN | wxFD_MULTIPLE | compatibility::wxHideReadonly);
    dlg->SetFilterIndex(StoredIndex);

    PlaceWindow(dlg);
    if (dlg->ShowModal() == wxID_OK)
    {
        // store the last used filter and directory
        // as said : don't do this in case of an 'open project'
        if(mgr && !bProject)
        {
            int Index = dlg->GetFilterIndex();
            wxString Filter;
            if(FileFilters::GetFilterNameFromIndex(Filters, Index, Filter))
            {
                mgr->Write(_T("/file_dialogs/file_new_open/filter"), Filter);
            }
            wxString Test = dlg->GetDirectory();
            mgr->Write(_T("/file_dialogs/file_new_open/directory"), dlg->GetDirectory());
        }
        wxArrayString files;
        dlg->GetPaths(files);
        OnDropFiles(0,0,files);
    }

    dlg->Destroy();
} // end of DoOnFileOpen
Exemple #4
0
    EFileType FileType(const wxString& filename, bool force_refresh)
    {
        static bool          cfg_read  = false;
        static bool          empty_ext = true;
        static wxArrayString header_ext;
        static wxArrayString source_ext;

        if (!cfg_read || force_refresh)
        {
            ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
            empty_ext               = cfg->ReadBool(_T("/empty_ext"), true);
            wxString header_ext_str = cfg->Read(_T("/header_ext"), _T("h,hpp,tcc,xpm"));
            wxString source_ext_str = cfg->Read(_T("/source_ext"), _T("c,cpp,cxx,cc,c++"));

            header_ext.Clear();
            wxStringTokenizer header_ext_tknzr(header_ext_str, _T(","));
            while (header_ext_tknzr.HasMoreTokens())
                header_ext.Add(header_ext_tknzr.GetNextToken().Trim(false).Trim(true).Lower());

            source_ext.Clear();
            wxStringTokenizer source_ext_tknzr(source_ext_str, _T(","));
            while (source_ext_tknzr.HasMoreTokens())
                source_ext.Add(source_ext_tknzr.GetNextToken().Trim(false).Trim(true).Lower());

            cfg_read = true; // caching done
        }

        if (filename.IsEmpty())
            return ParserCommon::ftOther;

        const wxString file = filename.AfterLast(wxFILE_SEP_PATH).Lower();
        const int      pos  = file.Find(_T('.'), true);
        wxString       ext;
        if (pos != wxNOT_FOUND)
            ext = file.SubString(pos + 1, file.Len());

        if (empty_ext && ext.IsEmpty())
            return ParserCommon::ftHeader;

        for (size_t i=0; i<header_ext.GetCount(); ++i)
        {
            if (ext==header_ext[i])
                return ParserCommon::ftHeader;
        }

        for (size_t i=0; i<source_ext.GetCount(); ++i)
        {
            if (ext==source_ext[i])
                return ParserCommon::ftSource;
        }

        return ParserCommon::ftOther;
    }
ConfigPanel::ConfigPanel(wxWindow* parent,wxWindowID id,const wxPoint& /*pos*/,const wxSize& /*size*/)
{
    //(*Initialize(ConfigPanel)
    wxFlexGridSizer* flsMain;
    wxStaticText* lblCppCheckArgs;
    wxButton* btnCppCheckApp;
    wxBoxSizer* bszMain;
    wxBoxSizer* bszCppCheckApp;
    wxStaticText* lblCppCheckArgsComment;
    wxStaticText* lblCppCheckApp;

    Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
    bszMain = new wxBoxSizer(wxHORIZONTAL);
    flsMain = new wxFlexGridSizer(0, 2, 0, 0);
    flsMain->AddGrowableCol(1);
    lblCppCheckApp = new wxStaticText(this, wxID_ANY, _("CppCheck application:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
    flsMain->Add(lblCppCheckApp, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
    bszCppCheckApp = new wxBoxSizer(wxHORIZONTAL);
    txtCppCheckApp = new wxTextCtrl(this, ID_TXT_CPP_CHECK_APP, _("cppcheck"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TXT_CPP_CHECK_APP"));
    bszCppCheckApp->Add(txtCppCheckApp, 1, wxLEFT|wxEXPAND, 5);
    btnCppCheckApp = new wxButton(this, ID_BTN_CPPCHECK_APP, _("..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BTN_CPPCHECK_APP"));
    btnCppCheckApp->SetMinSize(wxSize(30,-1));
    bszCppCheckApp->Add(btnCppCheckApp, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
    flsMain->Add(bszCppCheckApp, 1, wxEXPAND, 5);
    lblCppCheckArgs = new wxStaticText(this, wxID_ANY, _("CppCheck arguments:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
    flsMain->Add(lblCppCheckArgs, 0, wxTOP|wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
    txtCppCheckArgs = new wxTextCtrl(this, ID_TXT_CPP_CHECK_ARGS, _("--verbose --enable=all --enable=style --xml"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TXT_CPP_CHECK_ARGS"));
    flsMain->Add(txtCppCheckArgs, 1, wxTOP|wxLEFT|wxEXPAND, 5);
    lblCppCheckArgsComment = new wxStaticText(this, wxID_ANY, _("(before \"--file-list\")"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
    flsMain->Add(lblCppCheckArgsComment, 0, wxLEFT|wxALIGN_TOP, 5);
    flsMain->Add(-1,-1,1, wxEXPAND, 5);
    bszMain->Add(flsMain, 1, wxEXPAND, 5);
    SetSizer(bszMain);
    bszMain->Fit(this);
    bszMain->SetSizeHints(this);

    Connect(ID_BTN_CPPCHECK_APP,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ConfigPanel::OnCppCheckApp);
    //*)

    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck"));
    if (cfg)
    {
        txtCppCheckApp->SetValue( cfg->Read(_T("cppcheck_app"),
#ifdef __WXMSW__
                                  _T("cppcheck.exe")) );
#else
                                  _T("cppcheck")) );
#endif
        txtCppCheckArgs->SetValue( cfg->Read(_T("cppcheck_args"),
                                   _T("--verbose --enable=all --enable=style --xml")) );
    }
}
void FilesGroupsAndMasks::Load()
{
    Clear();
    ConfigManager* conf = Manager::Get()->GetConfigManager(_T("project_manager"));
    wxArrayString list = conf->EnumerateSubPaths(_T("/file_groups"));
    for (unsigned int i = 0; i < list.GetCount(); ++i)
    {
        // new way (reading groups)
        wxString key = _T("/file_groups/") + list[i];
        unsigned int group = AddGroup(conf->Read(key + _T("/name")));
        SetFileMasks(group, conf->Read(key + _T("/mask")));
    }
}
wxString Valgrind::BuildMemCheckCmd()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("valgrind"));

    wxString Cmd = GetValgrindExecutablePath();
    Cmd += wxT(" ") + cfg->Read(wxT("/memcheck_args"), wxEmptyString);
    if (cfg->ReadBool(wxT("/memcheck_full"), true))
    {
        Cmd += wxT(" --leak-check=full");
    }
    else
    {
        Cmd += wxT(" --leak-check=yes");
    }
    if (cfg->ReadBool(wxT("/memcheck_track_origins"), true))
    {
        Cmd += wxT(" --track-origins=yes");
    }
    if (cfg->ReadBool(wxT("/memcheck_reachable"), false))
    {
        Cmd += wxT(" --show-reachable=yes");
    }

    return Cmd;
}
wxString nsEnvVars::GetActiveSetName()
{
#if TRACE_ENVVARS
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetActiveSetName")));
#endif

  wxString active_set = nsEnvVars::EnvVarsDefault;

  // load and apply configuration (to application only)
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
  if (!cfg)
    return active_set;

  // try to get the envvar set name of the currently active global envvar set
  wxString active_set_cfg = cfg->Read(_T("/active_set"));
  if (!active_set_cfg.IsEmpty())
    active_set = active_set_cfg;

  #if wxCHECK_VERSION(2, 9, 0)
  EV_DBGLOG(_T("EnvVars: Obtained '%s' as active envvar set from config."), active_set.wx_str());
  #else
  EV_DBGLOG(_T("EnvVars: Obtained '%s' as active envvar set from config."), active_set.c_str());
  #endif
  return active_set;
}// GetActiveSetName
void DebuggerManager::ProcessSettings(RegisteredPlugins::iterator it)
{
    cbDebuggerPlugin *plugin = it->first;
    PluginData &data = it->second;
    ConfigManager *config = Manager::Get()->GetConfigManager(wxT("debugger_common"));
    wxString path = wxT("/sets/") + plugin->GetSettingsName();
    wxArrayString configs = config->EnumerateSubPaths(path);
    configs.Sort();

    if (configs.empty())
    {
        config->Write(path + wxT("/conf1/name"), wxString(wxT("Default")));
        configs = config->EnumerateSubPaths(path);
        configs.Sort();
    }

    data.ClearConfigurations();
    data.m_lastConfigID = -1;

    for (size_t jj = 0; jj < configs.Count(); ++jj)
    {
        wxString configPath = path + wxT("/") + configs[jj];
        wxString name = config->Read(configPath + wxT("/name"));

        cbDebuggerConfiguration *pluginConfig;
        pluginConfig = plugin->LoadConfig(ConfigManagerWrapper(wxT("debugger_common"), configPath + wxT("/values")));
        if (pluginConfig)
        {
            pluginConfig->SetName(name);
            data.GetConfigurations().push_back(pluginConfig);
        }
    }
}
bool cbEditorPanel::SaveAs()
{
    wxFileName fname;
    fname.Assign(GetFilename());
    ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("app"));

    wxString Path = fname.GetPath();
    wxString Extension = _T("nsd");

    if(mgr && Path.IsEmpty())
        Path = mgr->Read(_T("/file_dialogs/save_file_as/directory"), Path);

    wxFileDialog dlg(Manager::Get()->GetAppWindow(),
                      _("Save file"),
                      Path,
                      fname.GetFullName(),
                      m_filecontent->GetWildcard(),
                      wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

    if (dlg.ShowModal() != wxID_OK) // cancelled out
    {
        UpdateModified();
        return false;
    }

    SetFilename(dlg.GetPath());
    SetModified(true);
    m_IsOK = true;
    bool ret = m_filecontent->Save(GetFilename());
    UpdateModified();
    return ret;
}
Exemple #11
0
int CppCheck::DoCppCheckExecute(TCppCheckAttribs& CppCheckAttribs)
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck"));

    wxString CppExe  = GetAppExecutable(_T("cppcheck"), _T("cppcheck_app"));
    wxString CppArgs = cfg->Read(_T("cppcheck_args"), _T("--verbose --enable=all --enable=style --xml"));
    Manager::Get()->GetMacrosManager()->ReplaceMacros(CppArgs);
    wxString CommandLine = CppExe + _T(" ") + CppArgs
                         + _T(" --file-list=") + CppCheckAttribs.InputFileName;

    if ( !CppCheckAttribs.IncludeList.IsEmpty() )
    {
        CommandLine += _T(" ") + CppCheckAttribs.IncludeList.Trim() + _T(" ")
                     + CppCheckAttribs.DefineList.Trim();
    }

    wxArrayString Output, Errors;
    bool isOK = AppExecute(_T("cppcheck"), CommandLine, Output, Errors);
    ::wxRemoveFile(CppCheckAttribs.InputFileName);
    if (!isOK)
        return -1;

    wxString Xml;
    for (size_t idxCount = 0; idxCount < Errors.GetCount(); ++idxCount)
        Xml += Errors[idxCount];
    DoCppCheckAnalysis(Xml);

    return 0;
}
cbAuiNotebook::cbAuiNotebook(wxWindow* pParent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
        : wxAuiNotebook(pParent, id, pos, size, style),
#ifdef __WXMSW__
          m_LastSelected(wxNOT_FOUND),
          m_LastId(0),
#endif
#if !wxCHECK_VERSION(3, 0, 0)
          m_HasToolTip(false),
#endif
          m_SetZoomOnIdle(false),
          m_MinimizeFreeSpaceOnIdle(false),
          m_TabCtrlSize(wxDefaultSize)
{
    //ctor
#ifdef __WXGTK__
    m_mgr.SetFlags((m_mgr.GetFlags() | wxAUI_MGR_VENETIAN_BLINDS_HINT) & ~wxAUI_MGR_TRANSPARENT_HINT);
#endif  // #ifdef __WXGTK__
    ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app"));
#if defined __WXMSW__ && wxCHECK_VERSION(3, 0, 0)
    wxToolTip::SetMaxWidth(-1);
#endif
    s_AllowMousewheel = cfg->ReadBool(_T("/environment/tabs_use_mousewheel"),true);
    s_modKeys = cfg->Read(_T("/environment/tabs_mousewheel_modifier"),_T("Ctrl"));
    s_modToAdvance = cfg->ReadBool(_T("/environment/tabs_mousewheel_advance"),false);
    cbAuiNotebook::InvertAdvanceDirection(cfg->ReadBool(_T("/environment/tabs_invert_advance"),false));
    cbAuiNotebook::InvertMoveDirection(cfg->ReadBool(_T("/environment/tabs_invert_move"),false));

    if (s_cbAuiNotebookArray.Index(this) == wxNOT_FOUND)
        s_cbAuiNotebookArray.Add(this);
}
wxString ConfigManagerWrapper::Read(const wxString& key, const wxString& defaultVal)
{
    if (m_namespace.empty())
        return defaultVal;
    ConfigManager *c = Manager::Get()->GetConfigManager(m_namespace);
    return c->Read(m_basepath + key, defaultVal);
}
void AstyleConfigDlg::LoadSettings()
{
  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("astyle"));
  int style = cfg->ReadInt(_T("/style"), 0);

  XRCCTRL(*this, "spnIndentation",        wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/indentation"),           4));
  XRCCTRL(*this, "chkUseTab",             wxCheckBox)->SetValue(cfg->ReadBool(_T("/use_tabs"),             false));
  XRCCTRL(*this, "chkForceUseTabs",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/force_tabs"),           false));
  XRCCTRL(*this, "chkIndentClasses",      wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_classes"),       false));
  XRCCTRL(*this, "chkIndentSwitches",     wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_switches"),      false));
  XRCCTRL(*this, "chkIndentCase",         wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_case"),          false));
  XRCCTRL(*this, "chkIndentBrackets",     wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_brackets"),      false));
  XRCCTRL(*this, "chkIndentBlocks",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_blocks"),        false));
  XRCCTRL(*this, "chkIndentNamespaces",   wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_namespaces"),    false));
  XRCCTRL(*this, "chkIndentLabels",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_labels"),        false));
  XRCCTRL(*this, "chkIndentPreprocessor", wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_preprocessor"),  false));
  XRCCTRL(*this, "chkIndentCol1Comments", wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_col1_comments"), false));
  XRCCTRL(*this, "cmbPointerAlign",       wxComboBox)->SetValue(cfg->Read(_T("/pointer_align"),            _T("None")));
  XRCCTRL(*this, "chkBreakClosing",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/break_closing"),        false));
  XRCCTRL(*this, "chkBreakBlocks",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/break_blocks"),         false));
  XRCCTRL(*this, "chkBreakElseIfs",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/break_elseifs"),        false));
  XRCCTRL(*this, "chkPadOperators",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_operators"),        false));
  XRCCTRL(*this, "chkPadParensIn",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_parentheses_in"),   false));
  XRCCTRL(*this, "chkPadParensOut",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_parentheses_out"),  false));
  XRCCTRL(*this, "chkPadHeader",          wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_header"),           false));
  XRCCTRL(*this, "chkUnpadParens",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/unpad_parentheses"),    false));
  XRCCTRL(*this, "chkDelEmptyLine",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/delete_empty_lines"),   false));
  XRCCTRL(*this, "chkKeepComplex",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/keep_complex"),         false));
  XRCCTRL(*this, "chkKeepBlocks",         wxCheckBox)->SetValue(cfg->ReadBool(_T("/keep_blocks"),          false));
  XRCCTRL(*this, "chkConvertTabs",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/convert_tabs"),         false));
  XRCCTRL(*this, "chkFillEmptyLines",     wxCheckBox)->SetValue(cfg->ReadBool(_T("/fill_empty_lines"),     false));
  XRCCTRL(*this, "chkAddBrackets",        wxCheckBox)->SetValue(cfg->ReadBool(_T("/add_brackets"),         false));

  SetStyle((AStylePredefinedStyle)style);
}
bool ConfigManagerWrapper::Read(const wxString& key, wxString* str)
{
    if (m_namespace.empty())
        return false;
    ConfigManager *c = Manager::Get()->GetConfigManager(m_namespace);
    return c->Read(key, str);
}
void ScriptingSettingsDlg::FillScripts()
{
    wxListCtrl* list = XRCCTRL(*this, "chkStartupScripts", wxListCtrl);
    list->DeleteAllItems();

    ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("scripting"));
    wxArrayString keys = mgr->EnumerateKeys(_T("/startup_scripts"));

    for (size_t i = 0; i < keys.GetCount(); ++i)
    {
        ScriptEntry se;
        wxString ser;
        if (mgr->Read(_T("/startup_scripts/") + keys[i], &ser))
        {
            se.SerializeIn(ser);
            m_ScriptsVector.push_back(se);

            long item = list->InsertItem(list->GetItemCount(), se.script);
            list->SetItem(item, 1, se.enabled ? _("Yes") : _("No"));
            list->SetItem(item, 2, se.registered && !se.menu.IsEmpty() ? se.menu : wxString(wxEmptyString));
        }
    }

    UpdateState();
}
bool ConfigManagerWrapper::Read(const wxString& name, double* value)
{
    if (m_namespace.empty())
        return false;
    ConfigManager *c = Manager::Get()->GetConfigManager(m_namespace);
    return c->Read(m_basepath + name, value);
}
wxArrayString nsEnvVars::GetEnvvarsBySetPath(const wxString& set_path)
{
#if defined(TRACE_ENVVARS)
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetEnvvarsBySetPath")));
#endif

  wxArrayString envvars;
  EV_DBGLOG(_T("EnvVars: Searching for envvars in path '%s'."), set_path.wx_str());

  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
  if (!cfg || set_path.IsEmpty())
    return envvars;

  wxArrayString envvars_keys = cfg->EnumerateKeys(set_path);
  unsigned int  num_envvars  = envvars_keys.GetCount();
  for (unsigned int i=0; i<num_envvars; ++i)
  {
    wxString envvar = cfg->Read(set_path+_T("/")+envvars_keys[i]);
    if (!envvar.IsEmpty())
      envvars.Add(envvar);
    else
      EV_DBGLOG(_T("EnvVars: Warning: empty envvar detected and skipped."));
  }
  EV_DBGLOG(_T("EnvVars: Read %lu/%u envvars in path '%s'."),
    static_cast<unsigned long>(envvars.GetCount()), num_envvars, set_path.wx_str());

  return envvars;
}// GetEnvvarsBySetPath
Exemple #19
0
void CompilerFactory::RegisterUserCompilers()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("compiler"));
    wxArrayString paths = cfg->EnumerateSubPaths(_T("/user_sets"));
    for (unsigned int i = 0; i < paths.GetCount(); ++i)
    {
        wxString base = _T("/user_sets/") + paths[i];
        wxString parent = cfg->Read(base + _T("/parent"), wxEmptyString);
        if (!parent.IsEmpty())
        {
            Compiler* compiler = GetCompiler(parent);
            wxString name = cfg->Read(base + _T("/name"), wxEmptyString);
            CreateCompilerCopy(compiler, name);
        }
    }
}
Exemple #20
0
bool cbDiffEditor::SaveAsUnifiedDiff()
{
    ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("app"));
    wxString Path = wxGetCwd();
    wxString Filter;
    if(mgr && Path.IsEmpty())
        Path = mgr->Read(_T("/file_dialogs/save_file_as/directory"), Path);

    wxFileDialog dlg(Manager::Get()->GetAppWindow(), _("Save file"), Path, wxEmptyString, _("Diff files (*.diff)|*.diff"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
    PlaceWindow(&dlg);
    if (dlg.ShowModal() != wxID_OK)  // cancelled out
        return false;

    wxString Filename = dlg.GetPath();

    // store the last used directory
    if(mgr)
    {
        wxString Test = dlg.GetDirectory();
        mgr->Write(_T("/file_dialogs/save_file_as/directory"), dlg.GetDirectory());
    }

    if(!cbSaveToFile(Filename, diff_))
    {
        wxString msg;
        msg.Printf(_("File %s could not be saved..."), GetFilename().c_str());
        cbMessageBox(msg, _("Error saving file"), wxICON_ERROR);
        return false;
    }
    return true;
}
Exemple #21
0
void CodeBlocksApp::CheckVersion()
{
    // This is a remnant from early 2006 (Windows only), but keep the revision tag for possible future use
    ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app"));

    if (cfg->Read(_T("version")) != appglobals::AppActualVersion)
        cfg->Write(_T("version"), appglobals::AppActualVersion);
}
Exemple #22
0
wxString CppCheck::GetAppExecutable(const wxString& app, const wxString& app_cfg)
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck"));
    wxString Executable = ConfigPanel::GetDefaultCppCheckExecutableName();
    if (cfg)
        Executable = cfg->Read(app_cfg, Executable);
    Manager::Get()->GetMacrosManager()->ReplaceMacros(Executable);

    AppendToLog(wxString::Format(_("Executable ") + app + _T(": '%s'."),
                                 Executable.wx_str()));

    // Make sure file is accessible, otherwise add path to cppcheck to PATH envvar
    wxFileName fn(Executable);
    if (fn.IsOk() && fn.FileExists())
    {
        wxString AppPath = fn.GetPath();
        AppendToLog(wxString::Format(_("Path to ") + app + _T(": '%s'."),
                                     AppPath.wx_str()));

        if ( AppPath.Trim().IsEmpty() )
            return Executable; // Nothing to do, lets hope it works and cppcheck is in the PATH

        bool PrependPath = true;
        wxString NewPathEnvVar = wxEmptyString;

        wxPathList PathList;
        PathList.AddEnvList(wxT("PATH"));
        for (size_t i=0; i<PathList.GetCount(); ++i)
        {
            wxString PathItem = PathList.Item(i);
            if ( PathItem.IsSameAs(AppPath, (platform::windows ? false : true)) )
            {
                AppendToLog(_("Executable of cppcheck is in the path."));
                PrependPath = false;
                break; // Exit for-loop
            }

            if ( !NewPathEnvVar.IsEmpty() )
                NewPathEnvVar << wxPATH_SEP;
            NewPathEnvVar << PathItem;
        }

        if (m_PATH.IsEmpty())
            m_PATH = NewPathEnvVar;


        if (PrependPath)
        {
            NewPathEnvVar = NewPathEnvVar.Prepend(wxPATH_SEP);
            NewPathEnvVar = NewPathEnvVar.Prepend(AppPath);
            wxSetEnv(wxT("PATH"), NewPathEnvVar); // Don't care about return value
            AppendToLog(wxString::Format(_("Updated PATH environment to include path to ") + app + _T(": '%s' ('%s')."),
                                         AppPath.wx_str(), NewPathEnvVar.wx_str()));
        }
    }

    return Executable;
}
wxString Valgrind::BuildCacheGrindCmd()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("valgrind"));

    wxString Cmd = GetValgrindExecutablePath();
    Cmd += wxT(" ") + cfg->Read(wxT("/cachegrind_args"), wxEmptyString);
    Cmd += wxT(" --tool=cachegrind");
    return Cmd;
}
void EditorTweaks::OnAttach()
{
    // do whatever initialization you need for your plugin
    // NOTE: after this function, the inherited member variable
    // m_IsAttached will be TRUE...
    // You should check for it in other functions, because if it
    // is FALSE, it means that the application did *not* "load"
    // (see: does not need) this plugin...

    Manager* pm = Manager::Get();
    pm->RegisterEventSink(cbEVT_EDITOR_OPEN, new cbEventFunctor<EditorTweaks, CodeBlocksEvent>(this, &EditorTweaks::OnEditorOpen));

    m_tweakmenu=NULL;

    EditorManager* em = Manager::Get()->GetEditorManager();
    for (int i=0;i<em->GetEditorsCount();i++)
    {
        cbEditor* ed=em->GetBuiltinEditor(i);
        if (ed && ed->GetControl())
        {
            ed->GetControl()->SetOvertype(false);
            ed->GetControl()->Connect(wxEVT_KEY_DOWN,(wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction)&EditorTweaks::OnKeyPress,NULL,this);
            ed->GetControl()->Connect(wxEVT_CHAR,(wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction)&EditorTweaks::OnChar,NULL,this);
        }
    }


    AlignerMenuEntry e;

    ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("EditorTweaks"));

    for (int i = 0 ; i < cfg->ReadInt(_T("/aligner/saved_entries"),defaultStoredAlignerEntries) ; ++i)
    {
        e.MenuName = cfg->Read(wxString::Format(_T("/aligner/first_name_%d"),i),defaultNames[i]);
        e.ArgumentString = cfg->Read(wxString::Format(_T("/aligner/first_argument_string_%d"),i) ,defaultStrings[i]);
        e.UsageCount = 0;
        e.id = wxNewId();
        AlignerMenuEntries.push_back(e);
        Connect(e.id, wxEVT_COMMAND_MENU_SELECTED,  wxCommandEventHandler(EditorTweaks::OnAlign) );
    }
    m_suppress_insert = cfg->ReadBool(wxT("/suppress_insert_key"), false);
    m_laptop_friendly = cfg->ReadBool(wxT("/laptop_friendly"),     false);
    m_convert_braces  = cfg->ReadBool(wxT("/convert_braces"),      false);
}
Exemple #25
0
void ResultMap::ReadDetectedResults()
{
    Clear();

    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("lib_finder"));
    if ( !cfg ) return;

    wxArrayString Results = cfg->EnumerateSubPaths(_T("/stored_results"));
    for ( size_t i=0; i<Results.Count(); i++ )
    {
        wxString Path = _T("/stored_results/") + Results[i] + _T("/");
        LibraryResult* Result = new LibraryResult();

        Result->Type         = rtDetected;

        Result->LibraryName  = cfg->Read(Path+_T("name"),wxEmptyString);
        Result->ShortCode    = cfg->Read(Path+_T("short_code"),wxEmptyString);
        Result->BasePath     = cfg->Read(Path+_T("base_path"),wxEmptyString);
        Result->Description  = cfg->Read(Path+_T("description"),wxEmptyString);
        Result->PkgConfigVar = cfg->Read(Path+_T("pkg_config_var"),wxEmptyString);

        Result->Categories   = cfg->ReadArrayString(Path+_T("categories"));
        Result->IncludePath  = cfg->ReadArrayString(Path+_T("include_paths"));
        Result->LibPath      = cfg->ReadArrayString(Path+_T("lib_paths"));
        Result->ObjPath      = cfg->ReadArrayString(Path+_T("obj_paths"));
        Result->Libs         = cfg->ReadArrayString(Path+_T("libs"));
        Result->Defines      = cfg->ReadArrayString(Path+_T("defines"));
        Result->CFlags       = cfg->ReadArrayString(Path+_T("cflags"));
        Result->LFlags       = cfg->ReadArrayString(Path+_T("lflags"));
        Result->Compilers    = cfg->ReadArrayString(Path+_T("compilers"));
        Result->Headers      = cfg->ReadArrayString(Path+_T("headers"));
        Result->Require      = cfg->ReadArrayString(Path+_T("require"));

        if ( Result->ShortCode.IsEmpty() )
        {
            delete Result;
            continue;
        }

        GetShortCode(Result->ShortCode).Add(Result);
    }
}
wxString cbDebuggerCommonConfig::GetValueTooltipFont()
{
    wxFont system = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    system.SetPointSize(std::max(system.GetPointSize() - 3, 7));
    wxString defaultFont = system.GetNativeFontInfo()->ToString();

    ConfigManager *c = Manager::Get()->GetConfigManager(wxT("debugger_common"));
    wxString configFont = c->Read(wxT("/common/tooltip_font"));

    return configFont.empty() ? defaultFont : configFont;
}
void ToolsManager::LoadTools()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("tools"));
    wxArrayString list = cfg->EnumerateSubPaths(_("/"));
    for (unsigned int i = 0; i < list.GetCount(); ++i)
    {
        cbTool tool;
        tool.SetName( cfg->Read(_T("/") + list[i] + _T("/name")));
        if (tool.GetName().IsEmpty())
            continue;
        tool.SetCommand(cfg->Read(_T("/") + list[i] + _T("/command")));
        if (tool.GetCommand().IsEmpty())
            continue;
        tool.SetParams(cfg->Read(_T("/") + list[i] + _T("/params")));
        tool.SetWorkingDir(cfg->Read(_T("/") + list[i] + _T("/workingDir")));
        tool.SetLaunchOption(static_cast<cbTool::eLaunchOption>(cfg->ReadInt(_T("/") + list[i] + _T("/launchOption"))));

        AddTool(&tool, false);
    }
    Manager::Get()->GetLogManager()->Log(F(_("Configured %d tools"), m_Tools.GetCount()));
}
bool CommandCollection::ImportLegacyConfig()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("InterpretedLangs"));
    int len=0;
    if(!cfg->Read(_T("InterpProps/numinterps"), &len))
    {
        return false;
    }
    for(int i=0;i<len;i++)
    {
        wxString istr=istr0(i);
        wxString name,exec,extensions;
        cfg->Read(_T("InterpProps/I")+istr+_T("/name"), &name);
        cfg->Read(_T("InterpProps/I")+istr+_T("/exec"), &exec);
        cfg->Read(_T("InterpProps/I")+istr+_T("/ext"), &extensions);
        int lenact=0;
        cfg->Read(_T("InterpProps/I")+istr+_T("/numactions"), &lenact);
        for(int j=0;j<lenact;j++)
        {
            ShellCommand interp;
            wxString jstr=istr0(j);
            wxString aname,command,mode,wdir,envvarset;
            cfg->Read(_T("InterpProps/I")+istr+_T("/actions/A")+jstr+_T("/name"), &aname);
            cfg->Read(_T("InterpProps/I")+istr+_T("/actions/A")+jstr+_T("/command"), &command);
            cfg->Read(_T("InterpProps/I")+istr+_T("/actions/A")+jstr+_T("/mode"), &mode);
            cfg->Read(_T("InterpProps/I")+istr+_T("/actions/A")+jstr+_T("/workingdir"), &wdir);
            cfg->Read(_T("InterpProps/I")+istr+_T("/actions/A")+jstr+_T("/envvarset"), &envvarset);
            interp.name=name+_T(" ")+aname;
            interp.wildcards=extensions;
            interp.command=command;
            interp.command.Replace(_T("$interpreter"),exec);
            interp.wdir=wdir;
            interp.menu=name+_T("/")+aname;
            interp.cmenu=name+_T("/")+aname;
            interp.cmenupriority=0;
            interp.menupriority=0;
            interp.envvarset=envvarset;
            interp.mode=mode;
            interps.Add(interp);
        }
    }
    cfg->Clear();
    WriteConfig();
    return true;
}
void FortranFileExt::RereadFileExtensions()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("fortran_project"));
    if (!cfg)
        return;

    m_FortranExtFixed.clear();
    wxString extl = cfg->Read(_T("/extension_fixed"), _T("for, f77, f, fpp"));
    wxStringTokenizer tkz(extl, _T(" ;,*.\t\r\n"), wxTOKEN_STRTOK);
    while ( tkz.HasMoreTokens() )
    {
        wxString token = tkz.GetNextToken();
        m_FortranExtFixed.insert(token.Lower());
    }

    m_FortranExtFree.clear();
    extl = cfg->Read(_T("/extension_free"), _T("f90, f95, f03, f2k"));
    tkz.SetString(extl, _T(" ;,*.\t\r\n"), wxTOKEN_STRTOK);
    while ( tkz.HasMoreTokens() )
    {
        wxString token = tkz.GetNextToken();
        m_FortranExtFree.insert(token.Lower());
    }
}
Exemple #30
0
void CFortranIndentConfigDlg::LoadSettings()
{
	ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("fortran_indent"));

	CMyFortranIndentConfig myFortranIndentConfig;

	if( cfg->Read( _T("is_SameAsEditor"), & myFortranIndentConfig.isSameAsEditor ) )
	{
		cfg->Read( _T("is_UseTab"), & myFortranIndentConfig.isUseTab );
		cfg->Read( _T("i_TabWidth"), & myFortranIndentConfig.iTabWidth );
		cfg->Read( _T("is_KeepBlankLineOnly"), & myFortranIndentConfig.isKeepBlankLineOnly );
		cfg->Read( _T("is_TrimLineFromRight"), & myFortranIndentConfig.isTrimLineFromRight );
		cfg->Read( _T("i_PreprocessorType"), & myFortranIndentConfig.iPreprocessorType );
	}

    XRCCTRL(*this, "cb_SameAsEditor", wxCheckBox)->SetValue( myFortranIndentConfig.isSameAsEditor );
    XRCCTRL(*this, "cb_UseTab", wxCheckBox)->SetValue( myFortranIndentConfig.isUseTab );
	XRCCTRL(*this, "cb_UseTab", wxCheckBox)->Enable( ! myFortranIndentConfig.isSameAsEditor );
    XRCCTRL(*this, "sp_TabWidth", wxSpinCtrl)->SetValue( myFortranIndentConfig.iTabWidth );
	XRCCTRL(*this, "sp_TabWidth", wxCheckBox)->Enable( ! ( myFortranIndentConfig.isSameAsEditor || myFortranIndentConfig.isUseTab ) );
    XRCCTRL(*this, "cb_KeepBlankLineOnly", wxCheckBox)->SetValue( myFortranIndentConfig.isKeepBlankLineOnly );
    XRCCTRL(*this, "cb_TrimLineFromRight", wxCheckBox)->SetValue( myFortranIndentConfig.isTrimLineFromRight );
    XRCCTRL(*this, "rb_PreprocessorType", wxRadioBox)->SetSelection( myFortranIndentConfig.iPreprocessorType );
}