15 |
15 |
16 class LexerD(Lexer, QsciLexerD): |
16 class LexerD(Lexer, QsciLexerD): |
17 """ |
17 """ |
18 Subclass to implement some additional lexer dependant methods. |
18 Subclass to implement some additional lexer dependant methods. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, parent=None): |
21 def __init__(self, parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param parent parent widget of this lexer |
25 @param parent parent widget of this lexer |
25 """ |
26 """ |
26 QsciLexerD.__init__(self, parent) |
27 QsciLexerD.__init__(self, parent) |
27 Lexer.__init__(self) |
28 Lexer.__init__(self) |
28 |
29 |
29 self.commentString = "//" |
30 self.commentString = "//" |
30 self.streamCommentString = { |
31 self.streamCommentString = {"start": "/+ ", "end": " +/"} |
31 'start': '/+ ', |
32 self.boxCommentString = {"start": "/* ", "middle": " * ", "end": " */"} |
32 'end': ' +/' |
33 |
33 } |
|
34 self.boxCommentString = { |
|
35 'start': '/* ', |
|
36 'middle': ' * ', |
|
37 'end': ' */' |
|
38 } |
|
39 |
|
40 self.keywordSetDescriptions = [ |
34 self.keywordSetDescriptions = [ |
41 self.tr("Primary keywords and identifiers"), |
35 self.tr("Primary keywords and identifiers"), |
42 self.tr("Secondary keywords and identifiers"), |
36 self.tr("Secondary keywords and identifiers"), |
43 self.tr("Documentation comment keywords"), |
37 self.tr("Documentation comment keywords"), |
44 self.tr("Type definitions and aliases"), |
38 self.tr("Type definitions and aliases"), |
45 self.tr("User defined 1"), |
39 self.tr("User defined 1"), |
46 self.tr("User defined 2"), |
40 self.tr("User defined 2"), |
47 self.tr("User defined 3"), |
41 self.tr("User defined 3"), |
48 ] |
42 ] |
49 |
43 |
50 def initProperties(self): |
44 def initProperties(self): |
51 """ |
45 """ |
52 Public slot to initialize the properties. |
46 Public slot to initialize the properties. |
53 """ |
47 """ |
54 self.setFoldComments(Preferences.getEditor("DFoldComment")) |
48 self.setFoldComments(Preferences.getEditor("DFoldComment")) |
58 indentStyle |= QsciScintilla.AiOpening |
52 indentStyle |= QsciScintilla.AiOpening |
59 if Preferences.getEditor("DIndentClosingBrace"): |
53 if Preferences.getEditor("DIndentClosingBrace"): |
60 indentStyle |= QsciScintilla.AiClosing |
54 indentStyle |= QsciScintilla.AiClosing |
61 self.setAutoIndentStyle(indentStyle) |
55 self.setAutoIndentStyle(indentStyle) |
62 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
56 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
63 |
57 |
64 def autoCompletionWordSeparators(self): |
58 def autoCompletionWordSeparators(self): |
65 """ |
59 """ |
66 Public method to return the list of separators for autocompletion. |
60 Public method to return the list of separators for autocompletion. |
67 |
61 |
68 @return list of separators (list of strings) |
62 @return list of separators (list of strings) |
69 """ |
63 """ |
70 return ['.'] |
64 return ["."] |
71 |
65 |
72 def isCommentStyle(self, style): |
66 def isCommentStyle(self, style): |
73 """ |
67 """ |
74 Public method to check, if a style is a comment style. |
68 Public method to check, if a style is a comment style. |
75 |
69 |
76 @param style style to check (integer) |
70 @param style style to check (integer) |
77 @return flag indicating a comment style (boolean) |
71 @return flag indicating a comment style (boolean) |
78 """ |
72 """ |
79 return style in [QsciLexerD.Comment, |
73 return style in [ |
80 QsciLexerD.CommentDoc, |
74 QsciLexerD.Comment, |
81 QsciLexerD.CommentLine, |
75 QsciLexerD.CommentDoc, |
82 QsciLexerD.CommentLineDoc, |
76 QsciLexerD.CommentLine, |
83 QsciLexerD.CommentNested] |
77 QsciLexerD.CommentLineDoc, |
84 |
78 QsciLexerD.CommentNested, |
|
79 ] |
|
80 |
85 def isStringStyle(self, style): |
81 def isStringStyle(self, style): |
86 """ |
82 """ |
87 Public method to check, if a style is a string style. |
83 Public method to check, if a style is a string style. |
88 |
84 |
89 @param style style to check (integer) |
85 @param style style to check (integer) |
90 @return flag indicating a string style (boolean) |
86 @return flag indicating a string style (boolean) |
91 """ |
87 """ |
92 return style in [QsciLexerD.String, |
88 return style in [QsciLexerD.String, QsciLexerD.UnclosedString] |
93 QsciLexerD.UnclosedString] |
89 |
94 |
|
95 def defaultKeywords(self, kwSet): |
90 def defaultKeywords(self, kwSet): |
96 """ |
91 """ |
97 Public method to get the default keywords. |
92 Public method to get the default keywords. |
98 |
93 |
99 @param kwSet number of the keyword set (integer) |
94 @param kwSet number of the keyword set (integer) |
100 @return string giving the keywords (string) or None |
95 @return string giving the keywords (string) or None |
101 """ |
96 """ |
102 return QsciLexerD.keywords(self, kwSet) |
97 return QsciLexerD.keywords(self, kwSet) |
103 |
98 |
104 def maximumKeywordSet(self): |
99 def maximumKeywordSet(self): |
105 """ |
100 """ |
106 Public method to get the maximum keyword set. |
101 Public method to get the maximum keyword set. |
107 |
102 |
108 @return maximum keyword set (integer) |
103 @return maximum keyword set (integer) |
109 """ |
104 """ |
110 return 7 |
105 return 7 |