Qt: some cleanup

This commit is contained in:
Megamouse
2026-01-09 18:56:27 +01:00
parent 49bcc93072
commit be77083a2b
2 changed files with 11 additions and 11 deletions
+6 -6
View File
@@ -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:
+5 -5
View File
@@ -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);
}; };