(self, start=0, end=-1)
| 200 | self.ColorSeg(startSeg, i-1, state) |
| 201 | |
| 202 | def Colorize(self, start=0, end=-1): |
| 203 | # scintilla's formatting is all done in terms of utf, so |
| 204 | # we work with utf8 bytes instead of unicode. This magically |
| 205 | # works as any extended chars found in the utf8 don't change |
| 206 | # the semantics. |
| 207 | stringVal = self.scintilla.GetTextRange(start, end, decode=False) |
| 208 | styleStart = None |
| 209 | stylePyStart = None |
| 210 | if start > 1: |
| 211 | # Likely we are being asked to color from the start of the line. |
| 212 | # We find the last formatted character on the previous line. |
| 213 | # If TQString, we continue it. Otherwise, we reset. |
| 214 | look = start -1 |
| 215 | while look and self.scintilla.SCIGetCharAt(look) in '\n\r': |
| 216 | look = look - 1 |
| 217 | if look and look < start-1: # Did we find a char before the \n\r sets? |
| 218 | strstyle = self.GetStringStyle(look) |
| 219 | quote_char = None |
| 220 | if strstyle is not None: |
| 221 | if strstyle.name == pywin.scintilla.formatter.STYLE_TQSSTRING: |
| 222 | quote_char = "'" |
| 223 | elif strstyle.name == pywin.scintilla.formatter.STYLE_TQDSTRING: |
| 224 | quote_char = '"' |
| 225 | if quote_char is not None: |
| 226 | # It is a TQS. If the TQS is not terminated, we |
| 227 | # carry the style through. |
| 228 | if look > 2: |
| 229 | look_str = self.scintilla.SCIGetCharAt(look-2) + self.scintilla.SCIGetCharAt(look-1) + self.scintilla.SCIGetCharAt(look) |
| 230 | if look_str != quote_char * 3: |
| 231 | stylePyStart = strstyle.name |
| 232 | if stylePyStart is None: stylePyStart = pywin.scintilla.formatter.STYLE_DEFAULT |
| 233 | |
| 234 | if start > 0: |
| 235 | stylenum = self.scintilla.SCIGetStyleAt(start - 1) |
| 236 | styleStart = self.GetStyleByNum(stylenum).name |
| 237 | elif self.bannerDisplayed: |
| 238 | styleStart = STYLE_INTERACTIVE_EOL |
| 239 | else: |
| 240 | styleStart = STYLE_INTERACTIVE_BANNER |
| 241 | self.bannerDisplayed = True |
| 242 | self.scintilla.SCIStartStyling(start, 31) |
| 243 | self.style_buffer = array.array("b", (0,)*len(stringVal)) |
| 244 | self.ColorizeInteractiveCode(stringVal, styleStart, stylePyStart) |
| 245 | self.scintilla.SCISetStylingEx(self.style_buffer) |
| 246 | self.style_buffer = None |
| 247 | |
| 248 | ############################################################### |
| 249 | # |
no test coverage detected