eric6/QScintilla/Lexers/LexerPerl.py

changeset 6942
2602857055c5
parent 6874
5a3a39442711
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2004 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a Perl lexer with some additional methods.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.Qsci import QsciLexerPerl
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerPerl(Lexer, QsciLexerPerl):
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 QsciLexerPerl.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.commentString = "#"
32
33 self.keywordSetDescriptions = [
34 self.tr("Keywords"),
35 ]
36
37 def initProperties(self):
38 """
39 Public slot to initialize the properties.
40 """
41 self.setFoldComments(Preferences.getEditor("PerlFoldComment"))
42 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
43 try:
44 self.setFoldPackages(Preferences.getEditor("PerlFoldPackages"))
45 self.setFoldPODBlocks(Preferences.getEditor("PerlFoldPODBlocks"))
46 except AttributeError:
47 pass
48 try:
49 self.setFoldAtElse(Preferences.getEditor("PerlFoldAtElse"))
50 except AttributeError:
51 pass
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 return style in [QsciLexerPerl.Comment]
69
70 def isStringStyle(self, style):
71 """
72 Public method to check, if a style is a string style.
73
74 @param style style to check (integer)
75 @return flag indicating a string style (boolean)
76 """
77 return style in [QsciLexerPerl.DoubleQuotedHereDocument,
78 QsciLexerPerl.DoubleQuotedString,
79 QsciLexerPerl.QuotedStringQ,
80 QsciLexerPerl.QuotedStringQQ,
81 QsciLexerPerl.QuotedStringQR,
82 QsciLexerPerl.QuotedStringQW,
83 QsciLexerPerl.QuotedStringQX,
84 QsciLexerPerl.SingleQuotedHereDocument,
85 QsciLexerPerl.SingleQuotedString]
86
87 def defaultKeywords(self, kwSet):
88 """
89 Public method to get the default keywords.
90
91 @param kwSet number of the keyword set (integer)
92 @return string giving the keywords (string) or None
93 """
94 return QsciLexerPerl.keywords(self, kwSet)

eric ide

mercurial