QScintilla/Lexers/LexerPygments.py

Sat, 14 Dec 2013 23:44:25 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 14 Dec 2013 23:44:25 +0100
branch
Py2 comp.
changeset 3145
a9de05d4a22f
parent 3060
5883ce99ee12
child 3161
06f57a834adf
permissions
-rw-r--r--

# __IGNORE_WARNING__ added/ removed.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1563
diff changeset
3 # Copyright (c) 2008 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a custom lexer using pygments.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2519
diff changeset
11
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from pygments.token import Token
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
13 from pygments.lexers import guess_lexer_for_filename, guess_lexer, \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
14 find_lexer_class
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from pygments.util import ClassNotFound
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt4.QtGui import QColor, QFont
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from QScintilla.Lexers.LexerContainer import LexerContainer
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import Utilities
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
3042
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
23 PYGMENTS_DEFAULT = 0
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
24 PYGMENTS_COMMENT = 1
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
25 PYGMENTS_PREPROCESSOR = 2
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
26 PYGMENTS_KEYWORD = 3
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
27 PYGMENTS_PSEUDOKEYWORD = 4
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
28 PYGMENTS_TYPEKEYWORD = 5
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
29 PYGMENTS_OPERATOR = 6
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
30 PYGMENTS_WORD = 7
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
31 PYGMENTS_BUILTIN = 8
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
32 PYGMENTS_FUNCTION = 9
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
33 PYGMENTS_CLASS = 10
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
34 PYGMENTS_NAMESPACE = 11
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
35 PYGMENTS_EXCEPTION = 12
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
36 PYGMENTS_VARIABLE = 13
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
37 PYGMENTS_CONSTANT = 14
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
38 PYGMENTS_LABEL = 15
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
39 PYGMENTS_ENTITY = 16
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
40 PYGMENTS_ATTRIBUTE = 17
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
41 PYGMENTS_TAG = 18
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
42 PYGMENTS_DECORATOR = 19
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
43 PYGMENTS_STRING = 20
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
44 PYGMENTS_DOCSTRING = 21
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
45 PYGMENTS_SCALAR = 22
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
46 PYGMENTS_ESCAPE = 23
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
47 PYGMENTS_REGEX = 24
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
48 PYGMENTS_SYMBOL = 25
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
49 PYGMENTS_OTHER = 26
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
50 PYGMENTS_NUMBER = 27
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
51 PYGMENTS_HEADING = 28
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
52 PYGMENTS_SUBHEADING = 29
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
53 PYGMENTS_DELETED = 30
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
54 PYGMENTS_INSERTED = 31
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 # 32 to 39 are reserved for QScintilla internal styles
3042
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
56 PYGMENTS_GENERIC_ERROR = 40
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
57 PYGMENTS_EMPHASIZE = 41
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
58 PYGMENTS_STRONG = 42
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
59 PYGMENTS_PROMPT = 43
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
60 PYGMENTS_OUTPUT = 44
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
61 PYGMENTS_TRACEBACK = 45
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
62 PYGMENTS_ERROR = 46
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
63 PYGMENTS_MULTILINECOMMENT = 47
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
64 PYGMENTS_PROPERTY = 48
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
65 PYGMENTS_CHAR = 49
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
66 PYGMENTS_HEREDOC = 50
c9c3c0982145 Updated source docu and changed the pygments lexer definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
67 PYGMENTS_PUNCTUATION = 51
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 #-----------------------------------------------------------------------------#
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 TOKEN_MAP = {
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
72 Token.Comment: PYGMENTS_COMMENT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
73 Token.Comment.Preproc: PYGMENTS_PREPROCESSOR,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
74 Token.Comment.Multiline: PYGMENTS_MULTILINECOMMENT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
75 Token.Comment.Single: PYGMENTS_COMMENT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
76 Token.Comment.Special: PYGMENTS_COMMENT,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
78 Token.Keyword: PYGMENTS_KEYWORD,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
79 Token.Keyword.Pseudo: PYGMENTS_PSEUDOKEYWORD,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
80 Token.Keyword.Type: PYGMENTS_TYPEKEYWORD,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
81 Token.Keyword.Namespace: PYGMENTS_KEYWORD,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
83 Token.Operator: PYGMENTS_OPERATOR,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
84 Token.Operator.Word: PYGMENTS_WORD,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
86 Token.Name: PYGMENTS_DEFAULT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
87 Token.Name.Builtin: PYGMENTS_BUILTIN,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
88 Token.Name.Builtin.Pseudo: PYGMENTS_BUILTIN,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
89 Token.Name.Function: PYGMENTS_FUNCTION,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
90 Token.Name.Class: PYGMENTS_CLASS,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
91 Token.Name.Namespace: PYGMENTS_NAMESPACE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
92 Token.Name.Exception: PYGMENTS_EXCEPTION,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
93 Token.Name.Variable: PYGMENTS_VARIABLE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
94 Token.Name.Variable.Class: PYGMENTS_VARIABLE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
95 Token.Name.Variable.Global: PYGMENTS_VARIABLE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
96 Token.Name.Variable.Instance: PYGMENTS_VARIABLE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
97 Token.Name.Constant: PYGMENTS_CONSTANT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
98 Token.Name.Label: PYGMENTS_LABEL,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
99 Token.Name.Entity: PYGMENTS_ENTITY,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
100 Token.Name.Attribute: PYGMENTS_ATTRIBUTE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
101 Token.Name.Tag: PYGMENTS_TAG,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
102 Token.Name.Decorator: PYGMENTS_DECORATOR,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
103 Token.Name.Property: PYGMENTS_PROPERTY,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
105 Token.String: PYGMENTS_STRING,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
106 Token.String.Char: PYGMENTS_CHAR,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
107 Token.String.Doc: PYGMENTS_DOCSTRING,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
108 Token.String.Interpol: PYGMENTS_SCALAR,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
109 Token.String.Escape: PYGMENTS_ESCAPE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
110 Token.String.Regex: PYGMENTS_REGEX,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
111 Token.String.Symbol: PYGMENTS_SYMBOL,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
112 Token.String.Other: PYGMENTS_OTHER,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
113 Token.String.Heredoc: PYGMENTS_HEREDOC,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
114
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
115 Token.Number: PYGMENTS_NUMBER,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
116 Token.Number.Float: PYGMENTS_NUMBER,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
117 Token.Number.Hex: PYGMENTS_NUMBER,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
118 Token.Number.Integer: PYGMENTS_NUMBER,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
119 Token.Number.Integer.Long: PYGMENTS_NUMBER,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
120 Token.Number.Oct: PYGMENTS_NUMBER,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
122 Token.Punctuation: PYGMENTS_PUNCTUATION,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
124 Token.Generic.Heading: PYGMENTS_HEADING,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
125 Token.Generic.Subheading: PYGMENTS_SUBHEADING,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
126 Token.Generic.Deleted: PYGMENTS_DELETED,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
127 Token.Generic.Inserted: PYGMENTS_INSERTED,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
128 Token.Generic.Error: PYGMENTS_GENERIC_ERROR,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
129 Token.Generic.Emph: PYGMENTS_EMPHASIZE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
130 Token.Generic.Strong: PYGMENTS_STRONG,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
131 Token.Generic.Prompt: PYGMENTS_PROMPT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
132 Token.Generic.Output: PYGMENTS_OUTPUT,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
133 Token.Generic.Traceback: PYGMENTS_TRACEBACK,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
134
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
135 Token.Error: PYGMENTS_ERROR,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 }
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 #-----------------------------------------------------------------------------#
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
140
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 class LexerPygments(LexerContainer):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
142 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 Class implementing a custom lexer using pygments.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
145 def __init__(self, parent=None, name=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @param parent parent widget of this lexer
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 @keyparam name name of the pygments lexer to use (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 LexerContainer.__init__(self, parent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 self.__pygmentsName = name
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.descriptions = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
157 PYGMENTS_DEFAULT: self.trUtf8("Default"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
158 PYGMENTS_COMMENT: self.trUtf8("Comment"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
159 PYGMENTS_PREPROCESSOR: self.trUtf8("Preprocessor"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
160 PYGMENTS_KEYWORD: self.trUtf8("Keyword"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
161 PYGMENTS_PSEUDOKEYWORD: self.trUtf8("Pseudo Keyword"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
162 PYGMENTS_TYPEKEYWORD: self.trUtf8("Type Keyword"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
163 PYGMENTS_OPERATOR: self.trUtf8("Operator"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
164 PYGMENTS_WORD: self.trUtf8("Word"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
165 PYGMENTS_BUILTIN: self.trUtf8("Builtin"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
166 PYGMENTS_FUNCTION: self.trUtf8("Function or method name"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
167 PYGMENTS_CLASS: self.trUtf8("Class name"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
168 PYGMENTS_NAMESPACE: self.trUtf8("Namespace"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
169 PYGMENTS_EXCEPTION: self.trUtf8("Exception"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
170 PYGMENTS_VARIABLE: self.trUtf8("Identifier"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
171 PYGMENTS_CONSTANT: self.trUtf8("Constant"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
172 PYGMENTS_LABEL: self.trUtf8("Label"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
173 PYGMENTS_ENTITY: self.trUtf8("Entity"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
174 PYGMENTS_ATTRIBUTE: self.trUtf8("Attribute"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
175 PYGMENTS_TAG: self.trUtf8("Tag"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
176 PYGMENTS_DECORATOR: self.trUtf8("Decorator"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
177 PYGMENTS_STRING: self.trUtf8("String"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
178 PYGMENTS_DOCSTRING: self.trUtf8("Documentation string"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
179 PYGMENTS_SCALAR: self.trUtf8("Scalar"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
180 PYGMENTS_ESCAPE: self.trUtf8("Escape"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
181 PYGMENTS_REGEX: self.trUtf8("Regular expression"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
182 PYGMENTS_SYMBOL: self.trUtf8("Symbol"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
183 PYGMENTS_OTHER: self.trUtf8("Other string"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
184 PYGMENTS_NUMBER: self.trUtf8("Number"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
185 PYGMENTS_HEADING: self.trUtf8("Heading"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
186 PYGMENTS_SUBHEADING: self.trUtf8("Subheading"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
187 PYGMENTS_DELETED: self.trUtf8("Deleted"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
188 PYGMENTS_INSERTED: self.trUtf8("Inserted"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
189 PYGMENTS_GENERIC_ERROR: self.trUtf8("Generic error"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
190 PYGMENTS_EMPHASIZE: self.trUtf8("Emphasized text"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
191 PYGMENTS_STRONG: self.trUtf8("Strong text"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
192 PYGMENTS_PROMPT: self.trUtf8("Prompt"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
193 PYGMENTS_OUTPUT: self.trUtf8("Output"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
194 PYGMENTS_TRACEBACK: self.trUtf8("Traceback"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
195 PYGMENTS_ERROR: self.trUtf8("Error"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
196 PYGMENTS_MULTILINECOMMENT: self.trUtf8("Comment block"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
197 PYGMENTS_PROPERTY: self.trUtf8("Property"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
198 PYGMENTS_CHAR: self.trUtf8("Character"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
199 PYGMENTS_HEREDOC: self.trUtf8("Here document"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
200 PYGMENTS_PUNCTUATION: self.trUtf8("Punctuation"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 }
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.defaultColors = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
204 PYGMENTS_DEFAULT: QColor("#000000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
205 PYGMENTS_COMMENT: QColor("#408080"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
206 PYGMENTS_PREPROCESSOR: QColor("#BC7A00"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
207 PYGMENTS_KEYWORD: QColor("#008000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
208 PYGMENTS_PSEUDOKEYWORD: QColor("#008000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
209 PYGMENTS_TYPEKEYWORD: QColor("#B00040"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
210 PYGMENTS_OPERATOR: QColor("#666666"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
211 PYGMENTS_WORD: QColor("#AA22FF"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
212 PYGMENTS_BUILTIN: QColor("#008000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
213 PYGMENTS_FUNCTION: QColor("#0000FF"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
214 PYGMENTS_CLASS: QColor("#0000FF"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
215 PYGMENTS_NAMESPACE: QColor("#0000FF"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
216 PYGMENTS_EXCEPTION: QColor("#D2413A"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
217 PYGMENTS_VARIABLE: QColor("#19177C"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
218 PYGMENTS_CONSTANT: QColor("#880000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
219 PYGMENTS_LABEL: QColor("#A0A000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
220 PYGMENTS_ENTITY: QColor("#999999"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
221 PYGMENTS_ATTRIBUTE: QColor("#7D9029"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
222 PYGMENTS_TAG: QColor("#008000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
223 PYGMENTS_DECORATOR: QColor("#AA22FF"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
224 PYGMENTS_STRING: QColor("#BA2121"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
225 PYGMENTS_DOCSTRING: QColor("#BA2121"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
226 PYGMENTS_SCALAR: QColor("#BB6688"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
227 PYGMENTS_ESCAPE: QColor("#BB6622"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
228 PYGMENTS_REGEX: QColor("#BB6688"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
229 PYGMENTS_SYMBOL: QColor("#19177C"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
230 PYGMENTS_OTHER: QColor("#008000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
231 PYGMENTS_NUMBER: QColor("#666666"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
232 PYGMENTS_HEADING: QColor("#000080"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
233 PYGMENTS_SUBHEADING: QColor("#800080"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
234 PYGMENTS_DELETED: QColor("#A00000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
235 PYGMENTS_INSERTED: QColor("#00A000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
236 PYGMENTS_GENERIC_ERROR: QColor("#FF0000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
237 PYGMENTS_PROMPT: QColor("#000080"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
238 PYGMENTS_OUTPUT: QColor("#808080"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
239 PYGMENTS_TRACEBACK: QColor("#0040D0"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
240 PYGMENTS_MULTILINECOMMENT: QColor("#007F00"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
241 PYGMENTS_PROPERTY: QColor("#00A0E0"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
242 PYGMENTS_CHAR: QColor("#7F007F"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
243 PYGMENTS_HEREDOC: QColor("#7F007F"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
244 PYGMENTS_PUNCTUATION: QColor("#000000"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 }
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.defaultPapers = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
248 PYGMENTS_ERROR: QColor("#FF0000"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
249 PYGMENTS_MULTILINECOMMENT: QColor("#A8FFA8"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
250 PYGMENTS_HEREDOC: QColor("#DDD0DD"),
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
251 }
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
252
815
093b3b8204d1 Fixed an issue in the new code where two names overlapped each other.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 808
diff changeset
253 self.defaultEolFills = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
254 PYGMENTS_ERROR: True,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
255 PYGMENTS_MULTILINECOMMENT: True,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
256 PYGMENTS_HEREDOC: True,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 }
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 def language(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 Public method returning the language of the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 @return language of the lexer (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 return "Guessed"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 def description(self, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 Public method returning the descriptions of the styles supported
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 by the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @param style style number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 @return description for the style (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 return self.descriptions[style]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 return ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 def defaultColor(self, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 Public method to get the default foreground color for a style.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 @param style style number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 @return foreground color (QColor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 return self.defaultColors[style]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 return LexerContainer.defaultColor(self, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 def defaultPaper(self, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 Public method to get the default background color for a style.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 @param style style number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 @return background color (QColor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 return self.defaultPapers[style]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 return LexerContainer.defaultPaper(self, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 def defaultFont(self, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 Public method to get the default font for a style.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 @param style style number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 @return font (QFont)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
311 if style in [PYGMENTS_COMMENT, PYGMENTS_PREPROCESSOR,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
312 PYGMENTS_MULTILINECOMMENT]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 if Utilities.isWindowsPlatform():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 f = QFont("Comic Sans MS", 9)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 f = QFont("Bitstream Vera Serif", 9)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 if style == PYGMENTS_PREPROCESSOR:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 f.setItalic(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 return f
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
321 if style in [PYGMENTS_STRING, PYGMENTS_CHAR]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 if Utilities.isWindowsPlatform():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 return QFont("Comic Sans MS", 10)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 return QFont("Bitstream Vera Serif", 10)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
327 if style in [PYGMENTS_KEYWORD, PYGMENTS_OPERATOR, PYGMENTS_WORD,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
328 PYGMENTS_BUILTIN, PYGMENTS_ATTRIBUTE, PYGMENTS_FUNCTION,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
329 PYGMENTS_CLASS, PYGMENTS_NAMESPACE, PYGMENTS_EXCEPTION,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
330 PYGMENTS_ENTITY, PYGMENTS_TAG, PYGMENTS_SCALAR,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
331 PYGMENTS_ESCAPE, PYGMENTS_HEADING, PYGMENTS_SUBHEADING,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
332 PYGMENTS_STRONG, PYGMENTS_PROMPT]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 f = LexerContainer.defaultFont(self, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 f.setBold(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 return f
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 if style in [PYGMENTS_DOCSTRING, PYGMENTS_EMPHASIZE]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 f = LexerContainer.defaultFont(self, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 f.setItalic(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 return f
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 return LexerContainer.defaultFont(self, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
344 def defaultEolFill(self, style):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
345 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
346 Public method to get the default fill to eol flag.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
347
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
348 @param style style number (integer)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
349 @return fill to eol flag (boolean)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
350 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
351 try:
815
093b3b8204d1 Fixed an issue in the new code where two names overlapped each other.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 808
diff changeset
352 return self.defaultEolFills[style]
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
353 except KeyError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
354 return LexerContainer.defaultEolFill(self, style)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
355
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def styleBitsNeeded(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Public method to get the number of style bits needed by the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 @return number of style bits needed (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 return 6
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 def __guessLexer(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 Private method to guess a pygments lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 @param text text to base guessing on (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 @return reference to the guessed lexer (pygments.lexer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 lexer = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 if self.__pygmentsName:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 lexerClass = find_lexer_class(self.__pygmentsName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 if lexerClass is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 lexer = lexerClass()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 elif text:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 # step 1: guess based on filename and text
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 if self.editor is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 fn = self.editor.getFileName()
871
fbbcef4f43fb Fixed an issue detecting a lexer for a new (unsaved) editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 815
diff changeset
382 if fn:
fbbcef4f43fb Fixed an issue detecting a lexer for a new (unsaved) editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 815
diff changeset
383 try:
fbbcef4f43fb Fixed an issue detecting a lexer for a new (unsaved) editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 815
diff changeset
384 lexer = guess_lexer_for_filename(fn, text)
fbbcef4f43fb Fixed an issue detecting a lexer for a new (unsaved) editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 815
diff changeset
385 except ClassNotFound:
fbbcef4f43fb Fixed an issue detecting a lexer for a new (unsaved) editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 815
diff changeset
386 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 # step 2: guess on text only
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 if lexer is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 lexer = guess_lexer(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 except ClassNotFound:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 return lexer
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 def canStyle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 Public method to check, if the lexer is able to style the text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 @return flag indicating the lexer capability (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 if self.editor is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
406 text = self.editor.text()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 self.__lexer = self.__guessLexer(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 return self.__lexer is not None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 def name(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 Public method to get the name of the pygments lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 @return name of the pygments lexer (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 if self.__lexer is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 return ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 return self.__lexer.name
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 def styleText(self, start, end):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 Public method to perform the styling.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 @param start position of first character to be styled (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 @param end position of last character to be styled (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
429 text = self.editor.text()[:end + 1]
2519
e245447026ad Fixed an issue in the Pygments lexer, that could cause a segmentation fault, if the file doesn't end with a newline.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
430 textLen = len(text.encode("utf-8"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 self.__lexer = self.__guessLexer(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 cpos = 0
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
434 # adjust start position because pygments ignores empty line at
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
435 # start of text
1563
9d2cccd2074e Fixed an issue with the Pygments lexer because it is ignoring trailing empty lines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
436 for c in text:
9d2cccd2074e Fixed an issue with the Pygments lexer because it is ignoring trailing empty lines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
437 if c == "\n":
9d2cccd2074e Fixed an issue with the Pygments lexer because it is ignoring trailing empty lines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
438 cpos += 1
9d2cccd2074e Fixed an issue with the Pygments lexer because it is ignoring trailing empty lines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
439 else:
9d2cccd2074e Fixed an issue with the Pygments lexer because it is ignoring trailing empty lines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
440 break
9d2cccd2074e Fixed an issue with the Pygments lexer because it is ignoring trailing empty lines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
441
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 self.editor.startStyling(cpos, 0x3f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 if self.__lexer is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 self.editor.setStyling(len(text), PYGMENTS_DEFAULT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 eolLen = len(self.editor.getLineSeparator())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 for token, txt in self.__lexer.get_tokens(text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 style = TOKEN_MAP.get(token, PYGMENTS_DEFAULT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449
684
2f29a0b6e1c7 Updated Pygments to version 1.3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 167
diff changeset
450 tlen = len(txt.encode('utf-8'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 if eolLen > 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 tlen += txt.count('\n')
2519
e245447026ad Fixed an issue in the Pygments lexer, that could cause a segmentation fault, if the file doesn't end with a newline.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
453 cpos += tlen
e245447026ad Fixed an issue in the Pygments lexer, that could cause a segmentation fault, if the file doesn't end with a newline.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
454 if tlen and cpos < textLen:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 self.editor.setStyling(tlen, style)
2657
eb87b82eca17 Fixed an issue in the Pygments lexer causing highlighting to stop prematurely.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2519
diff changeset
456 if cpos >= textLen:
2519
e245447026ad Fixed an issue in the Pygments lexer, that could cause a segmentation fault, if the file doesn't end with a newline.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
457 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 self.editor.startStyling(cpos, 0x3f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 def isCommentStyle(self, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 Public method to check, if a style is a comment style.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2657
diff changeset
464 @param style style to check (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 @return flag indicating a comment style (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 return style in [PYGMENTS_COMMENT]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 def isStringStyle(self, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 Public method to check, if a style is a string style.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2657
diff changeset
473 @param style style to check (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 @return flag indicating a string style (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
476 return style in [PYGMENTS_STRING, PYGMENTS_DOCSTRING, PYGMENTS_OTHER,
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
477 PYGMENTS_HEADING, PYGMENTS_SUBHEADING,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
478 PYGMENTS_EMPHASIZE, PYGMENTS_STRONG]
167
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
479
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
480 def defaultKeywords(self, kwSet):
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
481 """
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
482 Public method to get the default keywords.
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
483
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 871
diff changeset
484 @param kwSet number of the keyword set (integer)
167
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
485 @return string giving the keywords (string) or None
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
486 """
7508e44f4853 Fixed an issue with a missing method in LexerPygments.py and corrected some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
487 return None

eric ide

mercurial