QScintilla/Lexers/LexerCPP.py

branch
sub_styles
changeset 6845
4680adb641e0
parent 6645
ad476851d7e0
child 6846
6ca9ef2c0907
diff -r d706eb5bc040 -r 4680adb641e0 QScintilla/Lexers/LexerCPP.py
--- a/QScintilla/Lexers/LexerCPP.py	Sat Mar 09 10:04:18 2019 +0100
+++ b/QScintilla/Lexers/LexerCPP.py	Sat Mar 09 17:36:44 2019 +0100
@@ -9,13 +9,14 @@
 
 from __future__ import unicode_literals
 
+from PyQt5.QtCore import QCoreApplication
 from PyQt5.Qsci import QsciLexerCPP, QsciScintilla
 
-from .Lexer import Lexer
+from .SubstyledLexer import SubstyledLexer
 import Preferences
 
 
-class LexerCPP(Lexer, QsciLexerCPP):
+class LexerCPP(SubstyledLexer, QsciLexerCPP):
     """
     Subclass to implement some additional lexer dependant methods.
     """
@@ -28,7 +29,7 @@
             insensitive (boolean)
         """
         QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords)
-        Lexer.__init__(self)
+        SubstyledLexer.__init__(self)
         
         self.commentString = "//"
         self.streamCommentString = {
@@ -40,6 +41,68 @@
             'middle': ' * ',
             'end': ' */'
         }
+        
+        ##############################################################
+        ## default sub-style definitions
+        ##############################################################
+        
+        # list of style numbers, that support sub-styling
+        self.baseStyles = [11, 17, 75, 81]
+        
+        self.defaultSubStyles = {
+            11: {
+                "SubStyleLength": 1,
+                "SubStyles": [
+                    {
+                        "Description": QCoreApplication.translate(
+                            "LexerCPP", "Extra Identifiers"),
+                        "Words": "std map string vector",
+                        "Style": {
+                            "fore": 0xEE00AA,
+                        }
+                    },
+                ]
+            },
+            17: {
+                "SubStyleLength": 1,
+                "SubStyles": [
+                    {
+                        "Description": QCoreApplication.translate(
+                            "LexerCPP", "Extra Doc Comment Keywords"),
+                        "Words": "check",
+                        "Style": {
+                            "fore": 0x00AAEE,
+                        }
+                    },
+                ]
+            },
+            75: {
+                "SubStyleLength": 1,
+                "SubStyles": [
+                    {
+                        "Description": QCoreApplication.translate(
+                            "LexerCPP", "Inactive Extra Identifiers"),
+                        "Words": "std map string vector",
+                        "Style": {
+                            "fore": 0xBB6666,
+                        }
+                    },
+                ]
+            },
+            81: {
+                "SubStyleLength": 1,
+                "SubStyles": [
+                    {
+                        "Description": QCoreApplication.translate(
+                            "LexerCPP", "Inactive Extra Doc Comment Keywords"),
+                        "Words": "check",
+                        "Style": {
+                            "fore": 0x6699AA,
+                        }
+                    },
+                ]
+            },
+        }
 
     def initProperties(self):
         """

eric ide

mercurial