Lexers, LexerPython: changed support for Cython from Pygments to QScintilla based lexer with a sub-style for Cython specific words.

Tue, 19 Mar 2019 19:07:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 19 Mar 2019 19:07:05 +0100
changeset 6881
054667c5c270
parent 6880
51f8a56f0b42
child 6882
65d1bf4b7427

Lexers, LexerPython: changed support for Cython from Pygments to QScintilla based lexer with a sub-style for Cython specific words.

QScintilla/Lexers/LexerPython.py file | annotate | diff | comparison | revisions
QScintilla/Lexers/__init__.py file | annotate | diff | comparison | revisions
Utilities/__init__.py file | annotate | diff | comparison | revisions
--- a/QScintilla/Lexers/LexerPython.py	Tue Mar 19 19:03:27 2019 +0100
+++ b/QScintilla/Lexers/LexerPython.py	Tue Mar 19 19:07:05 2019 +0100
@@ -100,6 +100,14 @@
                         "font_bold": True,
                     }
                 },
+                3: {
+                    "Description": self.tr("Cython Specifics"),
+                    "Words": "cython pyximport Cython __cinit__ __dealloc__",
+                    "Style": {
+                        "fore": 0xdd0000,
+                        "font_bold": True,
+                    }
+                },
             },
         }
     
@@ -227,13 +235,18 @@
                 keywords = ("and as assert break class continue def del elif "
                             "else except exec finally for from global if "
                             "import in is lambda not or pass print raise "
-                            "return try while with yield cdef cimport cpdef")
+                            "return try while with yield")
             elif self.language() == "Python3":
                 keywords = ("False None True and as assert break class "
                             "continue def del elif else except finally for "
                             "from global if import in is lambda nonlocal not "
-                            "or pass raise return try while with yield cdef "
-                            "cimport cpdef")
+                            "or pass raise return try while with yield")
+            elif self.language() == "Cython":
+                keywords = ("False None True and as assert break class "
+                            "continue def del elif else except finally for "
+                            "from global if import in is lambda nonlocal not "
+                            "or pass raise return try while with yield "
+                            "cdef cimport cpdef ctypedef")
             else:
                 keywords = QsciLexerPython.keywords(self, kwSet)
         else:
--- a/QScintilla/Lexers/__init__.py	Tue Mar 19 19:03:27 2019 +0100
+++ b/QScintilla/Lexers/__init__.py	Tue Mar 19 19:07:05 2019 +0100
@@ -228,7 +228,7 @@
     """
     if not pyname:
         try:
-            if language in ["Python", "Python2", "Python3"]:
+            if language in ["Python", "Python2", "Python3", "Cython"]:
                 from .LexerPython import LexerPython
                 return LexerPython(language, parent)
             elif language == "C++":
@@ -341,9 +341,6 @@
             
             elif language == "Protocol":
                 return __getPygmentsLexer(parent, name="Protocol Buffer")
-            # TODO: move this up to use LexerPython
-            elif language == "Cython":
-                return __getPygmentsLexer(parent, name="Cython")
             
             elif language in LexerRegistry:
                 return LexerRegistry[language][2](parent)
--- a/Utilities/__init__.py	Tue Mar 19 19:03:27 2019 +0100
+++ b/Utilities/__init__.py	Tue Mar 19 19:07:05 2019 +0100
@@ -1594,9 +1594,6 @@
         
         if pyVer == 0 and ext in py2Ext + py3Ext:
             pyVer = sys.version_info[0]
-        
-        if editor and pyVer:
-            editor.filetype = "Python{0}".format(pyVer)
     
     return pyVer
 

eric ide

mercurial