src/eric7/QScintilla/Lexers/LexerBash.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) 2004 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a Bash lexer with some additional methods.
8 """
9
10 from PyQt6.Qsci import QsciLexerBash
11
12 from .Lexer import Lexer
13 import Preferences
14
15
16 class LexerBash(Lexer, QsciLexerBash):
17 """
18 Subclass to implement some additional lexer dependant methods.
19 """
20 def __init__(self, parent=None):
21 """
22 Constructor
23
24 @param parent parent widget of this lexer
25 """
26 QsciLexerBash.__init__(self, parent)
27 Lexer.__init__(self)
28
29 self.commentString = "#"
30
31 self.keywordSetDescriptions = [
32 self.tr("Keywords"),
33 ]
34
35 def initProperties(self):
36 """
37 Public slot to initialize the properties.
38 """
39 self.setFoldComments(Preferences.getEditor("BashFoldComment"))
40 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
41
42 def isCommentStyle(self, style):
43 """
44 Public method to check, if a style is a comment style.
45
46 @param style style to check (integer)
47 @return flag indicating a comment style (boolean)
48 """
49 return style in [QsciLexerBash.Comment]
50
51 def isStringStyle(self, style):
52 """
53 Public method to check, if a style is a string style.
54
55 @param style style to check (integer)
56 @return flag indicating a string style (boolean)
57 """
58 return style in [QsciLexerBash.DoubleQuotedString,
59 QsciLexerBash.SingleQuotedString,
60 QsciLexerBash.SingleQuotedHereDocument]
61
62 def defaultKeywords(self, kwSet):
63 """
64 Public method to get the default keywords.
65
66 @param kwSet number of the keyword set (integer)
67 @return string giving the keywords (string) or None
68 """
69 return QsciLexerBash.keywords(self, kwSet)

eric ide

mercurial