扩展之前的IDE框架,包含语法高亮、代码补全、项目管理等所有建议功能。
1. 语法高亮实现
// SyntaxHighlighter.h
#pragma once
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QRegularExpression>
class SyntaxHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
SyntaxHighlighter(QTextDocument *parent = nullptr);
protected:
void highlightBlock(const QString &text) override;
private:
struct HighlightingRule
{
QRegularExpression pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegularExpression commentStartExpression;
QRegularExpression commentEndExpression;
QTextCharFormat keywordFormat;
QTextCharFormat classFormat;
QTextCharFormat si

订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



