15 |
15 |
16 class LexerLua(Lexer, QsciLexerLua): |
16 class LexerLua(Lexer, QsciLexerLua): |
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 QsciLexerLua.__init__(self, parent) |
27 QsciLexerLua.__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 |
32 'end': ' ]]--' |
|
33 } |
|
34 |
|
35 self.keywordSetDescriptions = [ |
33 self.keywordSetDescriptions = [ |
36 self.tr("Keywords"), |
34 self.tr("Keywords"), |
37 self.tr("Basic functions"), |
35 self.tr("Basic functions"), |
38 self.tr("String, (table) & math functions"), |
36 self.tr("String, (table) & math functions"), |
39 self.tr("Coroutines, I/O & system facilities"), |
37 self.tr("Coroutines, I/O & system facilities"), |
40 self.tr("User defined 1"), |
38 self.tr("User defined 1"), |
41 self.tr("User defined 2"), |
39 self.tr("User defined 2"), |
42 self.tr("User defined 3"), |
40 self.tr("User defined 3"), |
43 self.tr("User defined 4"), |
41 self.tr("User defined 4"), |
44 ] |
42 ] |
45 |
43 |
46 def initProperties(self): |
44 def initProperties(self): |
47 """ |
45 """ |
48 Public slot to initialize the properties. |
46 Public slot to initialize the properties. |
49 """ |
47 """ |
50 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
48 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
51 |
49 |
52 def autoCompletionWordSeparators(self): |
50 def autoCompletionWordSeparators(self): |
53 """ |
51 """ |
54 Public method to return the list of separators for autocompletion. |
52 Public method to return the list of separators for autocompletion. |
55 |
53 |
56 @return list of separators (list of strings) |
54 @return list of separators (list of strings) |
57 """ |
55 """ |
58 return [':', '.'] |
56 return [":", "."] |
59 |
57 |
60 def isCommentStyle(self, style): |
58 def isCommentStyle(self, style): |
61 """ |
59 """ |
62 Public method to check, if a style is a comment style. |
60 Public method to check, if a style is a comment style. |
63 |
61 |
64 @param style style to check (integer) |
62 @param style style to check (integer) |
65 @return flag indicating a comment style (boolean) |
63 @return flag indicating a comment style (boolean) |
66 """ |
64 """ |
67 return style in [QsciLexerLua.Comment, |
65 return style in [QsciLexerLua.Comment, QsciLexerLua.LineComment] |
68 QsciLexerLua.LineComment] |
66 |
69 |
|
70 def isStringStyle(self, style): |
67 def isStringStyle(self, style): |
71 """ |
68 """ |
72 Public method to check, if a style is a string style. |
69 Public method to check, if a style is a string style. |
73 |
70 |
74 @param style style to check (integer) |
71 @param style style to check (integer) |
75 @return flag indicating a string style (boolean) |
72 @return flag indicating a string style (boolean) |
76 """ |
73 """ |
77 return style in [QsciLexerLua.String, |
74 return style in [ |
78 QsciLexerLua.LiteralString, |
75 QsciLexerLua.String, |
79 QsciLexerLua.UnclosedString] |
76 QsciLexerLua.LiteralString, |
80 |
77 QsciLexerLua.UnclosedString, |
|
78 ] |
|
79 |
81 def defaultKeywords(self, kwSet): |
80 def defaultKeywords(self, kwSet): |
82 """ |
81 """ |
83 Public method to get the default keywords. |
82 Public method to get the default keywords. |
84 |
83 |
85 @param kwSet number of the keyword set (integer) |
84 @param kwSet number of the keyword set (integer) |
86 @return string giving the keywords (string) or None |
85 @return string giving the keywords (string) or None |
87 """ |
86 """ |
88 return QsciLexerLua.keywords(self, kwSet) |
87 return QsciLexerLua.keywords(self, kwSet) |
89 |
88 |
90 def maximumKeywordSet(self): |
89 def maximumKeywordSet(self): |
91 """ |
90 """ |
92 Public method to get the maximum keyword set. |
91 Public method to get the maximum keyword set. |
93 |
92 |
94 @return maximum keyword set (integer) |
93 @return maximum keyword set (integer) |
95 """ |
94 """ |
96 return 8 |
95 return 8 |