From c1f17f4be22bae15592ae1c6790b797207af00e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=89=E5=AE=87=E6=B8=85=E9=9F=B3?= <2422523675@qq.com> Date: Thu, 17 Nov 2022 16:52:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=89=93=E5=BC=80=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=A7=86=E5=9B=BE=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WordsIDE/SensitiveCore.cpp | 12 ++++++++++++ WordsIDE/SensitiveCore.h | 2 ++ WordsIDE/chainhightlighter.cpp | 2 +- WordsIDE/mainwindow.cpp | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/WordsIDE/SensitiveCore.cpp b/WordsIDE/SensitiveCore.cpp index 423553d..cf72781 100644 --- a/WordsIDE/SensitiveCore.cpp +++ b/WordsIDE/SensitiveCore.cpp @@ -31,6 +31,18 @@ bool SensitiveCore::contains(const QFileInfo &target) const return false; } +VariedTextView *SensitiveCore::queryComponent(const QFileInfo &target) const +{ + for(auto &it : sourcecode_map.keys()) + if(it == target.absoluteFilePath()) + return sourcecode_map[it]; + for(auto &it : plaintext_map.keys()) + if(it == target.absoluteFilePath()) + return plaintext_map[it]; + + return nullptr; +} + void SensitiveCore::addPerceptionList(VariedTextView *ins, SensitiveType type) { if(type == SensitiveType::CompileAtChanged){ diff --git a/WordsIDE/SensitiveCore.h b/WordsIDE/SensitiveCore.h index 4198012..d78957b 100644 --- a/WordsIDE/SensitiveCore.h +++ b/WordsIDE/SensitiveCore.h @@ -51,6 +51,8 @@ namespace MakeTools { void saveAll() const; bool contains(const QFileInfo &target) const; + VariedTextView * queryComponent(const QFileInfo &target) const; + void addPerceptionList(VariedTextView *ins, SensitiveType type = SensitiveType::CompileAtChanged); void addProcTrigger(std::function exc); diff --git a/WordsIDE/chainhightlighter.cpp b/WordsIDE/chainhightlighter.cpp index 35eb869..b3e621e 100644 --- a/WordsIDE/chainhightlighter.cpp +++ b/WordsIDE/chainhightlighter.cpp @@ -24,7 +24,7 @@ void ChainHightlighter::highlightBlock(const QString &text) unknowns.setForeground(QBrush(Qt::gray)); QTextCharFormat generate; - generate.setForeground(QBrush(Qt::black)); + generate.setForeground(QBrush(Qt::blue)); QTextCharFormat error; error.setForeground(QBrush(Qt::red)); diff --git a/WordsIDE/mainwindow.cpp b/WordsIDE/mainwindow.cpp index ff407e8..d723f02 100644 --- a/WordsIDE/mainwindow.cpp +++ b/WordsIDE/mainwindow.cpp @@ -196,8 +196,11 @@ MainWindow::MainWindow(QWidget *parent) center_funcs->addTab(new QTextEdit(this), "编辑区域"); left_funcs->addTab(project_view, "项目管理"); connect(project_view, &ProjectView::activeDocument, [this](const QString &file_path, const QString &name){ - if(framework->contains(file_path)) + if(framework->contains(file_path)){ + auto ins = framework->queryComponent(QFileInfo(file_path)); + center_funcs->setCurrentWidget(ins->textView()); return; + } VariedTextView *tview = nullptr; if(file_path.endsWith("storychain")){