7 Module implementing a CPP lexer with some additional methods. |
7 Module implementing a CPP lexer with some additional methods. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
|
12 from PyQt5.QtCore import QCoreApplication |
12 from PyQt5.Qsci import QsciLexerCPP, QsciScintilla |
13 from PyQt5.Qsci import QsciLexerCPP, QsciScintilla |
13 |
14 |
14 from .Lexer import Lexer |
15 from .SubstyledLexer import SubstyledLexer |
15 import Preferences |
16 import Preferences |
16 |
17 |
17 |
18 |
18 class LexerCPP(Lexer, QsciLexerCPP): |
19 class LexerCPP(SubstyledLexer, QsciLexerCPP): |
19 """ |
20 """ |
20 Subclass to implement some additional lexer dependant methods. |
21 Subclass to implement some additional lexer dependant methods. |
21 """ |
22 """ |
22 def __init__(self, parent=None, caseInsensitiveKeywords=False): |
23 def __init__(self, parent=None, caseInsensitiveKeywords=False): |
23 """ |
24 """ |
26 @param parent parent widget of this lexer |
27 @param parent parent widget of this lexer |
27 @param caseInsensitiveKeywords flag indicating keywords are case |
28 @param caseInsensitiveKeywords flag indicating keywords are case |
28 insensitive (boolean) |
29 insensitive (boolean) |
29 """ |
30 """ |
30 QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords) |
31 QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords) |
31 Lexer.__init__(self) |
32 SubstyledLexer.__init__(self) |
32 |
33 |
33 self.commentString = "//" |
34 self.commentString = "//" |
34 self.streamCommentString = { |
35 self.streamCommentString = { |
35 'start': '/* ', |
36 'start': '/* ', |
36 'end': ' */' |
37 'end': ' */' |
38 self.boxCommentString = { |
39 self.boxCommentString = { |
39 'start': '/* ', |
40 'start': '/* ', |
40 'middle': ' * ', |
41 'middle': ' * ', |
41 'end': ' */' |
42 'end': ' */' |
42 } |
43 } |
|
44 |
|
45 ############################################################## |
|
46 ## default sub-style definitions |
|
47 ############################################################## |
|
48 |
|
49 # list of style numbers, that support sub-styling |
|
50 self.baseStyles = [11, 17, 75, 81] |
|
51 |
|
52 self.defaultSubStyles = { |
|
53 11: { |
|
54 "SubStyleLength": 1, |
|
55 "SubStyles": [ |
|
56 { |
|
57 "Description": QCoreApplication.translate( |
|
58 "LexerCPP", "Extra Identifiers"), |
|
59 "Words": "std map string vector", |
|
60 "Style": { |
|
61 "fore": 0xEE00AA, |
|
62 } |
|
63 }, |
|
64 ] |
|
65 }, |
|
66 17: { |
|
67 "SubStyleLength": 1, |
|
68 "SubStyles": [ |
|
69 { |
|
70 "Description": QCoreApplication.translate( |
|
71 "LexerCPP", "Extra Doc Comment Keywords"), |
|
72 "Words": "check", |
|
73 "Style": { |
|
74 "fore": 0x00AAEE, |
|
75 } |
|
76 }, |
|
77 ] |
|
78 }, |
|
79 75: { |
|
80 "SubStyleLength": 1, |
|
81 "SubStyles": [ |
|
82 { |
|
83 "Description": QCoreApplication.translate( |
|
84 "LexerCPP", "Inactive Extra Identifiers"), |
|
85 "Words": "std map string vector", |
|
86 "Style": { |
|
87 "fore": 0xBB6666, |
|
88 } |
|
89 }, |
|
90 ] |
|
91 }, |
|
92 81: { |
|
93 "SubStyleLength": 1, |
|
94 "SubStyles": [ |
|
95 { |
|
96 "Description": QCoreApplication.translate( |
|
97 "LexerCPP", "Inactive Extra Doc Comment Keywords"), |
|
98 "Words": "check", |
|
99 "Style": { |
|
100 "fore": 0x6699AA, |
|
101 } |
|
102 }, |
|
103 ] |
|
104 }, |
|
105 } |
43 |
106 |
44 def initProperties(self): |
107 def initProperties(self): |
45 """ |
108 """ |
46 Public slot to initialize the properties. |
109 Public slot to initialize the properties. |
47 """ |
110 """ |