pgLab/sqlhighlighter.h
Eelke Klein 37e8882a3c New syntax highlighter not complete.
- Supports comments
- more efficient as it scans the text block instead of repeatedly searching throught the whole block
- type matching based on catalog (but need to add aliases manually)
- added many keywords

todo:
- heap corruption bug
- symbol stops at special char like parenthese or operator or something similar.
2017-02-07 21:39:45 +01:00

42 lines
889 B
C++

#pragma once
#include <QSyntaxHighlighter>
#include <QRegularExpression>
#include <vector>
class SqlHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
SqlHighlighter(QTextDocument *parent = 0);
protected:
void highlightBlock(const QString &text) override;
private:
struct HighlightingRule
{
QRegExp pattern;
QTextCharFormat format;
HighlightingRule(const QRegExp &regex, const QTextCharFormat &f)
: pattern(regex), format(f)
{}
};
//QVector<HighlightingRule> highlightingRules;
std::vector<HighlightingRule> highlightingRules;
// QRegExp commentStartExpression;
// QRegExp commentEndExpression;
QTextCharFormat keywordFormat;
// QTextCharFormat classFormat;
// QTextCharFormat singleLineCommentFormat;
// QTextCharFormat multiLineCommentFormat;
// QTextCharFormat quotationFormat;
// QTextCharFormat functionFormat;
};