15 |
15 |
16 class LexerJavaScript(Lexer, QsciLexerJavaScript): |
16 class LexerJavaScript(Lexer, QsciLexerJavaScript): |
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 QsciLexerJavaScript.__init__(self, parent) |
27 QsciLexerJavaScript.__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("Global classes and typedefs"), |
38 self.tr("Global classes and typedefs"), |
45 self.tr("Preprocessor definitions"), |
39 self.tr("Preprocessor definitions"), |
46 self.tr("Task marker and error marker keywords"), |
40 self.tr("Task marker and error marker keywords"), |
47 ] |
41 ] |
48 |
42 |
49 def initProperties(self): |
43 def initProperties(self): |
50 """ |
44 """ |
51 Public slot to initialize the properties. |
45 Public slot to initialize the properties. |
52 """ |
46 """ |
53 self.setFoldComments(Preferences.getEditor("CppFoldComment")) |
47 self.setFoldComments(Preferences.getEditor("CppFoldComment")) |
58 indentStyle |= QsciScintilla.AiOpening |
52 indentStyle |= QsciScintilla.AiOpening |
59 if Preferences.getEditor("CppIndentClosingBrace"): |
53 if Preferences.getEditor("CppIndentClosingBrace"): |
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 isCommentStyle(self, style): |
58 def isCommentStyle(self, style): |
65 """ |
59 """ |
66 Public method to check, if a style is a comment style. |
60 Public method to check, if a style is a comment style. |
67 |
61 |
68 @param style style to check (integer) |
62 @param style style to check (integer) |
69 @return flag indicating a comment style (boolean) |
63 @return flag indicating a comment style (boolean) |
70 """ |
64 """ |
71 return style in [QsciLexerJavaScript.Comment, |
65 return style in [ |
72 QsciLexerJavaScript.CommentDoc, |
66 QsciLexerJavaScript.Comment, |
73 QsciLexerJavaScript.CommentLine, |
67 QsciLexerJavaScript.CommentDoc, |
74 QsciLexerJavaScript.CommentLineDoc] |
68 QsciLexerJavaScript.CommentLine, |
75 |
69 QsciLexerJavaScript.CommentLineDoc, |
|
70 ] |
|
71 |
76 def isStringStyle(self, style): |
72 def isStringStyle(self, style): |
77 """ |
73 """ |
78 Public method to check, if a style is a string style. |
74 Public method to check, if a style is a string style. |
79 |
75 |
80 @param style style to check (integer) |
76 @param style style to check (integer) |
81 @return flag indicating a string style (boolean) |
77 @return flag indicating a string style (boolean) |
82 """ |
78 """ |
83 return style in [QsciLexerJavaScript.DoubleQuotedString, |
79 return style in [ |
84 QsciLexerJavaScript.SingleQuotedString, |
80 QsciLexerJavaScript.DoubleQuotedString, |
85 QsciLexerJavaScript.UnclosedString, |
81 QsciLexerJavaScript.SingleQuotedString, |
86 QsciLexerJavaScript.VerbatimString] |
82 QsciLexerJavaScript.UnclosedString, |
87 |
83 QsciLexerJavaScript.VerbatimString, |
|
84 ] |
|
85 |
88 def defaultKeywords(self, kwSet): |
86 def defaultKeywords(self, kwSet): |
89 """ |
87 """ |
90 Public method to get the default keywords. |
88 Public method to get the default keywords. |
91 |
89 |
92 @param kwSet number of the keyword set (integer) |
90 @param kwSet number of the keyword set (integer) |
93 @return string giving the keywords (string) or None |
91 @return string giving the keywords (string) or None |
94 """ |
92 """ |
95 return QsciLexerJavaScript.keywords(self, kwSet) |
93 return QsciLexerJavaScript.keywords(self, kwSet) |
96 |
94 |
97 def maximumKeywordSet(self): |
95 def maximumKeywordSet(self): |
98 """ |
96 """ |
99 Public method to get the maximum keyword set. |
97 Public method to get the maximum keyword set. |
100 |
98 |
101 @return maximum keyword set (integer) |
99 @return maximum keyword set (integer) |
102 """ |
100 """ |
103 return 4 |
101 return 4 |