src/eric7/QScintilla/Lexers/LexerPascal.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class LexerPascal(Lexer, QsciLexerPascal): 18 class LexerPascal(Lexer, QsciLexerPascal):
19 """ 19 """
20 Subclass to implement some additional lexer dependant methods. 20 Subclass to implement some additional lexer dependant methods.
21 """ 21 """
22
22 def __init__(self, parent=None): 23 def __init__(self, parent=None):
23 """ 24 """
24 Constructor 25 Constructor
25 26
26 @param parent parent widget of this lexer 27 @param parent parent widget of this lexer
27 """ 28 """
28 QsciLexerPascal.__init__(self, parent) 29 QsciLexerPascal.__init__(self, parent)
29 Lexer.__init__(self) 30 Lexer.__init__(self)
30 31
31 self.commentString = "//" 32 self.commentString = "//"
32 self.streamCommentString = { 33 self.streamCommentString = {"start": "{ ", "end": " }"}
33 'start': '{ ', 34
34 'end': ' }'
35 }
36
37 self.keywordSetDescriptions = [ 35 self.keywordSetDescriptions = [
38 self.tr("Keywords"), 36 self.tr("Keywords"),
39 ] 37 ]
40 38
41 def initProperties(self): 39 def initProperties(self):
42 """ 40 """
43 Public slot to initialize the properties. 41 Public slot to initialize the properties.
44 """ 42 """
45 self.setFoldComments(Preferences.getEditor("PascalFoldComment")) 43 self.setFoldComments(Preferences.getEditor("PascalFoldComment"))
46 self.setFoldPreprocessor( 44 self.setFoldPreprocessor(Preferences.getEditor("PascalFoldPreprocessor"))
47 Preferences.getEditor("PascalFoldPreprocessor"))
48 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) 45 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
49 with contextlib.suppress(AttributeError): 46 with contextlib.suppress(AttributeError):
50 self.setSmartHighlighting( 47 self.setSmartHighlighting(Preferences.getEditor("PascalSmartHighlighting"))
51 Preferences.getEditor("PascalSmartHighlighting")) 48
52
53 def autoCompletionWordSeparators(self): 49 def autoCompletionWordSeparators(self):
54 """ 50 """
55 Public method to return the list of separators for autocompletion. 51 Public method to return the list of separators for autocompletion.
56 52
57 @return list of separators (list of strings) 53 @return list of separators (list of strings)
58 """ 54 """
59 return ['.'] 55 return ["."]
60 56
61 def isCommentStyle(self, style): 57 def isCommentStyle(self, style):
62 """ 58 """
63 Public method to check, if a style is a comment style. 59 Public method to check, if a style is a comment style.
64 60
65 @param style style to check (integer) 61 @param style style to check (integer)
66 @return flag indicating a comment style (boolean) 62 @return flag indicating a comment style (boolean)
67 """ 63 """
68 try: 64 try:
69 return style in [QsciLexerPascal.Comment, 65 return style in [
70 QsciLexerPascal.CommentDoc, 66 QsciLexerPascal.Comment,
71 QsciLexerPascal.CommentLine] 67 QsciLexerPascal.CommentDoc,
68 QsciLexerPascal.CommentLine,
69 ]
72 except AttributeError: 70 except AttributeError:
73 return style in [QsciLexerPascal.Comment, 71 return style in [
74 QsciLexerPascal.CommentParenthesis, 72 QsciLexerPascal.Comment,
75 QsciLexerPascal.CommentLine] 73 QsciLexerPascal.CommentParenthesis,
76 74 QsciLexerPascal.CommentLine,
75 ]
76
77 def isStringStyle(self, style): 77 def isStringStyle(self, style):
78 """ 78 """
79 Public method to check, if a style is a string style. 79 Public method to check, if a style is a string style.
80 80
81 @param style style to check (integer) 81 @param style style to check (integer)
82 @return flag indicating a string style (boolean) 82 @return flag indicating a string style (boolean)
83 """ 83 """
84 return style in [QsciLexerPascal.SingleQuotedString] 84 return style in [QsciLexerPascal.SingleQuotedString]
85 85
86 def defaultKeywords(self, kwSet): 86 def defaultKeywords(self, kwSet):
87 """ 87 """
88 Public method to get the default keywords. 88 Public method to get the default keywords.
89 89
90 @param kwSet number of the keyword set (integer) 90 @param kwSet number of the keyword set (integer)
91 @return string giving the keywords (string) or None 91 @return string giving the keywords (string) or None
92 """ 92 """
93 return QsciLexerPascal.keywords(self, kwSet) 93 return QsciLexerPascal.keywords(self, kwSet)

eric ide

mercurial