diff --git a/NEWS.md b/NEWS.md index b6bfee2a..1490f8bf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -28,7 +28,7 @@ Red Panda C++ Version 1.5 - fix: editor tooltip for #include_next is not correctly calculated - fix: ctrl+click on #include_next header name doesn't open the right file - enhancement: parser used for non-project C files won't find header files in C++ include folders. - - fix: when physical memory is less than 16G or "Auto clearn + - fix: toggle block comment/delete to word begin/delete to word end are not correctly disabled when editor not open Red Panda C++ Version 1.4 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 99096b21..d3fe55ea 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1209,10 +1209,10 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) QString s = document()->getString(p.line - 1); if (mParser->isIncludeNextLine(s)) { QString filename = mParser->getHeaderFileName(mFilename,s, true); - pMainWindow->openFile(filename,true); + pMainWindow->openFile(filename); } if (mParser->isIncludeLine(s)) { QString filename = mParser->getHeaderFileName(mFilename,s); - pMainWindow->openFile(filename,true); + pMainWindow->openFile(filename); } else { gotoDefinition(p); return; @@ -3983,7 +3983,10 @@ void Editor::gotoDeclaration(const QSynedit::BufferCoord &pos) filename = statement->fileName; line = statement->line; } - pMainWindow->openFile(filename); + Editor *e = pMainWindow->openFile(filename); + if (e) { + e->setCaretPositionAndActivate(line,1); + } } void Editor::gotoDefinition(const QSynedit::BufferCoord &pos) @@ -4009,7 +4012,10 @@ void Editor::gotoDefinition(const QSynedit::BufferCoord &pos) filename = statement->definitionFileName; line = statement->definitionLine; } - pMainWindow->openFile(filename); + Editor *e = pMainWindow->openFile(filename); + if (e) { + e->setCaretPositionAndActivate(line,1); + } } QString getWordAtPosition(QSynedit::SynEdit *editor, const QSynedit::BufferCoord &p, QSynedit::BufferCoord &pWordBegin, QSynedit::BufferCoord &pWordEnd, Editor::WordPurpose purpose) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 00ccae7a..72c82887 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -490,6 +490,7 @@ void MainWindow::updateEditorActions() ui->actionPrint->setEnabled(false); ui->actionSelectAll->setEnabled(false); ui->actionToggleComment->setEnabled(false); + ui->actionToggle_Block_Comment->setEnabled(false); ui->actionUnIndent->setEnabled(false); ui->actionUndo->setEnabled(false); ui->actionUnfoldAll->setEnabled(false); @@ -498,6 +499,9 @@ void MainWindow::updateEditorActions() ui->actionDuplicate_Line->setEnabled(false); ui->actionDelete_to_BOL->setEnabled(false); ui->actionDelete_to_EOL->setEnabled(false); + ui->actionDelete_to_Word_End->setEnabled(false); + ui->actionDelete_Last_Word->setEnabled(false); + ui->actionFind->setEnabled(false); ui->actionReplace->setEnabled(false); @@ -542,6 +546,7 @@ void MainWindow::updateEditorActions() ui->actionPrint->setEnabled(true); ui->actionSelectAll->setEnabled(e->document()->count()>0); ui->actionToggleComment->setEnabled(!e->readOnly() && e->document()->count()>0); + ui->actionToggle_Block_Comment->setEnabled(!e->readOnly() && e->selAvail()); ui->actionUnIndent->setEnabled(!e->readOnly() && e->document()->count()>0); ui->actionUnfoldAll->setEnabled(e->document()->count()>0); ui->actionDelete_Line->setEnabled(!e->readOnly() && e->document()->count()>0); @@ -549,6 +554,9 @@ void MainWindow::updateEditorActions() ui->actionDuplicate_Line->setEnabled(!e->readOnly() && e->document()->count()>0); ui->actionDelete_to_BOL->setEnabled(!e->readOnly() && e->document()->count()>0); ui->actionDelete_to_EOL->setEnabled(!e->readOnly() && e->document()->count()>0); + ui->actionDelete_to_Word_End->setEnabled(!e->readOnly() && e->document()->count()>0); + ui->actionDelete_Last_Word->setEnabled(!e->readOnly() && e->document()->count()>0); + ui->actionFind->setEnabled(true); ui->actionReplace->setEnabled(true); diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 76c0211a..b7950ef6 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -974,10 +974,9 @@ void CppParser::resetParser() mBlockEndSkips.clear(); //list of for/catch block end token index; mInlineNamespaceEndSkips.clear(); // list for inline namespace end token index; mFilesToScan.clear(); // list of base files to scan - mNamespaces.clear(); //TStringList> namespace and the statements in its scope + mNamespaces.clear(); // namespace and the statements in its scope mInlineNamespaces.clear(); - // We haven't scanned anything anymore mPreprocessor = std::make_shared(); mTokenizer.reset(); diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 16e776d1..16b45deb 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -536,7 +536,6 @@ private: CppTokenizer mTokenizer; PCppPreprocessor mPreprocessor; - //{ List of current project's file } QSet mProjectFiles; QVector mBlockBeginSkips; //list of for/catch block begin token index; QVector mBlockEndSkips; //list of for/catch block end token index; @@ -547,12 +546,10 @@ private: bool mParseLocalHeaders; bool mParseGlobalHeaders; bool mIsProjectFile; - //fMacroDefines : TList; int mLockCount; // lock(don't reparse) when we need to find statements in a batch bool mParsing; - QHash mNamespaces; //TStringList> namespace and the statements in its scope + QHash mNamespaces; // namespace and the statements in its scope QSet mInlineNamespaces; - //fRemovedStatements: THashedStringList; //THashedStringList QMutex mMutex; GetFileStreamCallBack mOnGetFileStream; diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 3dcb677d..d08ada4f 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -371,12 +371,6 @@ QString CppPreprocessor::getNextPreprocessor() return result; } -void CppPreprocessor::simplify(QString &output) -{ - // Remove # - output = output.mid(1).trimmed(); -} - void CppPreprocessor::handleBranch(const QString &line) { if (line.startsWith("ifdef")) { @@ -1143,7 +1137,7 @@ void CppPreprocessor::preprocessBuffer() do { s = getNextPreprocessor(); if (s.startsWith('#')) { - simplify(s); + s = s.mid(1).trimmed(); // remove # if (!s.isEmpty()) { handlePreprocessor(s); }