blob: b4ffae847c4c17e4deb113f686c584c368723e55 (
plain)
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
|
#ifndef HIGHLIGHTER_H_
#define HIGHLIGHTER_H_
#include <QSyntaxHighlighter>
#include <QTextFormat>
#include <QHash>
class Highlighter : public QSyntaxHighlighter
{
public:
enum state_e {NORMAL=-1,QUOTE,COMMENT};
QHash<QString, QTextCharFormat> tokenFormats;
QTextCharFormat errorFormat, commentFormat, quoteFormat, numberFormat;
Highlighter(QTextDocument *parent);
void highlightBlock(const QString &text);
void highlightError(int error_pos);
void unhighlightLastError();
private:
QTextBlock lastErrorBlock;
int errorPos;
bool errorState;
QMap<QString,QStringList> tokentypes;
QMap<QString,QTextCharFormat> typeformats;
int lastDocumentPos();
void portable_rehighlightBlock( const QTextBlock &text );
};
#endif
|