8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 from pygments.token import Token |
12 from pygments.token import Token |
13 from pygments.lexers import guess_lexer_for_filename, guess_lexer, find_lexer_class |
13 from pygments.lexers import guess_lexer_for_filename, guess_lexer, \ |
|
14 find_lexer_class |
14 from pygments.util import ClassNotFound |
15 from pygments.util import ClassNotFound |
15 |
16 |
16 from PyQt4.QtGui import QColor, QFont |
17 from PyQt4.QtGui import QColor, QFont |
17 |
18 |
18 from QScintilla.Lexers.LexerContainer import LexerContainer |
19 from QScintilla.Lexers.LexerContainer import LexerContainer |
305 Public method to get the default font for a style. |
306 Public method to get the default font for a style. |
306 |
307 |
307 @param style style number (integer) |
308 @param style style number (integer) |
308 @return font (QFont) |
309 @return font (QFont) |
309 """ |
310 """ |
310 if style in [PYGMENTS_COMMENT, PYGMENTS_PREPROCESSOR, PYGMENTS_MULTILINECOMMENT]: |
311 if style in [PYGMENTS_COMMENT, PYGMENTS_PREPROCESSOR, |
|
312 PYGMENTS_MULTILINECOMMENT]: |
311 if Utilities.isWindowsPlatform(): |
313 if Utilities.isWindowsPlatform(): |
312 f = QFont("Comic Sans MS", 9) |
314 f = QFont("Comic Sans MS", 9) |
313 else: |
315 else: |
314 f = QFont("Bitstream Vera Serif", 9) |
316 f = QFont("Bitstream Vera Serif", 9) |
315 if style == PYGMENTS_PREPROCESSOR: |
317 if style == PYGMENTS_PREPROCESSOR: |
320 if Utilities.isWindowsPlatform(): |
322 if Utilities.isWindowsPlatform(): |
321 return QFont("Comic Sans MS", 10) |
323 return QFont("Comic Sans MS", 10) |
322 else: |
324 else: |
323 return QFont("Bitstream Vera Serif", 10) |
325 return QFont("Bitstream Vera Serif", 10) |
324 |
326 |
325 if style in [PYGMENTS_KEYWORD, PYGMENTS_OPERATOR, PYGMENTS_WORD, PYGMENTS_BUILTIN, |
327 if style in [PYGMENTS_KEYWORD, PYGMENTS_OPERATOR, PYGMENTS_WORD, |
326 PYGMENTS_ATTRIBUTE, PYGMENTS_FUNCTION, PYGMENTS_CLASS, |
328 PYGMENTS_BUILTIN, PYGMENTS_ATTRIBUTE, PYGMENTS_FUNCTION, |
327 PYGMENTS_NAMESPACE, PYGMENTS_EXCEPTION, PYGMENTS_ENTITY, |
329 PYGMENTS_CLASS, PYGMENTS_NAMESPACE, PYGMENTS_EXCEPTION, |
328 PYGMENTS_TAG, PYGMENTS_SCALAR, PYGMENTS_ESCAPE, PYGMENTS_HEADING, |
330 PYGMENTS_ENTITY, PYGMENTS_TAG, PYGMENTS_SCALAR, |
329 PYGMENTS_SUBHEADING, PYGMENTS_STRONG, PYGMENTS_PROMPT]: |
331 PYGMENTS_ESCAPE, PYGMENTS_HEADING, PYGMENTS_SUBHEADING, |
|
332 PYGMENTS_STRONG, PYGMENTS_PROMPT]: |
330 f = LexerContainer.defaultFont(self, style) |
333 f = LexerContainer.defaultFont(self, style) |
331 f.setBold(True) |
334 f.setBold(True) |
332 return f |
335 return f |
333 |
336 |
334 if style in [PYGMENTS_DOCSTRING, PYGMENTS_EMPHASIZE]: |
337 if style in [PYGMENTS_DOCSTRING, PYGMENTS_EMPHASIZE]: |
455 |
459 |
456 def isCommentStyle(self, style): |
460 def isCommentStyle(self, style): |
457 """ |
461 """ |
458 Public method to check, if a style is a comment style. |
462 Public method to check, if a style is a comment style. |
459 |
463 |
|
464 @param style style to check (integer) |
460 @return flag indicating a comment style (boolean) |
465 @return flag indicating a comment style (boolean) |
461 """ |
466 """ |
462 return style in [PYGMENTS_COMMENT] |
467 return style in [PYGMENTS_COMMENT] |
463 |
468 |
464 def isStringStyle(self, style): |
469 def isStringStyle(self, style): |
465 """ |
470 """ |
466 Public method to check, if a style is a string style. |
471 Public method to check, if a style is a string style. |
467 |
472 |
|
473 @param style style to check (integer) |
468 @return flag indicating a string style (boolean) |
474 @return flag indicating a string style (boolean) |
469 """ |
475 """ |
470 return style in [PYGMENTS_STRING, PYGMENTS_DOCSTRING, PYGMENTS_OTHER, |
476 return style in [PYGMENTS_STRING, PYGMENTS_DOCSTRING, PYGMENTS_OTHER, |
471 PYGMENTS_HEADING, PYGMENTS_SUBHEADING, PYGMENTS_EMPHASIZE, |
477 PYGMENTS_HEADING, PYGMENTS_SUBHEADING, |
472 PYGMENTS_STRONG] |
478 PYGMENTS_EMPHASIZE, PYGMENTS_STRONG] |
473 |
479 |
474 def defaultKeywords(self, kwSet): |
480 def defaultKeywords(self, kwSet): |
475 """ |
481 """ |
476 Public method to get the default keywords. |
482 Public method to get the default keywords. |
477 |
483 |