10 from PyQt4.Qsci import QsciLexerCPP, QsciScintilla |
10 from PyQt4.Qsci import QsciLexerCPP, QsciScintilla |
11 |
11 |
12 from .Lexer import Lexer |
12 from .Lexer import Lexer |
13 import Preferences |
13 import Preferences |
14 |
14 |
|
15 |
15 class LexerCPP(QsciLexerCPP, Lexer): |
16 class LexerCPP(QsciLexerCPP, Lexer): |
16 """ |
17 """ |
17 Subclass to implement some additional lexer dependant methods. |
18 Subclass to implement some additional lexer dependant methods. |
18 """ |
19 """ |
19 def __init__(self, parent=None, caseInsensitiveKeywords = False): |
20 def __init__(self, parent=None, caseInsensitiveKeywords=False): |
20 """ |
21 """ |
21 Constructor |
22 Constructor |
22 |
23 |
23 @param parent parent widget of this lexer |
24 @param parent parent widget of this lexer |
24 """ |
25 """ |
25 QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords) |
26 QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords) |
26 Lexer.__init__(self) |
27 Lexer.__init__(self) |
27 |
28 |
28 self.commentString = "//" |
29 self.commentString = "//" |
29 self.streamCommentString = { |
30 self.streamCommentString = { |
30 'start' : '/* ', |
31 'start': '/* ', |
31 'end' : ' */' |
32 'end': ' */' |
32 } |
33 } |
33 self.boxCommentString = { |
34 self.boxCommentString = { |
34 'start' : '/* ', |
35 'start': '/* ', |
35 'middle' : ' * ', |
36 'middle': ' * ', |
36 'end' : ' */' |
37 'end': ' */' |
37 } |
38 } |
38 |
39 |
39 def initProperties(self): |
40 def initProperties(self): |
40 """ |
41 """ |
41 Public slot to initialize the properties. |
42 Public slot to initialize the properties. |
67 """ |
68 """ |
68 Public method to check, if a style is a comment style. |
69 Public method to check, if a style is a comment style. |
69 |
70 |
70 @return flag indicating a comment style (boolean) |
71 @return flag indicating a comment style (boolean) |
71 """ |
72 """ |
72 return style in [QsciLexerCPP.Comment, |
73 return style in [QsciLexerCPP.Comment, |
73 QsciLexerCPP.CommentDoc, |
74 QsciLexerCPP.CommentDoc, |
74 QsciLexerCPP.CommentLine, |
75 QsciLexerCPP.CommentLine, |
75 QsciLexerCPP.CommentLineDoc] |
76 QsciLexerCPP.CommentLineDoc] |
76 |
77 |
77 def isStringStyle(self, style): |
78 def isStringStyle(self, style): |
78 """ |
79 """ |
79 Public method to check, if a style is a string style. |
80 Public method to check, if a style is a string style. |
80 |
81 |
81 @return flag indicating a string style (boolean) |
82 @return flag indicating a string style (boolean) |
82 """ |
83 """ |
83 return style in [QsciLexerCPP.DoubleQuotedString, |
84 return style in [QsciLexerCPP.DoubleQuotedString, |
84 QsciLexerCPP.SingleQuotedString, |
85 QsciLexerCPP.SingleQuotedString, |
85 QsciLexerCPP.UnclosedString, |
86 QsciLexerCPP.UnclosedString, |
86 QsciLexerCPP.VerbatimString] |
87 QsciLexerCPP.VerbatimString] |
87 |
88 |
88 def defaultKeywords(self, kwSet): |
89 def defaultKeywords(self, kwSet): |
89 """ |
90 """ |
90 Public method to get the default keywords. |
91 Public method to get the default keywords. |
91 |
92 |
92 @param kwSet number of the keyword set (integer) |
93 @param kwSet number of the keyword set (integer) |
93 @return string giving the keywords (string) or None |
94 @return string giving the keywords (string) or None |
94 """ |
95 """ |
95 return QsciLexerCPP.keywords(self, kwSet) |
96 return QsciLexerCPP.keywords(self, kwSet) |