eric6/Preferences/HighlightingStylesFile.py

branch
jsonfiles
changeset 8026
d3eacdbcb18b
parent 8022
2da0139f4f91
child 8028
a4f1b68c0737
--- a/eric6/Preferences/HighlightingStylesFile.py	Fri Jan 29 14:18:50 2021 +0100
+++ b/eric6/Preferences/HighlightingStylesFile.py	Fri Jan 29 14:19:41 2021 +0100
@@ -11,7 +11,6 @@
 import time
 
 from PyQt5.QtCore import QObject
-from PyQt5.QtGui import QColor, QFont
 
 from E5Gui import E5MessageBox
 from E5Gui.E5OverrideCursor import E5OverridenCursor
@@ -90,7 +89,7 @@
         
         return True
     
-    def readFile(self, filename: str, lexers: dict) -> bool:
+    def readFile(self, filename: str, lexers: dict) -> list:
         """
         Public method to read the highlighting styles data from a highlighting
         styles JSON file.
@@ -100,8 +99,8 @@
         @param lexers dictionary of lexer objects for which to import the
             styles
         @type dict of {str: PreferencesLexer}
-        @return flag indicating a successful read
-        @rtype bool
+        @return list of read lexer style definitions
+        @rtype list of dict
         """
         try:
             with open(filename, "r") as f:
@@ -116,24 +115,6 @@
                     " read.</p><p>Reason: {1}</p>"
                 ).format(filename, str(err))
             )
-            return False
+            return []
         
-        for lexerDict in stylesDict["lexers"]:
-            if lexerDict["name"] in lexers:
-                lexer = lexers[lexerDict["name"]]
-                for styleDict in lexerDict["styles"]:
-                    style = styleDict["style"]
-                    substyle = styleDict["substyle"]
-                    lexer.setColor(QColor(styleDict["color"]), style, substyle)
-                    lexer.setPaper(QColor(styleDict["paper"]), style, substyle)
-                    font = QFont()
-                    font.fromString(styleDict["font"])
-                    lexer.setFont(font, style, substyle)
-                    lexer.setEolFill(styleDict["eolfill"], style, substyle)
-                    if substyle >= 0:
-                        # description and words can only be set for sub-styles
-                        lexer.setDescription(styleDict["description"],
-                                             style, substyle)
-                        lexer.setWords(styleDict["words"], style, substyle)
-        
-        return True
+        return stylesDict["lexers"]

eric ide

mercurial