Patch #3103 2010-12-16 22:12

danselmi

Make GetCommentLexerStyle() and friends langauge dependant.
Download
3103-Make_GetCommen.patch (16.2 KB)
Category
Application::Refinement
Status
Accepted
Close date
2010-12-27 15:31
Assigned to
mortenmacfly
Index: include/cbstyledtextctrl.h
===================================================================
--- include/cbstyledtextctrl.h    (revision 6863)
+++ include/cbstyledtextctrl.h    (working copy)
@@ -9,6 +9,9 @@
 #include "wx/wxscintilla.h"
 #include <wx/longlong.h>
 
+#include <map>
+#include <set>
+
 class wxContextMenuEvent;
 class wxFocusEvent;
 class wxMouseEvent;
@@ -27,6 +30,11 @@
         bool IsComment(int style);
         void CallTipCancel();
 
+        static std::map<int, std::set<int> > &GetCharacterLexerStyles();
+        static std::map<int, std::set<int> > &GetStringLexerStyles();
+        static std::map<int, std::set<int> > &GetPreprocessorLexerStyles();
+        static std::map<int, std::set<int> > &GetCommentLexerStyles();
+
     private:
         void OnContextMenu(wxContextMenuEvent& event);
         void OnKillFocus(wxFocusEvent& event);
@@ -45,6 +53,8 @@
         int m_lastPosition;
         bool m_tabSmartJump;
 
+        static std::map<int, std::set<int> > CharacterLexerStyles, StringLexerStyles, PreprocessorLexerStyles, CommentLexerStyles;
+
         DECLARE_EVENT_TABLE()
 };
 
Index: include/editorcolourset.h
===================================================================
--- include/editorcolourset.h    (revision 6863)
+++ include/editorcolourset.h    (working copy)
@@ -13,6 +13,8 @@
 #include "settings.h"
 #include "globals.h" // HighlightLanguage
 
+#include <set>
+
 // forward decls
 class cbEditor;
 class cbStyledTextCtrl;
@@ -65,6 +67,7 @@
 
     CommentToken comment;
     bool m_CaseSensitive;
+    //std::set<int> CommentStyles, StringStyles, CharacterStyles, PreprocessorStyles;
 };
 WX_DECLARE_STRING_HASH_MAP(OptionSet, OptionSetsMap);
 
@@ -113,6 +116,10 @@
         void SetCommentToken(HighlightLanguage lang, CommentToken token);
         bool GetCaseSensitivity(HighlightLanguage lang);
         void SetCaseSensitivity(HighlightLanguage lang, bool CaseSensitive);
+        void SetStringLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
+        void SetCommentLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
+        void SetCharacterLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
+        void SetPreprocessorLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
     protected:
     private:
         void DoApplyStyle(cbStyledTextCtrl* control, int value, OptionColour* option);
Index: include/editorlexerloader.h
===================================================================
--- include/editorlexerloader.h    (revision 6863)
+++ include/editorlexerloader.h    (working copy)
@@ -26,6 +26,7 @@
         void DoSingleKeywordNode(HighlightLanguage language, TiXmlElement* node, const wxString& nodename);
         void DoSampleCode(HighlightLanguage language, TiXmlElement* node);
         void DoLangAttributes(HighlightLanguage language, TiXmlElement* node);
+        bool DoLangAttributesLexerStyles(TiXmlElement* attribs, const char *attributeName, std::set<int> &styles);
         EditorColourSet* m_pTarget;
     private:
 };
Index: sdk/cbstyledtextctrl.cpp
===================================================================
--- sdk/cbstyledtextctrl.cpp    (revision 6863)
+++ sdk/cbstyledtextctrl.cpp    (working copy)
@@ -22,6 +22,11 @@
 static const wxString s_rightBrace(_T(")]}'\""));
 static const int s_indicHighlight(20);
 
+std::map<int, std::set<int> > cbStyledTextCtrl::CharacterLexerStyles;
+std::map<int, std::set<int> > cbStyledTextCtrl::StringLexerStyles;
+std::map<int, std::set<int> > cbStyledTextCtrl::PreprocessorLexerStyles;
+std::map<int, std::set<int> > cbStyledTextCtrl::CommentLexerStyles;
+
 BEGIN_EVENT_TABLE(cbStyledTextCtrl, wxScintilla)
     EVT_CONTEXT_MENU(cbStyledTextCtrl::OnContextMenu)
     EVT_KILL_FOCUS  (cbStyledTextCtrl::OnKillFocus)
@@ -247,61 +252,22 @@
 
 bool cbStyledTextCtrl::IsCharacter(int style)
 {
-    switch (GetLexer())
-    {
-    case wxSCI_LEX_CPP:
-        return style == wxSCI_C_CHARACTER;
-    case wxSCI_LEX_D:
-        return style == wxSCI_D_CHARACTER;
-    default:
-        return false;
-    }
-    return false;
+    return CharacterLexerStyles[GetLexer()].find(style) != CharacterLexerStyles[GetLexer()].end();
 }
 
 bool cbStyledTextCtrl::IsString(int style)
 {
-    switch (GetLexer())
-    {
-    case wxSCI_LEX_CPP:
-        return style == wxSCI_C_STRING;
-    case wxSCI_LEX_D:
-        return style == wxSCI_D_STRING;
-    default:
-        return false;
-    }
-    return false;
+    return StringLexerStyles[GetLexer()].find(style) != StringLexerStyles[GetLexer()].end();
 }
 
 bool cbStyledTextCtrl::IsPreprocessor(int style)
 {
-    if (GetLexer() == wxSCI_LEX_CPP)
-        return  style == wxSCI_C_PREPROCESSOR;
-    return false;
+    return PreprocessorLexerStyles[GetLexer()].find(style) != PreprocessorLexerStyles[GetLexer()].end();
 }
 
 bool cbStyledTextCtrl::IsComment(int style)
 {
-    switch (GetLexer())
-    {
-    case wxSCI_LEX_CPP:
-
download for full patch...