48 PYGMENTS_OTHER, \ |
48 PYGMENTS_OTHER, \ |
49 PYGMENTS_NUMBER, \ |
49 PYGMENTS_NUMBER, \ |
50 PYGMENTS_HEADING, \ |
50 PYGMENTS_HEADING, \ |
51 PYGMENTS_SUBHEADING, \ |
51 PYGMENTS_SUBHEADING, \ |
52 PYGMENTS_DELETED, \ |
52 PYGMENTS_DELETED, \ |
53 PYGMENTS_INSERTED = range(32) |
53 PYGMENTS_INSERTED = list(range(32)) |
54 # 32 to 39 are reserved for QScintilla internal styles |
54 # 32 to 39 are reserved for QScintilla internal styles |
55 PYGMENTS_GENERIC_ERROR, \ |
55 PYGMENTS_GENERIC_ERROR, \ |
56 PYGMENTS_EMPHASIZE, \ |
56 PYGMENTS_EMPHASIZE, \ |
57 PYGMENTS_STRONG, \ |
57 PYGMENTS_STRONG, \ |
58 PYGMENTS_PROMPT, \ |
58 PYGMENTS_PROMPT, \ |
59 PYGMENTS_OUTPUT, \ |
59 PYGMENTS_OUTPUT, \ |
60 PYGMENTS_TRACEBACK, \ |
60 PYGMENTS_TRACEBACK, \ |
61 PYGMENTS_ERROR = range(40, 47) |
61 PYGMENTS_ERROR = list(range(40, 47)) |
62 |
62 |
63 #-----------------------------------------------------------------------------# |
63 #-----------------------------------------------------------------------------# |
64 |
64 |
65 TOKEN_MAP = { |
65 TOKEN_MAP = { |
66 Token.Comment: PYGMENTS_COMMENT, |
66 Token.Comment: PYGMENTS_COMMENT, |
341 @return flag indicating the lexer capability (boolean) |
341 @return flag indicating the lexer capability (boolean) |
342 """ |
342 """ |
343 if self.editor is None: |
343 if self.editor is None: |
344 return True |
344 return True |
345 |
345 |
346 text = self.editor.text().encode('utf-8') |
346 ## text = self.editor.text().encode('utf-8') |
|
347 text = self.editor.text() |
347 self.__lexer = self.__guessLexer(text) |
348 self.__lexer = self.__guessLexer(text) |
348 |
349 |
349 return self.__lexer is not None |
350 return self.__lexer is not None |
350 |
351 |
351 def name(self): |
352 def name(self): |
364 Public method to perform the styling. |
365 Public method to perform the styling. |
365 |
366 |
366 @param start position of first character to be styled (integer) |
367 @param start position of first character to be styled (integer) |
367 @param end position of last character to be styled (integer) |
368 @param end position of last character to be styled (integer) |
368 """ |
369 """ |
369 text = self.editor.text()[:end + 1].encode('utf-8') |
370 ## text = self.editor.text()[:end + 1].encode('utf-8') |
|
371 text = self.editor.text()[:end + 1] |
370 self.__lexer = self.__guessLexer(text) |
372 self.__lexer = self.__guessLexer(text) |
371 |
373 |
372 cpos = 0 |
374 cpos = 0 |
373 self.editor.startStyling(cpos, 0x3f) |
375 self.editor.startStyling(cpos, 0x3f) |
374 if self.__lexer is None: |
376 if self.__lexer is None: |