-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXmlSyntaxHighlighter.h
40 lines (31 loc) · 1.09 KB
/
XmlSyntaxHighlighter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef XMLSYNTAXHIGHLIGHTER_H
#define XMLSYNTAXHIGHLIGHTER_H
#include <QSyntaxHighlighter>
#include <QTextEdit>
class XMLSyntaxHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
XMLSyntaxHighlighter(QObject * parent);
XMLSyntaxHighlighter(QTextDocument * parent);
XMLSyntaxHighlighter(QTextEdit * parent);
protected:
virtual void highlightBlock(const QString & text);
private:
void highlightByRegex(const QTextCharFormat & format,
const QRegExp & regex, const QString & text);
void setRegexes();
void setFormats();
private:
QTextCharFormat m_xmlKeywordFormat;
QTextCharFormat m_xmlElementFormat;
QTextCharFormat m_xmlAttributeFormat;
QTextCharFormat m_xmlValueFormat;
QTextCharFormat m_xmlCommentFormat;
QList<QRegExp> m_xmlKeywordRegexes;
QRegExp m_xmlElementRegex;
QRegExp m_xmlAttributeRegex;
QRegExp m_xmlValueRegex;
QRegExp m_xmlCommentRegex;
};
#endif // XMLSYNTAXHIGHLIGHTER_H