diff --git a/NEWS.md b/NEWS.md index 72b933d5..3bc631a8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,6 +25,7 @@ Red Panda C++ Version 0.13.3 - fix: search around option can't be disabled - enhancement: show a confirm dialog when search/replace around - enhancement: auto zoom ui when screen's zoom factor changed (windows) + - enhancement: parser not called when open a file, if option "clean parser symbols when hidden" is turned on. Red Panda C++ Version 0.13.2 - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly diff --git a/RedPandaIDE/HighlighterManager.cpp b/RedPandaIDE/HighlighterManager.cpp index 3a27b035..3d2489a4 100644 --- a/RedPandaIDE/HighlighterManager.cpp +++ b/RedPandaIDE/HighlighterManager.cpp @@ -43,7 +43,7 @@ PSynHighlighter HighlighterManager::getHighlighter(const QString &filename) || suffix == "CPP" || suffix =="H" || suffix == "c++" || suffix == "h++") { return getCppHighlighter(); - } else if (suffix == "vs" || suffix == "fs") { + } else if (suffix == "vs" || suffix == "fs" || suffix == "frag") { return getGLSLHighlighter(); } } diff --git a/RedPandaIDE/autolinkmanager.cpp b/RedPandaIDE/autolinkmanager.cpp index c7d8c421..cff90af0 100644 --- a/RedPandaIDE/autolinkmanager.cpp +++ b/RedPandaIDE/autolinkmanager.cpp @@ -32,7 +32,15 @@ AutolinkManager::AutolinkManager() PAutolink AutolinkManager::getLink(const QString &header) const { - return mLinks.value(header,PAutolink()); + PAutolink link = mLinks.value(header,PAutolink()); + if (link) + return link; + foreach (QString key, mLinks.keys()) { + if (header.endsWith("/"+key, PATH_SENSITIVITY)) { + return mLinks.value(key); + } + } + return PAutolink(); } void AutolinkManager::load() diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index 055e5857..be4fbaec 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -534,11 +534,10 @@ QString Compiler::parseFileIncludesForAutolink( PCppParser& parser) { QString result; - QString baseName = extractFileName(filename); if (parsedFiles.contains(filename)) return result; parsedFiles.insert(filename); - PAutolink autolink = pAutolinkManager->getLink(baseName); + PAutolink autolink = pAutolinkManager->getLink(filename); if (autolink) { result += ' '+autolink->linkOption; } diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 913e4a55..5063c7fe 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -94,16 +94,16 @@ Editor::Editor(QWidget *parent, const QString& filename, mCurrentHighlightedWord(), mSaving(false) { + qDebug()<<"inited1 "; mCurrentLineModified = false; mUseCppSyntax = pSettings->editor().defaultFileCpp(); if (mFilename.isEmpty()) { mFilename = tr("untitled")+QString("%1").arg(getNewFileNumber()); } + qDebug()<<"inited2 "; QFileInfo fileInfo(mFilename); - if (mParentPageControl!=nullptr) { - mParentPageControl->addTab(this,""); - updateCaption(); - } + + qDebug()<<"inited3 "; PSynHighlighter highlighter; if (!isNew) { @@ -117,6 +117,8 @@ Editor::Editor(QWidget *parent, const QString& filename, highlighter=highlighterManager.getCppHighlighter(); } + qDebug()<<"----------inited"; + if (highlighter) { setHighlighter(highlighter); setUseCodeFolding(true); @@ -134,7 +136,6 @@ Editor::Editor(QWidget *parent, const QString& filename, && mParser && (mParser->isSystemHeaderFile(mFilename) || mParser->isProjectHeaderFile(mFilename))) { this->setModified(false); setReadOnly(true); - updateCaption(); } mCompletionPopup = pMainWindow->completionPopup(); @@ -180,6 +181,10 @@ Editor::Editor(QWidget *parent, const QString& filename, resetBreakpoints(); } mStatementColors = pMainWindow->statementColors(); + if (mParentPageControl!=nullptr) { + mParentPageControl->addTab(this,""); + updateCaption(); + } } Editor::~Editor() { @@ -524,12 +529,6 @@ void Editor::wheelEvent(QWheelEvent *event) { void Editor::focusInEvent(QFocusEvent *event) { SynEdit::focusInEvent(event); - if (mParser) { - connect(mParser.get(), - &CppParser::onEndParsing, - this, - &SynEdit::invalidate); - } pMainWindow->updateAppTitle(); pMainWindow->updateEditorActions(); pMainWindow->updateStatusbarForLineCol(); @@ -540,12 +539,6 @@ void Editor::focusInEvent(QFocusEvent *event) void Editor::focusOutEvent(QFocusEvent *event) { SynEdit::focusOutEvent(event); - if (mParser) { - disconnect(mParser.get(), - &CppParser::onEndParsing, - this, - &SynEdit::invalidate); - } //pMainWindow->updateClassBrowserForEditor(nullptr); pMainWindow->updateStatusbarForLineCol(); pMainWindow->updateForStatusbarModeInfo(); @@ -1195,6 +1188,41 @@ void Editor::closeEvent(QCloseEvent *) pMainWindow->functionTip()->hide(); } +void Editor::showEvent(QShowEvent */*event*/) +{ + qDebug()<<"show event"; + if (pSettings->codeCompletion().clearWhenEditorHidden() + && !inProject()) { + initParser(); + } + if (mParser) { + connect(mParser.get(), + &CppParser::onEndParsing, + this, + &SynEdit::invalidate); + } + if (pSettings->codeCompletion().clearWhenEditorHidden() + && !inProject()) { + reparse(); + } + reparseTodo(); + setHideTime(QDateTime()); +} + +void Editor::hideEvent(QHideEvent */*event*/) +{ + if (mParser) { + disconnect(mParser.get(), + &CppParser::onEndParsing, + this, + &SynEdit::invalidate); + } + if (pSettings->codeCompletion().clearWhenEditorHidden() + && !inProject() && mParser) + mParser->reset(); + setHideTime(QDateTime::currentDateTime()); +} + void Editor::copyToClipboard() { if (pSettings->editor().copySizeLimit()) { @@ -2407,6 +2435,7 @@ void Editor::reparse() if (highlighter()->language() != SynHighlighterLanguage::Cpp && highlighter()->language() != SynHighlighterLanguage::GLSL) return; + qDebug()<<"reparse"<mEditorList->endUpdate(); mOpenningFiles = false; - updateEditorParser(ui->EditorTabsLeft); - updateEditorParser(ui->EditorTabsRight); }); //Check if there is a project file in the list and open it for (const QString& file:files) { @@ -5222,39 +5220,6 @@ PSymbolUsageManager &MainWindow::symbolUsageManager() return mSymbolUsageManager; } -void MainWindow::updateEditorParser(QTabWidget* tabWidget) { - if (mOpenningFiles) - return; - Editor * editor = mEditorList->getEditor(-1,tabWidget); - if (pSettings->codeCompletion().clearWhenEditorHidden()) { - for (int i=0;icount();i++) { - Editor * e = (Editor*)(tabWidget->widget(i)); - if (!e->inProject()) { - if (e!=editor && e->parser() && !e->notParsed()) { - e->parser()->reset(); - } - } - } - } - if (editor && editor->parser() && editor->notParsed()) { - resetCppParser(editor->parser()); - editor->reparse(); - } -} - -void MainWindow::updateEditorHideTime(QTabWidget* tabWidget) { - Editor * editor = mEditorList->getEditor(-1,tabWidget); - for (int i=0;icount();i++) { - Editor * e = (Editor*)(tabWidget->widget(i)); - if (e!=editor) { - if (!e->hideTime().isValid()) - e->setHideTime(QDateTime::currentDateTime()); - } else { - e->setHideTime(QDateTime()); - } - } -} - void MainWindow::showHideInfosTab(QWidget *widget, bool show) { int idx = findTabIndex(ui->tabInfos,widget); @@ -5393,26 +5358,13 @@ void MainWindow::onEditorRenamed(const QString &oldFilename, const QString &newF void MainWindow::on_EditorTabsLeft_currentChanged(int) { - Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft); - if (editor) { - editor->reparseTodo(); - } - updateEditorParser(ui->EditorTabsLeft); - updateEditorHideTime(ui->EditorTabsLeft); } void MainWindow::on_EditorTabsRight_currentChanged(int) { - Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsRight); - if (editor) { - editor->reparseTodo(); - } - updateEditorParser(ui->EditorTabsRight); - updateEditorHideTime(ui->EditorTabsRight); } - void MainWindow::on_tableTODO_doubleClicked(const QModelIndex &index) { PTodoItem item = mTodoModel.getItem(index); @@ -5422,7 +5374,6 @@ void MainWindow::on_tableTODO_doubleClicked(const QModelIndex &index) editor->setCaretPositionAndActivate(item->lineNo,item->ch+1); } } - } diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 433567d8..ebb689ca 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -243,8 +243,6 @@ private: void doCompileRun(RunType runType); void updateProblemCaseOutput(POJProblemCase problemCase); void applyCurrentProblemCaseChanges(); - void updateEditorParser(QTabWidget* tabWidget); - void updateEditorHideTime(QTabWidget* tabWidget); void showHideInfosTab(QWidget *widget, bool show); void showHideMessagesTab(QWidget *widget, bool show); void prepareTabInfosData(); diff --git a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp index eb05e37e..9e35d2a6 100644 --- a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp @@ -50,6 +50,7 @@ void EditorCodeCompletionWidget::doLoad() ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase()); ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc()); ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns()); + ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden()); ui->spinMinCharRequired->setValue(pSettings->codeCompletion().minCharRequired()); } @@ -74,6 +75,7 @@ void EditorCodeCompletionWidget::doSave() pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked()); pSettings->codeCompletion().setMinCharRequired(ui->spinMinCharRequired->value()); + pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked()); pSettings->codeCompletion().save(); }