| 1 |
#ifndef BASIC_XML_SYNTAX_HIGHLIGHTER_H |
| 2 |
#define BASIC_XML_SYNTAX_HIGHLIGHTER_H |
| 3 |
|
| 4 |
#include <QSyntaxHighlighter> |
| 5 |
#include <QTextEdit> |
| 6 |
|
| 7 |
class BasicXMLSyntaxHighlighter : public QSyntaxHighlighter |
| 8 |
{ |
| 9 |
Q_OBJECT |
| 10 |
public: |
| 11 |
BasicXMLSyntaxHighlighter(QObject * parent); |
| 12 |
BasicXMLSyntaxHighlighter(QTextDocument * parent); |
| 13 |
BasicXMLSyntaxHighlighter(QTextEdit * parent); |
| 14 |
|
| 15 |
protected: |
| 16 |
virtual void highlightBlock(const QString & text); |
| 17 |
|
| 18 |
private: |
| 19 |
void highlightByRegex(const QTextCharFormat & format, |
| 20 |
const QRegExp & regex, const QString & text); |
| 21 |
|
| 22 |
void setRegexes(); |
| 23 |
void setFormats(); |
| 24 |
|
| 25 |
private: |
| 26 |
QTextCharFormat m_xmlKeywordFormat; |
| 27 |
QTextCharFormat m_xmlElementFormat; |
| 28 |
QTextCharFormat m_xmlAttributeFormat; |
| 29 |
QTextCharFormat m_xmlValueFormat; |
| 30 |
QTextCharFormat m_xmlCommentFormat; |
| 31 |
|
| 32 |
QList<QRegExp> m_xmlKeywordRegexes; |
| 33 |
QRegExp m_xmlElementRegex; |
| 34 |
QRegExp m_xmlAttributeRegex; |
| 35 |
QRegExp m_xmlValueRegex; |
| 36 |
QRegExp m_xmlCommentRegex; |
| 37 |
}; |
| 38 |
|
| 39 |
#endif // BASIC_XML_SYNTAX_HIGHLIGHTER_H |