Patch #3333 2012-09-11 03:21

alpha0010

Define collection: make persistent
Download
3333-Define_collect.patch (900 bytes)
Category
Application::Refinement
Status
Accepted
Close date
2012-09-30 07:49
Assigned to
mortenmacfly
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (revision 8383)
+++ src/sdk/editormanager.cpp    (working copy)
@@ -3212,7 +3212,11 @@
             defines.Add(wxT("__IA64__"));
         }
     }
-    m_Theme->SetKeywords(m_Theme->GetHighlightLanguage(wxT("C/C++")), 4, GetStringFromArray(MakeUniqueArray(defines, true), wxT(" "), false));
+    wxString keywords = GetStringFromArray(MakeUniqueArray(defines, true), wxT(" "), false);
+    m_Theme->SetKeywords(m_Theme->GetHighlightLanguage(wxT("C/C++")), 4, keywords);
+    wxString key = wxT("/colour_sets/") + m_Theme->GetName() + wxT("/cc/");
+    Manager::Get()->GetConfigManager(wxT("editor"))->Write(key + wxT("editor/keywords/set4"), keywords);
+    Manager::Get()->GetConfigManager(wxT("editor"))->Write(key + wxT("name"), wxT("C/C++"));
     event.Skip();
 }
 
mortenmacfly 2012-09-11 08:56

Why exactly do you do this? And what, if you are working on multiple projects sharing the same file but with different project settings? Imagine a project having two targets: One for Windows and one for Linux or cross-compilation. What, if you change the platform of the target during development, does it update the #defines? Does it really make sense to store this information instead of only collecting it on-line?

alpha0010 2012-09-12 20:47

This does not change any behavior during run-time. The only thing it changes is that the last collected defines from the previous launch are reloaded during start up.

Doing this helps mitigate the problem that files are only highlighted based on what defines were set when the file was opened (during the opening of a project, it seems all files are loaded before defines are collected).

Define collection already updates the defines every time the active project/build target is switched.

So I guess you could say this patch is more of a partial workaround for a bug (open files are not updated after define collection) that I do not know how to solve :).