Qt: some cleanup
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
#include "syntax_highlighter.h"
|
#include "syntax_highlighter.h"
|
||||||
#include "qt_utils.h"
|
#include "qt_utils.h"
|
||||||
|
|
||||||
Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent)
|
Highlighter::Highlighter(QTextDocument* parent) : QSyntaxHighlighter(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Highlighter::addRule(const QString &pattern, const QBrush &brush)
|
void Highlighter::addRule(const QString& pattern, const QBrush& brush)
|
||||||
{
|
{
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
rule.pattern = QRegularExpression(pattern);
|
rule.pattern = QRegularExpression(pattern);
|
||||||
@@ -13,14 +13,14 @@ void Highlighter::addRule(const QString &pattern, const QBrush &brush)
|
|||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Highlighter::highlightBlock(const QString &text)
|
void Highlighter::highlightBlock(const QString& text)
|
||||||
{
|
{
|
||||||
for (const HighlightingRule& rule : highlightingRules)
|
for (const HighlightingRule& rule : highlightingRules)
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
|
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
|
||||||
while (matchIterator.hasNext())
|
while (matchIterator.hasNext())
|
||||||
{
|
{
|
||||||
QRegularExpressionMatch match = matchIterator.next();
|
const QRegularExpressionMatch match = matchIterator.next();
|
||||||
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ LogHighlighter::LogHighlighter(QTextDocument* parent) : Highlighter(parent)
|
|||||||
addRule("^·T.*$", gui::utils::get_label_color("log_level_trace", color, color));
|
addRule("^·T.*$", gui::utils::get_label_color("log_level_trace", color, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
AsmHighlighter::AsmHighlighter(QTextDocument *parent) : Highlighter(parent)
|
AsmHighlighter::AsmHighlighter(QTextDocument* parent) : Highlighter(parent)
|
||||||
{
|
{
|
||||||
addRule("^\\b[A-Z0-9]+\\b", Qt::darkBlue); // Instructions
|
addRule("^\\b[A-Z0-9]+\\b", Qt::darkBlue); // Instructions
|
||||||
addRule("-?R\\d[^,;\\s]*", Qt::darkRed); // -R0.*
|
addRule("-?R\\d[^,;\\s]*", Qt::darkRed); // -R0.*
|
||||||
@@ -78,7 +78,7 @@ AsmHighlighter::AsmHighlighter(QTextDocument *parent) : Highlighter(parent)
|
|||||||
addRule("#[^\\n]*", Qt::darkGreen); // Single line comment
|
addRule("#[^\\n]*", Qt::darkGreen); // Single line comment
|
||||||
}
|
}
|
||||||
|
|
||||||
GlslHighlighter::GlslHighlighter(QTextDocument *parent) : Highlighter(parent)
|
GlslHighlighter::GlslHighlighter(QTextDocument* parent) : Highlighter(parent)
|
||||||
{
|
{
|
||||||
const QStringList keywordPatterns = QStringList()
|
const QStringList keywordPatterns = QStringList()
|
||||||
// Selection-Iteration-Jump Statements:
|
// Selection-Iteration-Jump Statements:
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ class Highlighter : public QSyntaxHighlighter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Highlighter(QTextDocument *parent = nullptr);
|
explicit Highlighter(QTextDocument* parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void highlightBlock(const QString &text) override;
|
void highlightBlock(const QString& text) override;
|
||||||
void addRule(const QString &pattern, const QBrush &brush);
|
void addRule(const QString& pattern, const QBrush& brush);
|
||||||
|
|
||||||
struct HighlightingRule
|
struct HighlightingRule
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,7 @@ class AsmHighlighter : public Highlighter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AsmHighlighter(QTextDocument *parent = nullptr);
|
explicit AsmHighlighter(QTextDocument* parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlslHighlighter : public Highlighter
|
class GlslHighlighter : public Highlighter
|
||||||
@@ -50,5 +50,5 @@ class GlslHighlighter : public Highlighter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlslHighlighter(QTextDocument *parent = nullptr);
|
explicit GlslHighlighter(QTextDocument* parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user