initial upload
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef HTMLHIGHLIGHTER_H
|
||||
#define HTMLHIGHLIGHTER_H
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QTextCharFormat>
|
||||
#include <QTextEdit>
|
||||
|
||||
/* HTML syntax highlighter based on Qt Quarterly example */
|
||||
class HtmlHighlighter : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Construct {
|
||||
Entity,
|
||||
Tag,
|
||||
Comment,
|
||||
Attribute,
|
||||
Value,
|
||||
LastConstruct = Value
|
||||
};
|
||||
|
||||
HtmlHighlighter(QTextEdit *textEdit);
|
||||
|
||||
void setFormatFor(Construct construct, const QTextCharFormat &format);
|
||||
|
||||
QTextCharFormat formatFor(Construct construct) const
|
||||
{ return m_formats[construct]; }
|
||||
|
||||
protected:
|
||||
enum State {
|
||||
NormalState = -1,
|
||||
InComment,
|
||||
InTag
|
||||
};
|
||||
|
||||
void highlightBlock(const QString &text) override;
|
||||
|
||||
private:
|
||||
QTextCharFormat m_formats[LastConstruct + 1];
|
||||
};
|
||||
|
||||
#endif // HTMLHIGHLIGHTER_H
|
||||
Reference in New Issue
Block a user