|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2004 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a Perl lexer with some additional methods. |
|
8 """ |
|
9 |
|
10 from PyQt4.Qsci import QsciLexerPerl |
|
11 |
|
12 from Lexer import Lexer |
|
13 import Preferences |
|
14 |
|
15 class LexerPerl(QsciLexerPerl, Lexer): |
|
16 """ |
|
17 Subclass to implement some additional lexer dependant methods. |
|
18 """ |
|
19 def __init__(self, parent=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param parent parent widget of this lexer |
|
24 """ |
|
25 QsciLexerPerl.__init__(self, parent) |
|
26 Lexer.__init__(self) |
|
27 |
|
28 self.commentString = "#" |
|
29 |
|
30 def initProperties(self): |
|
31 """ |
|
32 Public slot to initialize the properties. |
|
33 """ |
|
34 self.setFoldComments(Preferences.getEditor("PerlFoldComment")) |
|
35 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
|
36 try: |
|
37 self.setFoldPackages(Preferences.getEditor("PerlFoldPackages")) |
|
38 self.setFoldPODBlocks(Preferences.getEditor("PerlFoldPODBlocks")) |
|
39 except AttributeError: |
|
40 pass |
|
41 |
|
42 def autoCompletionWordSeparators(self): |
|
43 """ |
|
44 Public method to return the list of separators for autocompletion. |
|
45 |
|
46 @return list of separators (list of strings) |
|
47 """ |
|
48 return ['::', '->'] |
|
49 |
|
50 def isCommentStyle(self, style): |
|
51 """ |
|
52 Public method to check, if a style is a comment style. |
|
53 |
|
54 @return flag indicating a comment style (boolean) |
|
55 """ |
|
56 return style in [QsciLexerPerl.Comment] |
|
57 |
|
58 def isStringStyle(self, style): |
|
59 """ |
|
60 Public method to check, if a style is a string style. |
|
61 |
|
62 @return flag indicating a string style (boolean) |
|
63 """ |
|
64 return style in [QsciLexerPerl.DoubleQuotedHereDocument, |
|
65 QsciLexerPerl.DoubleQuotedString, |
|
66 QsciLexerPerl.QuotedStringQ, |
|
67 QsciLexerPerl.QuotedStringQQ, |
|
68 QsciLexerPerl.QuotedStringQR, |
|
69 QsciLexerPerl.QuotedStringQW, |
|
70 QsciLexerPerl.QuotedStringQX, |
|
71 QsciLexerPerl.SingleQuotedHereDocument, |
|
72 QsciLexerPerl.SingleQuotedString] |