QScintilla/Lexers/LexerPascal.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2008 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a Pascal lexer with some additional methods.
8 """
9
10 from PyQt4.Qsci import QsciLexerPascal, QsciScintilla
11
12 from Lexer import Lexer
13 import Preferences
14
15 class LexerPascal(QsciLexerPascal, 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 QsciLexerPascal.__init__(self, parent)
26 Lexer.__init__(self)
27
28 self.commentString = "//"
29 self.streamCommentString = {
30 'start' : '{ ',
31 'end' : ' }'
32 }
33
34 def initProperties(self):
35 """
36 Public slot to initialize the properties.
37 """
38 self.setFoldComments(Preferences.getEditor("PascalFoldComment"))
39 self.setFoldPreprocessor(Preferences.getEditor("PascalFoldPreprocessor"))
40 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
41 try:
42 self.setSmartHighlighting(Preferences.getEditor("PascalSmartHighlighting"))
43 except AttributeError:
44 pass
45
46 def autoCompletionWordSeparators(self):
47 """
48 Public method to return the list of separators for autocompletion.
49
50 @return list of separators (list of strings)
51 """
52 return ['.']
53
54 def isCommentStyle(self, style):
55 """
56 Public method to check, if a style is a comment style.
57
58 @return flag indicating a comment style (boolean)
59 """
60 try:
61 return style in [QsciLexerPascal.Comment,
62 QsciLexerPascal.CommentDoc,
63 QsciLexerPascal.CommentLine]
64 except AttributeError:
65 return style in [QsciLexerPascal.Comment,
66 QsciLexerPascal.CommentParenthesis,
67 QsciLexerPascal.CommentLine]
68
69 def isStringStyle(self, style):
70 """
71 Public method to check, if a style is a string style.
72
73 @return flag indicating a string style (boolean)
74 """
75 return style in [QsciLexerPascal.SingleQuotedString]

eric ide

mercurial