eric6/E5XML/HighlightingStylesReader.py

Sat, 21 Sep 2019 16:04:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 21 Sep 2019 16:04:17 +0200
changeset 7253
50dbe65a1334
parent 7229
53054eb5b15a
child 7360
9190402e4505
permissions
-rw-r--r--

Continued to resolve code style issue M841.

593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2010 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Module implementing a class for reading a highlighting styles XML file.
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
12 from PyQt5.QtGui import QColor, QFont
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Config import highlightingStylesFileFormatVersion
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .XMLStreamReaderBase import XMLStreamReaderBase
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
17
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class HighlightingStylesReader(XMLStreamReaderBase):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class for reading a highlighting styles XML file.
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
22 supportedVersions = ["4.3", "6.0"]
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, device, lexers):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param device reference to the I/O device to read from (QIODevice)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param lexers list of lexer objects for which to export the styles
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 XMLStreamReaderBase.__init__(self, device)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.lexers = lexers
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.version = ""
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 def readXML(self):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 Public method to read and parse the XML document.
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 while not self.atEnd():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.readNext()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 if self.isStartElement():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 if self.name() == "HighlightingStyles":
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
45 self.version = self.attribute(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
46 "version",
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 highlightingStylesFileFormatVersion)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 if self.version not in self.supportedVersions:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.raiseUnsupportedFormatVersion(self.version)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 elif self.name() == "Lexer":
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__readLexer()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 else:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.raiseUnexpectedStartTag(self.name())
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.showErrorMessage()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 def __readLexer(self):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 Private method to read the lexer info.
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 language = self.attribute("name")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 if language and language in self.lexers:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 lexer = self.lexers[language]
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 else:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 lexer = None
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 while not self.atEnd():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.readNext()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 if self.isEndElement() and self.name() == "Lexer":
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 break
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 if self.isStartElement():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 if self.name() == "Style":
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__readStyle(lexer)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 else:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.raiseUnexpectedStartTag(self.name())
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 def __readStyle(self, lexer):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Private method to read the style info.
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @param lexer reference to the lexer object
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if lexer is not None:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 style = self.attribute("style")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 if style:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 style = int(style)
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
88 substyle = int(self.attribute("substyle", "-1"))
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
89 # -1 is default for base styles
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
90
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
91 # add sub-style if not already there
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
92 if not lexer.hasStyle(style, substyle):
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
93 substyle = lexer.addSubstyle(style)
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 color = self.attribute("color")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 if color:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 color = QColor(color)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
99 color = lexer.defaultColor(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
100 lexer.setColor(color, style, substyle)
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 paper = self.attribute("paper")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 if paper:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 paper = QColor(paper)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
106 paper = lexer.defaultPaper(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
107 lexer.setPaper(paper, style, substyle)
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 fontStr = self.attribute("font")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 if fontStr:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 font = QFont()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 font.fromString(fontStr)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
114 font = lexer.defaultFont(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
115 lexer.setFont(font, style, substyle)
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 eolfill = self.attribute("eolfill")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 if eolfill:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 eolfill = self.toBool(eolfill)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if eolfill is None:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
121 eolfill = lexer.defaulEolFill(style, substyle)
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
123 eolfill = lexer.defaulEolFill(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
124 lexer.setEolFill(eolfill, style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
125
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
126 while not self.atEnd():
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
127 self.readNext()
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
128 if self.isStartElement():
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
129 if self.name() == "Description" and substyle >= 0:
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
130 # description can only be set for sub-styles
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
131 description = self.readElementText().strip()
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
132 if not description:
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
133 description = lexer.defaultDescription(
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
134 style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
135 lexer.setDescription(description, style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
136 elif self.name() == "Words" and substyle >= 0:
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
137 # words can only be set for sub-styles
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
138 words = self.readElementText().strip()
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
139 if not words:
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
140 words = lexer.defaultWords(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
141 lexer.setWords(words, style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
142
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
143 if self.isEndElement() and self.name() == "Style":
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
144 return
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 while not self.atEnd():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.readNext()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 if self.isEndElement() and self.name() == "Style":
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 break

eric ide

mercurial