eric6/E5XML/HighlightingStylesReader.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8022
2da0139f4f91
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2010 - 2021 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
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
11 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
12
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Config import highlightingStylesFileFormatVersion
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .XMLStreamReaderBase import XMLStreamReaderBase
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
16
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class HighlightingStylesReader(XMLStreamReaderBase):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 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
20 """
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
21 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
22
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 def __init__(self, device, lexers):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @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
28 @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
29 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 XMLStreamReaderBase.__init__(self, device)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.lexers = lexers
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.version = ""
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def readXML(self):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 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
39 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 while not self.atEnd():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.readNext()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 if self.isStartElement():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 if self.name() == "HighlightingStyles":
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
44 self.version = self.attribute(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
45 "version",
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 highlightingStylesFileFormatVersion)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 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
48 self.raiseUnsupportedFormatVersion(self.version)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 elif self.name() == "Lexer":
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__readLexer()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 else:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.raiseUnexpectedStartTag(self.name())
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.showErrorMessage()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def __readLexer(self):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 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
59 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 language = self.attribute("name")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 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
62 lexer = self.lexers[language]
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 else:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 lexer = None
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 while not self.atEnd():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.readNext()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 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
69 break
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 if self.isStartElement():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 if self.name() == "Style":
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__readStyle(lexer)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 else:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.raiseUnexpectedStartTag(self.name())
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def __readStyle(self, lexer):
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 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
80
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @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
82 """
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 if lexer is not None:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 style = self.attribute("style")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 if style:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 style = int(style)
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
87 substyle = int(self.attribute("substyle", "-1"))
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
88 # -1 is default for base styles
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
89
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
90 # 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
91 if not lexer.hasStyle(style, substyle):
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
92 substyle = lexer.addSubstyle(style)
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 color = self.attribute("color")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 if color:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 color = QColor(color)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
98 color = lexer.defaultColor(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
99 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
100
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 paper = self.attribute("paper")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 if paper:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 paper = QColor(paper)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
105 paper = lexer.defaultPaper(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
106 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
107
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 fontStr = self.attribute("font")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 if fontStr:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 font = QFont()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 font.fromString(fontStr)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
113 font = lexer.defaultFont(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
114 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
115
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 eolfill = self.attribute("eolfill")
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 if eolfill:
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 eolfill = self.toBool(eolfill)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 if eolfill is None:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
120 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
121 else:
6863
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
122 eolfill = lexer.defaulEolFill(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
123 lexer.setEolFill(eolfill, style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
124
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
125 while not self.atEnd():
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
126 self.readNext()
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
127 if self.isStartElement():
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
128 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
129 # 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
130 description = self.readElementText().strip()
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
131 if not description:
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
132 description = lexer.defaultDescription(
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
133 style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
134 lexer.setDescription(description, style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
135 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
136 # 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
137 words = self.readElementText().strip()
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
138 if not words:
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
139 words = lexer.defaultWords(style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
140 lexer.setWords(words, style, substyle)
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
141
e900929889dd HighlightingStylesReader, -Writer: added support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6857
diff changeset
142 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
143 return
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 while not self.atEnd():
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.readNext()
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 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
148 break

eric ide

mercurial