eric6/QScintilla/Lexers/LexerXML.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) 2008 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a XML lexer with some additional methods.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.Qsci import QsciLexerXML
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerXML(Lexer, QsciLexerXML):
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 QsciLexerXML.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.streamCommentString = {
32 'start': '<!-- ',
33 'end': ' -->'
34 }
35
36 self.keywordSetDescriptions = [
37 self.tr(""),
38 self.tr(""),
39 self.tr(""),
40 self.tr(""),
41 self.tr(""),
42 self.tr("SGML and DTD keywords"),
43 ]
44
45 def initProperties(self):
46 """
47 Public slot to initialize the properties.
48 """
49 self.setFoldPreprocessor(Preferences.getEditor("HtmlFoldPreprocessor"))
50 self.setCaseSensitiveTags(
51 Preferences.getEditor("HtmlCaseSensitiveTags"))
52 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
53 try:
54 self.setFoldScriptComments(
55 Preferences.getEditor("HtmlFoldScriptComments"))
56 self.setFoldScriptHeredocs(
57 Preferences.getEditor("HtmlFoldScriptHeredocs"))
58 self.setScriptsStyled(Preferences.getEditor("XMLStyleScripts"))
59 except AttributeError:
60 pass
61
62 def isCommentStyle(self, style):
63 """
64 Public method to check, if a style is a comment style.
65
66 @param style style to check (integer)
67 @return flag indicating a comment style (boolean)
68 """
69 return style in [QsciLexerXML.HTMLComment,
70 QsciLexerXML.ASPXCComment,
71 QsciLexerXML.SGMLComment,
72 QsciLexerXML.SGMLParameterComment,
73 QsciLexerXML.JavaScriptComment,
74 QsciLexerXML.JavaScriptCommentDoc,
75 QsciLexerXML.JavaScriptCommentLine,
76 QsciLexerXML.ASPJavaScriptComment,
77 QsciLexerXML.ASPJavaScriptCommentDoc,
78 QsciLexerXML.ASPJavaScriptCommentLine,
79 QsciLexerXML.VBScriptComment,
80 QsciLexerXML.ASPVBScriptComment,
81 QsciLexerXML.PythonComment,
82 QsciLexerXML.ASPPythonComment,
83 QsciLexerXML.PHPComment]
84
85 def isStringStyle(self, style):
86 """
87 Public method to check, if a style is a string style.
88
89 @param style style to check (integer)
90 @return flag indicating a string style (boolean)
91 """
92 return style in [QsciLexerXML.HTMLDoubleQuotedString,
93 QsciLexerXML.HTMLSingleQuotedString,
94 QsciLexerXML.SGMLDoubleQuotedString,
95 QsciLexerXML.SGMLSingleQuotedString,
96 QsciLexerXML.JavaScriptDoubleQuotedString,
97 QsciLexerXML.JavaScriptSingleQuotedString,
98 QsciLexerXML.JavaScriptUnclosedString,
99 QsciLexerXML.ASPJavaScriptDoubleQuotedString,
100 QsciLexerXML.ASPJavaScriptSingleQuotedString,
101 QsciLexerXML.ASPJavaScriptUnclosedString,
102 QsciLexerXML.VBScriptString,
103 QsciLexerXML.VBScriptUnclosedString,
104 QsciLexerXML.ASPVBScriptString,
105 QsciLexerXML.ASPVBScriptUnclosedString,
106 QsciLexerXML.PythonDoubleQuotedString,
107 QsciLexerXML.PythonSingleQuotedString,
108 QsciLexerXML.PythonTripleDoubleQuotedString,
109 QsciLexerXML.PythonTripleSingleQuotedString,
110 QsciLexerXML.ASPPythonDoubleQuotedString,
111 QsciLexerXML.ASPPythonSingleQuotedString,
112 QsciLexerXML.ASPPythonTripleDoubleQuotedString,
113 QsciLexerXML.ASPPythonTripleSingleQuotedString,
114 QsciLexerXML.PHPDoubleQuotedString,
115 QsciLexerXML.PHPSingleQuotedString]
116
117 def defaultKeywords(self, kwSet):
118 """
119 Public method to get the default keywords.
120
121 @param kwSet number of the keyword set (integer)
122 @return string giving the keywords (string) or None
123 """
124 return QsciLexerXML.keywords(self, kwSet)

eric ide

mercurial