eric7/QScintilla/Lexers/LexerPascal.py

branch
eric7
changeset 8312
800c432b34c8
parent 8243
cc717c2ae956
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2008 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a Pascal lexer with some additional methods.
8 """
9
10 import contextlib
11
12 from PyQt5.Qsci import QsciLexerPascal
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerPascal(Lexer, QsciLexerPascal):
19 """
20 Subclass to implement some additional lexer dependant methods.
21 """
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent parent widget of this lexer
27 """
28 QsciLexerPascal.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.commentString = "//"
32 self.streamCommentString = {
33 'start': '{ ',
34 'end': ' }'
35 }
36
37 self.keywordSetDescriptions = [
38 self.tr("Keywords"),
39 ]
40
41 def initProperties(self):
42 """
43 Public slot to initialize the properties.
44 """
45 self.setFoldComments(Preferences.getEditor("PascalFoldComment"))
46 self.setFoldPreprocessor(
47 Preferences.getEditor("PascalFoldPreprocessor"))
48 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
49 with contextlib.suppress(AttributeError):
50 self.setSmartHighlighting(
51 Preferences.getEditor("PascalSmartHighlighting"))
52
53 def autoCompletionWordSeparators(self):
54 """
55 Public method to return the list of separators for autocompletion.
56
57 @return list of separators (list of strings)
58 """
59 return ['.']
60
61 def isCommentStyle(self, style):
62 """
63 Public method to check, if a style is a comment style.
64
65 @param style style to check (integer)
66 @return flag indicating a comment style (boolean)
67 """
68 try:
69 return style in [QsciLexerPascal.Comment,
70 QsciLexerPascal.CommentDoc,
71 QsciLexerPascal.CommentLine]
72 except AttributeError:
73 return style in [QsciLexerPascal.Comment,
74 QsciLexerPascal.CommentParenthesis,
75 QsciLexerPascal.CommentLine]
76
77 def isStringStyle(self, style):
78 """
79 Public method to check, if a style is a string style.
80
81 @param style style to check (integer)
82 @return flag indicating a string style (boolean)
83 """
84 return style in [QsciLexerPascal.SingleQuotedString]
85
86 def defaultKeywords(self, kwSet):
87 """
88 Public method to get the default keywords.
89
90 @param kwSet number of the keyword set (integer)
91 @return string giving the keywords (string) or None
92 """
93 return QsciLexerPascal.keywords(self, kwSet)

eric ide

mercurial