420 |
420 |
421 @param start position of first character to be styled (integer) |
421 @param start position of first character to be styled (integer) |
422 @param end position of last character to be styled (integer) |
422 @param end position of last character to be styled (integer) |
423 """ |
423 """ |
424 text = self.editor.text()[:end + 1] |
424 text = self.editor.text()[:end + 1] |
|
425 textLen = len(text.encode("utf-8")) |
425 self.__lexer = self.__guessLexer(text) |
426 self.__lexer = self.__guessLexer(text) |
426 |
427 |
427 cpos = 0 |
428 cpos = 0 |
428 # adjust start position because pygments ignores empty line at start of text |
429 # adjust start position because pygments ignores empty line at start of text |
429 for c in text: |
430 for c in text: |
441 style = TOKEN_MAP.get(token, PYGMENTS_DEFAULT) |
442 style = TOKEN_MAP.get(token, PYGMENTS_DEFAULT) |
442 |
443 |
443 tlen = len(txt.encode('utf-8')) |
444 tlen = len(txt.encode('utf-8')) |
444 if eolLen > 1: |
445 if eolLen > 1: |
445 tlen += txt.count('\n') |
446 tlen += txt.count('\n') |
446 if tlen: |
447 cpos += tlen |
|
448 if tlen and cpos < textLen: |
447 self.editor.setStyling(tlen, style) |
449 self.editor.setStyling(tlen, style) |
448 cpos += tlen |
450 else: |
|
451 break |
449 self.editor.startStyling(cpos, 0x3f) |
452 self.editor.startStyling(cpos, 0x3f) |
450 |
453 |
451 def isCommentStyle(self, style): |
454 def isCommentStyle(self, style): |
452 """ |
455 """ |
453 Public method to check, if a style is a comment style. |
456 Public method to check, if a style is a comment style. |