src/eric7/QScintilla/Lexers/LexerCoffeeScript.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class LexerCoffeeScript(Lexer, QsciLexerCoffeeScript): 16 class LexerCoffeeScript(Lexer, QsciLexerCoffeeScript):
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 QsciLexerCoffeeScript.__init__(self, parent) 27 QsciLexerCoffeeScript.__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": "###\n", "end": "\n###"}
31 'start': '###\n', 32
32 'end': '\n###'
33 }
34
35 self.keywordSetDescriptions = [ 33 self.keywordSetDescriptions = [
36 self.tr("Keywords"), 34 self.tr("Keywords"),
37 self.tr("Secondary keywords"), 35 self.tr("Secondary keywords"),
38 self.tr("Unused"), 36 self.tr("Unused"),
39 self.tr("Global classes"), 37 self.tr("Global classes"),
40 ] 38 ]
41 39
42 def initProperties(self): 40 def initProperties(self):
43 """ 41 """
44 Public slot to initialize the properties. 42 Public slot to initialize the properties.
45 """ 43 """
46 self.setDollarsAllowed( 44 self.setDollarsAllowed(Preferences.getEditor("CoffeeScriptDollarsAllowed"))
47 Preferences.getEditor("CoffeeScriptDollarsAllowed")) 45 self.setFoldComments(Preferences.getEditor("CoffeScriptFoldComment"))
48 self.setFoldComments(
49 Preferences.getEditor("CoffeScriptFoldComment"))
50 self.setStylePreprocessor( 46 self.setStylePreprocessor(
51 Preferences.getEditor("CoffeeScriptStylePreprocessor")) 47 Preferences.getEditor("CoffeeScriptStylePreprocessor")
52 self.setFoldCompact( 48 )
53 Preferences.getEditor("AllFoldCompact")) 49 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
54 50
55 def isCommentStyle(self, style): 51 def isCommentStyle(self, style):
56 """ 52 """
57 Public method to check, if a style is a comment style. 53 Public method to check, if a style is a comment style.
58 54
59 @param style style to check (integer) 55 @param style style to check (integer)
60 @return flag indicating a comment style (boolean) 56 @return flag indicating a comment style (boolean)
61 """ 57 """
62 return style in [QsciLexerCoffeeScript.Comment, 58 return style in [
63 QsciLexerCoffeeScript.CommentDoc, 59 QsciLexerCoffeeScript.Comment,
64 QsciLexerCoffeeScript.CommentLine, 60 QsciLexerCoffeeScript.CommentDoc,
65 QsciLexerCoffeeScript.CommentLineDoc, 61 QsciLexerCoffeeScript.CommentLine,
66 QsciLexerCoffeeScript.CommentBlock, 62 QsciLexerCoffeeScript.CommentLineDoc,
67 QsciLexerCoffeeScript.BlockRegexComment] 63 QsciLexerCoffeeScript.CommentBlock,
68 64 QsciLexerCoffeeScript.BlockRegexComment,
65 ]
66
69 def isStringStyle(self, style): 67 def isStringStyle(self, style):
70 """ 68 """
71 Public method to check, if a style is a string style. 69 Public method to check, if a style is a string style.
72 70
73 @param style style to check (integer) 71 @param style style to check (integer)
74 @return flag indicating a string style (boolean) 72 @return flag indicating a string style (boolean)
75 """ 73 """
76 return style in [QsciLexerCoffeeScript.DoubleQuotedString, 74 return style in [
77 QsciLexerCoffeeScript.SingleQuotedString, 75 QsciLexerCoffeeScript.DoubleQuotedString,
78 QsciLexerCoffeeScript.UnclosedString, 76 QsciLexerCoffeeScript.SingleQuotedString,
79 QsciLexerCoffeeScript.VerbatimString] 77 QsciLexerCoffeeScript.UnclosedString,
80 78 QsciLexerCoffeeScript.VerbatimString,
79 ]
80
81 def defaultKeywords(self, kwSet): 81 def defaultKeywords(self, kwSet):
82 """ 82 """
83 Public method to get the default keywords. 83 Public method to get the default keywords.
84 84
85 @param kwSet number of the keyword set (integer) 85 @param kwSet number of the keyword set (integer)
86 @return string giving the keywords (string) or None 86 @return string giving the keywords (string) or None
87 """ 87 """
88 return QsciLexerCoffeeScript.keywords(self, kwSet) 88 return QsciLexerCoffeeScript.keywords(self, kwSet)
89 89
90 def maximumKeywordSet(self): 90 def maximumKeywordSet(self):
91 """ 91 """
92 Public method to get the maximum keyword set. 92 Public method to get the maximum keyword set.
93 93
94 @return maximum keyword set (integer) 94 @return maximum keyword set (integer)
95 """ 95 """
96 return 4 96 return 4

eric ide

mercurial