84 """ |
84 """ |
85 if lexer is not None: |
85 if lexer is not None: |
86 style = self.attribute("style") |
86 style = self.attribute("style") |
87 if style: |
87 if style: |
88 style = int(style) |
88 style = int(style) |
|
89 substyle = int(self.attribute("substyle", "-1")) |
|
90 # -1 is default for base styles |
|
91 |
|
92 # add sub-style if not already there |
|
93 if not lexer.hasStyle(style, substyle): |
|
94 substyle = lexer.addSubstyle(style) |
89 |
95 |
90 color = self.attribute("color") |
96 color = self.attribute("color") |
91 if color: |
97 if color: |
92 color = QColor(color) |
98 color = QColor(color) |
93 else: |
99 else: |
94 color = lexer.defaultColor(style) |
100 color = lexer.defaultColor(style, substyle) |
95 lexer.setColor(color, style) |
101 lexer.setColor(color, style, substyle) |
96 |
102 |
97 paper = self.attribute("paper") |
103 paper = self.attribute("paper") |
98 if paper: |
104 if paper: |
99 paper = QColor(paper) |
105 paper = QColor(paper) |
100 else: |
106 else: |
101 paper = lexer.defaultPaper(style) |
107 paper = lexer.defaultPaper(style, substyle) |
102 lexer.setPaper(paper, style) |
108 lexer.setPaper(paper, style, substyle) |
103 |
109 |
104 fontStr = self.attribute("font") |
110 fontStr = self.attribute("font") |
105 if fontStr: |
111 if fontStr: |
106 font = QFont() |
112 font = QFont() |
107 font.fromString(fontStr) |
113 font.fromString(fontStr) |
108 else: |
114 else: |
109 font = lexer.defaultFont(style) |
115 font = lexer.defaultFont(style, substyle) |
110 lexer.setFont(font, style) |
116 lexer.setFont(font, style, substyle) |
111 |
117 |
112 eolfill = self.attribute("eolfill") |
118 eolfill = self.attribute("eolfill") |
113 if eolfill: |
119 if eolfill: |
114 eolfill = self.toBool(eolfill) |
120 eolfill = self.toBool(eolfill) |
115 if eolfill is None: |
121 if eolfill is None: |
116 eolfill = lexer.defaulEolFill(style) |
122 eolfill = lexer.defaulEolFill(style, substyle) |
117 else: |
123 else: |
118 eolfill = lexer.defaulEolFill(style) |
124 eolfill = lexer.defaulEolFill(style, substyle) |
119 lexer.setEolFill(eolfill, style) |
125 lexer.setEolFill(eolfill, style, substyle) |
|
126 |
|
127 while not self.atEnd(): |
|
128 self.readNext() |
|
129 if self.isStartElement(): |
|
130 if self.name() == "Description" and substyle >= 0: |
|
131 # description can only be set for sub-styles |
|
132 description = self.readElementText().strip() |
|
133 if not description: |
|
134 description = lexer.defaultDescription( |
|
135 style, substyle) |
|
136 lexer.setDescription(description, style, substyle) |
|
137 elif self.name() == "Words" and substyle >= 0: |
|
138 # words can only be set for sub-styles |
|
139 words = self.readElementText().strip() |
|
140 if not words: |
|
141 words = lexer.defaultWords(style, substyle) |
|
142 lexer.setWords(words, style, substyle) |
|
143 |
|
144 if self.isEndElement() and self.name() == "Style": |
|
145 return |
120 |
146 |
121 while not self.atEnd(): |
147 while not self.atEnd(): |
122 self.readNext() |
148 self.readNext() |
123 if self.isEndElement() and self.name() == "Style": |
149 if self.isEndElement() and self.name() == "Style": |
124 break |
150 break |
125 |
|
126 if self.isStartElement(): |
|
127 self.raiseUnexpectedStartTag(self.name()) |
|