src/eric7/QScintilla/Lexers/LexerTCL.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2008 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a TCL/Tk lexer with some additional methods.
8 """
9
10 import contextlib
11
12 from PyQt6.Qsci import QsciLexerTCL
13
14 from .Lexer import Lexer
15
16 import Preferences
17
18
19 class LexerTCL(Lexer, QsciLexerTCL):
20 """
21 Subclass to implement some additional lexer dependant methods.
22 """
23 def __init__(self, parent=None):
24 """
25 Constructor
26
27 @param parent parent widget of this lexer
28 """
29 QsciLexerTCL.__init__(self, parent)
30 Lexer.__init__(self)
31
32 self.commentString = "#"
33
34 self.keywordSetDescriptions = [
35 self.tr("TCL Keywords"),
36 self.tr("TK Keywords"),
37 self.tr("iTCL Keywords"),
38 self.tr("TK Commands"),
39 self.tr("expand"),
40 self.tr("User defined 1"),
41 self.tr("User defined 2"),
42 self.tr("User defined 3"),
43 self.tr("User defined 4"),
44 ]
45
46 def initProperties(self):
47 """
48 Public slot to initialize the properties.
49 """
50 with contextlib.suppress(AttributeError):
51 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
52 with contextlib.suppress(AttributeError):
53 self.setFoldComments(Preferences.getEditor("TclFoldComment"))
54
55 def isCommentStyle(self, style):
56 """
57 Public method to check, if a style is a comment style.
58
59 @param style style to check (integer)
60 @return flag indicating a comment style (boolean)
61 """
62 return style in [QsciLexerTCL.Comment,
63 QsciLexerTCL.CommentBlock,
64 QsciLexerTCL.CommentBox,
65 QsciLexerTCL.CommentLine]
66
67 def isStringStyle(self, style):
68 """
69 Public method to check, if a style is a string style.
70
71 @param style style to check (integer)
72 @return flag indicating a string style (boolean)
73 """
74 return style in [QsciLexerTCL.QuotedString]
75
76 def defaultKeywords(self, kwSet):
77 """
78 Public method to get the default keywords.
79
80 @param kwSet number of the keyword set (integer)
81 @return string giving the keywords (string) or None
82 """
83 return QsciLexerTCL.keywords(self, kwSet)
84
85 def maximumKeywordSet(self):
86 """
87 Public method to get the maximum keyword set.
88
89 @return maximum keyword set (integer)
90 """
91 return 9

eric ide

mercurial