src/ldrawsyntaxhighlighter.h

Sun, 09 Apr 2023 15:59:08 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 15:59:08 +0300
changeset 362
e1d646a4cbd8
parent 331
638a7458ef5e
permissions
-rw-r--r--

Extracted the state of the program into a MainState structure, and extracted local functions of main() into static functions.
I was planning to make the core logic and state of the program into a Main class, which would be a QObject that would
have lots of signals and slots, but it looks like this works even without it

#pragma once
#include <QSyntaxHighlighter>
#include <QRegularExpression>

class LDrawSyntaxHighlighter final : public QSyntaxHighlighter
{
	Q_OBJECT
	QRegularExpression commentPattern;
	QRegularExpression bfcPattern;
	QRegularExpression refPattern;
	QRegularExpression trianglePattern;
	QRegularExpression quadrilateralPattern;
	QRegularExpression cedgePattern;
	QTextCharFormat lineTypeFormat;
	QTextCharFormat colorFormat;
	QTextCharFormat point1Format;
	QTextCharFormat point2Format;
	QTextCharFormat point3Format;
	QTextCharFormat point4Format;
	QTextCharFormat bfcFormat;
	QTextCharFormat nameFormat;
	QTextCharFormat errorFormat;
public:
	LDrawSyntaxHighlighter(QTextDocument* parent = nullptr);
	
	// QSyntaxHighlighter interface
protected:
	void highlightBlock(const QString& text) override;
};

mercurial