From f03c25a67258379058e5dce6ea982b61667ef1be Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 21 Feb 2023 20:35:41 +0800 Subject: [PATCH] - fix: Enum value defines is not correctly parsed. - enhancement: Use differenct source file for each language in project templates --- NEWS.md | 5 +++-- RedPandaIDE/editor.cpp | 31 ++++++++++++++++--------------- RedPandaIDE/parser/cppparser.cpp | 1 + RedPandaIDE/projecttemplate.cpp | 19 ++++++++++++++----- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4613fa66..ab498a79 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,8 @@ -Red Panda C++ Version 2.13 +Red Panda C++ Version 2.14 - change: Remove all breakpoints of the current non-project file, when it is closed. - + - fix: Enum value defines is not correctly parsed. + - enhancement: Use differenct source file for each language in project templates Red Panda C++ Version 2.13 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 5769b9de..2cbd110b 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1275,21 +1275,22 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) // if ctrl+clicked if ((event->modifiers() == Qt::ControlModifier) && (event->button() == Qt::LeftButton)) { - - QSynedit::BufferCoord p; - if (mParser && pointToCharLine(event->pos(),p)) { - QString s = document()->getLine(p.line - 1); - if (mParser->isIncludeNextLine(s)) { - QString filename = mParser->getHeaderFileName(mFilename,s, true); - pMainWindow->openFile(filename); - return; - } if (mParser->isIncludeLine(s)) { - QString filename = mParser->getHeaderFileName(mFilename,s); - pMainWindow->openFile(filename); - return; - } else if (mParser->enabled()) { - gotoDefinition(p); - return; + if (!mCurrentWord.isEmpty()) { + QSynedit::BufferCoord p; + if (mParser && pointToCharLine(event->pos(),p)) { + QString s = document()->getLine(p.line - 1); + if (mParser->isIncludeNextLine(s)) { + QString filename = mParser->getHeaderFileName(mFilename,s, true); + pMainWindow->openFile(filename); + return; + } if (mParser->isIncludeLine(s)) { + QString filename = mParser->getHeaderFileName(mFilename,s); + pMainWindow->openFile(filename); + return; + } else if (mParser->enabled()) { + gotoDefinition(p); + return; + } } } } diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index d06804de..ebbb91bf 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -5389,6 +5389,7 @@ int CppParser::indexOfNextPeriodOrSemicolon(int index, int endIndex) switch(mTokenizer[index]->text[0].unicode()) { case ';': case ',': + case '}': return index; case '(': index = mTokenizer[index]->matchIndex+1; diff --git a/RedPandaIDE/projecttemplate.cpp b/RedPandaIDE/projecttemplate.cpp index 2db1db03..42a03adc 100644 --- a/RedPandaIDE/projecttemplate.cpp +++ b/RedPandaIDE/projecttemplate.cpp @@ -38,17 +38,26 @@ PTemplateUnit ProjectTemplate::unit(int index) return PTemplateUnit(); QString section = QString("Unit%1").arg(index); PTemplateUnit unit = std::make_shared(); - unit->Source = fromByteArray(mIni->GetValue(toByteArray(section), "Source", "")); - unit->Target = fromByteArray(mIni->GetValue(toByteArray(section), "Target", "")); - unit->CText = fromByteArray(mIni->GetValue(toByteArray(section), "C", "")); - unit->CppText = fromByteArray(mIni->GetValue(toByteArray(section), "Cpp", "")); + QString lang = pSettings->environment().language(); + if (!lang.isEmpty()) { + unit->Source = fromByteArray(mIni->GetValue(toByteArray(section), QString("Source[%1]").arg(lang).toUtf8(), "")); + unit->CText = fromByteArray(mIni->GetValue(toByteArray(section), QString("C[%1]").arg(lang).toUtf8(), "")); + unit->CppText = fromByteArray(mIni->GetValue(toByteArray(section), QString("Cpp[%1]").arg(lang).toUtf8(), "")); + } + if (unit->Source.isEmpty()) + unit->Source = fromByteArray(mIni->GetValue(toByteArray(section), "Source", "")); + if (unit->CText.isEmpty()) + unit->CText = fromByteArray(mIni->GetValue(toByteArray(section), "C", "")); + if (unit->CppText.isEmpty()) + unit->CppText = fromByteArray(mIni->GetValue(toByteArray(section), "Cpp", "")); if (unit->CppText.isEmpty()) unit->CppText = unit->CText; - unit->CName = fromByteArray(mIni->GetValue(toByteArray(section), "CName", "")); unit->CppName = fromByteArray(mIni->GetValue(toByteArray(section), "CppName", "")); if (unit->CppName.isEmpty()) unit->CppName = unit->CName; + unit->Target = fromByteArray(mIni->GetValue(toByteArray(section), "Target", "")); + return unit; }