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")){