rpcsx/rpcs3/rpcs3qt/syntax_highlighter.h
scribam 626836f95b qt: rewrite syntax highlighter
- fix multi-line comments
- remove compilation warnings "unknown escape sequence"
- fewer lines of code
2018-06-12 02:49:58 +04:00

46 lines
886 B
C++

#pragma once
#include <QSyntaxHighlighter>
#include <QRegularExpression>
// Inspired by https://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.html
class Highlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
Highlighter(QTextDocument *parent = 0);
protected:
void highlightBlock(const QString &text) override;
void addRule(const QString &pattern, const QBrush &brush);
struct HighlightingRule
{
QRegularExpression pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegularExpression commentStartExpression;
QRegularExpression commentEndExpression;
QTextCharFormat multiLineCommentFormat;
};
class AsmHighlighter : public Highlighter
{
Q_OBJECT
public:
AsmHighlighter(QTextDocument *parent = 0);
};
class GlslHighlighter : public Highlighter
{
Q_OBJECT
public:
GlslHighlighter(QTextDocument *parent = 0);
};