This patch should fix (almost) all custom color scheme loading problems. It also adds evaluation of back-ticked expressions during define collection, and enables preprocessor interpretation by default (it is fine if this last part is left out, however, having tested it on both Windows and Linux now, I think most users would likely prefer it on).
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp (revision 8236)
+++ src/sdk/cbeditor.cpp (working copy)
@@ -1576,7 +1576,7 @@
ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
// Interpret #if/#else/#endif to grey out code that is not active
- control->SetProperty(_T("lexer.cpp.track.preprocessor"), mgr->ReadBool(_T("/track_preprocessor"), false) ? _T("1") : _T("0"));
+ control->SetProperty(_T("lexer.cpp.track.preprocessor"), mgr->ReadBool(_T("/track_preprocessor"), true) ? _T("1") : _T("0"));
// code folding
if (mgr->ReadBool(_T("/folding/show_folds"), true))
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp (revision 8236)
+++ src/sdk/editormanager.cpp (working copy)
@@ -3045,8 +3045,8 @@
{
cbProject* prj = Manager::Get()->GetProjectManager()->GetActiveProject();
if ( !prj
- || !Manager::Get()->GetConfigManager(wxT("editor"))->ReadBool(wxT("/track_preprocessor"), false)
- || !Manager::Get()->GetConfigManager(wxT("editor"))->ReadBool(wxT("/collect_prj_defines"), false) )
+ || !Manager::Get()->GetConfigManager(wxT("editor"))->ReadBool(wxT("/track_preprocessor"), true)
+ || !Manager::Get()->GetConfigManager(wxT("editor"))->ReadBool(wxT("/collect_prj_defines"), true) )
{
event.Skip();
return;
@@ -3067,13 +3067,39 @@
lst = &prj->GetFilesList();
id = prj->GetCompilerID();
}
+ Compiler* comp = CompilerFactory::GetCompiler(id); // get global flags
+ if (comp)
+ AppendArray(comp->GetCompilerOptions(), compilerFlags);
wxArrayString defines;
for (size_t i = 0; i < compilerFlags.Count(); ++i)
{
- if ( (compilerFlags[i].Left(2) == wxT("-D"))
- || (compilerFlags[i].Left(2) == wxT("/D")) )
+ if ( compilerFlags[i].StartsWith(wxT("-D"))
+ || compilerFlags[i].StartsWith(wxT("/D")) )
+ {
defines.Add(compilerFlags[i].Mid(2));
+ }
+ else if ( compilerFlags[i].StartsWith(wxT("`"))
+ && compilerFlags[i].EndsWith(wxT("`")) )
+ {
+ wxArrayString out;
+ long ret = 0;
+ {
+ wxLogNull logNo; // no need to warn if execution fails
+ ret = wxExecute(compilerFlags[i].Mid(1, compilerFlags[i].Length() - 2), out);
+ }
+ if (ret == 0)
+ {
+ out = GetArrayFromString(out[0], wxT(" ")); // pkg-config gives only single line output
+ AppendArray(out, compilerFlags); // append for processing
+ }
+ }
+ else if ( compilerFlags[i] == wxT("-ansi")
+ || compilerFlags[i] == wxT("-std=c90")
+ || compilerFlags[i] == wxT("-std=c++98"))
+ {
+ defines.Add(wxT("__STRICT_ANSI__"));
+ }
}
defines.Add(wxT("__cplusplus"));
Index: src/sdk/editorcolourset.cpp
===================================================================
--- src/sdk/editorcolourset.cpp (revision 8236)
+++ src/sdk/editorcolourset.cpp (working copy)
@@ -658,7 +658,22 @@
tmpKey << key << _T("/style") << wxString::Format(_T("%d"), i);
if (cfg->Exists(tmpKey + _T("/name")))
- opt->name = cfg->Read(tmpKey + _T("/name"));
+ {
+ wxString name = cfg->Read(tmpKey + _T("/name"));
+ for (size_t j = 0; opt->name != name && i + j < it->second.m_Colours.GetCount(); ++j) // search forwards first
+ {
+ opt = it->second.m_Colours.Item(i + j);
+ }
+ for (int j = -1; opt->name != name && i + j >= 0; --j) // then search backwards if it was not found
+ {
+ opt = it->second.m_Colours.Item(i + j);
+ }
+ if (opt->name != name)
+ {
+ cfg->DeleteSubPath(tmpKey); // unknown key, clear it out
+ continue;
+ }
+ }
else
{
// make sure we didn't create it accidentally
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp (revision 8236)
+++ src/sdk/editorconfigurationdlg.cpp (working copy)
@@ -140,8 +140,8 @@
XRCCTRL(*this, "cmbViewWS", wxComboBox)->SetSelection(cfg->ReadInt(_T("/view_whitespace"), 0));
XRCCTRL(*this, "rbTabText", wxRadioBox)->SetSelection(cfg->ReadBool(_T("/tab_text_relative"), true)? 1 : 0);
- XRCCTRL(*this, "chkTrackPreprocessor", wxCheckBox)->SetValue(cfg->ReadBool(_T("/track_preprocessor"), false));
- XRCCTRL(*this, "chkCollectPrjDefines", wxCheckBox)->SetValue(cfg->ReadBool(_T("/collect_prj_defines"), false));
+ XRCCTRL(*this, "chkTrackPreprocessor", wxCheckBox)->SetValue(cfg->ReadBool(_T("/track_preprocessor"), true));
+ XRCCTRL(*this, "chkCollectPrjDefines", wxCheckBox)->SetValue(cfg->ReadBool(_T("/collect_prj_defines"), true));
XRCCTRL(*this, "chkPlatDefines", wxCheckBox)->SetValue(cfg->ReadBool(_T("/platform_defines"), false));
XRCCTRL(*this, "chkColoursWxSmith", wxCheckBox)->SetValue(cfg->ReadBool(_T("/highlight_wxsmith"), true));
I have no idea how this happens (and I cannot reproduce it).