QScintilla/Lexers/LexerXML.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 XML lexer with some additional methods.
8 """
9
10 from PyQt4.Qsci import QsciLexerXML
11
12 from Lexer import Lexer
13 import Preferences
14
15 class LexerXML(QsciLexerXML, 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 QsciLexerXML.__init__(self, parent)
26 Lexer.__init__(self)
27
28 self.streamCommentString = {
29 'start' : '<!-- ',
30 'end' : ' -->'
31 }
32
33 def initProperties(self):
34 """
35 Public slot to initialize the properties.
36 """
37 self.setFoldPreprocessor(Preferences.getEditor("HtmlFoldPreprocessor"))
38 self.setCaseSensitiveTags(\
39 Preferences.getEditor("HtmlCaseSensitiveTags"))
40 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
41 try:
42 self.setFoldScriptComments(Preferences.getEditor("HtmlFoldScriptComments"))
43 self.setFoldScriptHeredocs(Preferences.getEditor("HtmlFoldScriptHeredocs"))
44 self.setScriptsStyled(Preferences.getEditor("XMLStyleScripts"))
45 except AttributeError:
46 pass
47
48 def isCommentStyle(self, style):
49 """
50 Public method to check, if a style is a comment style.
51
52 @return flag indicating a comment style (boolean)
53 """
54 return style in [QsciLexerXML.HTMLComment,
55 QsciLexerXML.ASPXCComment,
56 QsciLexerXML.SGMLComment,
57 QsciLexerXML.SGMLParameterComment,
58 QsciLexerXML.JavaScriptComment,
59 QsciLexerXML.JavaScriptCommentDoc,
60 QsciLexerXML.JavaScriptCommentLine,
61 QsciLexerXML.ASPJavaScriptComment,
62 QsciLexerXML.ASPJavaScriptCommentDoc,
63 QsciLexerXML.ASPJavaScriptCommentLine,
64 QsciLexerXML.VBScriptComment,
65 QsciLexerXML.ASPVBScriptComment,
66 QsciLexerXML.PythonComment,
67 QsciLexerXML.ASPPythonComment,
68 QsciLexerXML.PHPComment]
69
70 def isStringStyle(self, style):
71 """
72 Public method to check, if a style is a string style.
73
74 @return flag indicating a string style (boolean)
75 """
76 return style in [QsciLexerXML.HTMLDoubleQuotedString,
77 QsciLexerXML.HTMLSingleQuotedString,
78 QsciLexerXML.SGMLDoubleQuotedString,
79 QsciLexerXML.SGMLSingleQuotedString,
80 QsciLexerXML.JavaScriptDoubleQuotedString,
81 QsciLexerXML.JavaScriptSingleQuotedString,
82 QsciLexerXML.JavaScriptUnclosedString,
83 QsciLexerXML.ASPJavaScriptDoubleQuotedString,
84 QsciLexerXML.ASPJavaScriptSingleQuotedString,
85 QsciLexerXML.ASPJavaScriptUnclosedString,
86 QsciLexerXML.VBScriptString,
87 QsciLexerXML.VBScriptUnclosedString,
88 QsciLexerXML.ASPVBScriptString,
89 QsciLexerXML.ASPVBScriptUnclosedString,
90 QsciLexerXML.PythonDoubleQuotedString,
91 QsciLexerXML.PythonSingleQuotedString,
92 QsciLexerXML.PythonTripleDoubleQuotedString,
93 QsciLexerXML.PythonTripleSingleQuotedString,
94 QsciLexerXML.ASPPythonDoubleQuotedString,
95 QsciLexerXML.ASPPythonSingleQuotedString,
96 QsciLexerXML.ASPPythonTripleDoubleQuotedString,
97 QsciLexerXML.ASPPythonTripleSingleQuotedString,
98 QsciLexerXML.PHPDoubleQuotedString,
99 QsciLexerXML.PHPSingleQuotedString]

eric ide

mercurial