diff --git a/NEWS.md b/NEWS.md index 05615432..357f7de4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,10 @@ Red Panda C++ Version 2.17 - fix: After project's default encoding is changed in the project options dialog, all project files' encoding are wrongly setted to the new encoding.(They should be "Project default") - enhancement: Make project's default encoding setting in the project options dialog more user friendly. - fix: In project options dialog's file page, Project's default encoding name is not updated when it's changed. + - enhancement: Improve the compatibility with Dev-C++ for project configuations saved by Redpanda-C++. + - enhancement: Syntax color support for binaray integer literals. + - enhancement: Syntax color support for suffix in integer/float literals. + Red Panda C++ Version 2.16 diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index ea779e2e..41cdce6d 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -1048,13 +1048,13 @@ bool Project::saveAsTemplate(const QString &templateFolder, if (!mOptions.libDirs.isEmpty()) ini->SetValue("Project", "Libs", relativePaths(mOptions.libDirs).join(";").toUtf8()); if (!mOptions.compilerCmd.isEmpty()) - ini->SetValue("Project", "Compiler", textToLines(mOptions.compilerCmd).join(";CONFIG_LINE;").toUtf8()); + ini->SetValue("Project", "Compiler", textToLines(mOptions.compilerCmd).join(" ").toUtf8()); if (!mOptions.cppCompilerCmd.isEmpty()) - ini->SetValue("Project", "CppCompiler", textToLines(mOptions.cppCompilerCmd).join(";CONFIG_LINE;").toUtf8()); + ini->SetValue("Project", "CppCompiler", textToLines(mOptions.cppCompilerCmd).join(" ").toUtf8()); if (!mOptions.linkerCmd.isEmpty()) - ini->SetValue("Project", "Linker",textToLines(mOptions.linkerCmd).join(";CONFIG_LINE;").toUtf8()); + ini->SetValue("Project", "Linker",textToLines(mOptions.linkerCmd).join(" ").toUtf8()); if (!mOptions.resourceCmd.isEmpty()) - ini->SetValue("Project", "ResourceCommand",textToLines(mOptions.resourceCmd).join(";CONFIG_LINE;").toUtf8()); + ini->SetValue("Project", "ResourceCommand",textToLines(mOptions.resourceCmd).join(" ").toUtf8()); ini->SetBoolValue("Project", "IsCpp", mOptions.isCpp); if (mOptions.includeVersionInfo) ini->SetBoolValue("Project", "IncludeVersionInfo", true); @@ -1152,10 +1152,10 @@ void Project::saveOptions() ini.SetValue("Project","ResourceIncludes", toByteArray(relativePaths(mOptions.resourceIncludes).join(";"))); ini.SetValue("Project","MakeIncludes", toByteArray(relativePaths(mOptions.makeIncludes).join(";"))); ini.SetValue("Project","PrivateResource", toByteArray(mOptions.privateResource)); - ini.SetValue("Project","Compiler", toByteArray(textToLines(mOptions.compilerCmd).join(";CONFIG_LINE;"))); - ini.SetValue("Project","CppCompiler", toByteArray(textToLines(mOptions.cppCompilerCmd).join(";CONFIG_LINE;"))); - ini.SetValue("Project","Linker", toByteArray(textToLines(mOptions.linkerCmd).join(";CONFIG_LINE;"))); - ini.SetValue("Project", "ResourceCommand", toByteArray(textToLines(mOptions.resourceCmd).join(";CONFIG_LINE;"))); + ini.SetValue("Project","Compiler", toByteArray(textToLines(mOptions.compilerCmd).join(" "))); + ini.SetValue("Project","CppCompiler", toByteArray(textToLines(mOptions.cppCompilerCmd).join(" "))); + ini.SetValue("Project","Linker", toByteArray(textToLines(mOptions.linkerCmd).join(" "))); + ini.SetValue("Project", "ResourceCommand", toByteArray(textToLines(mOptions.resourceCmd).join(" "))); ini.SetLongValue("Project","IsCpp", mOptions.isCpp); ini.SetValue("Project","Icon", toByteArray(extractRelativePath(directory(), mOptions.icon))); ini.SetValue("Project","ExeOutput", toByteArray(extractRelativePath(directory(),mOptions.exeOutput))); @@ -1956,6 +1956,8 @@ void Project::loadOptions(SimpleIni& ini) } mOptions.type = static_cast(ini.GetLongValue("Project", "type", 0)); + // ;CONFIG_LINE; is used in olded version config files (<2.17) + // keep it for compatibility mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "Compiler", "")).replace(";CONFIG_LINE;","\n"); mOptions.cppCompilerCmd = fromByteArray(ini.GetValue("Project", "CppCompiler", "")).replace(";CONFIG_LINE;","\n"); mOptions.linkerCmd = fromByteArray(ini.GetValue("Project", "Linker", "")).replace(";CONFIG_LINE;","\n"); diff --git a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.cpp b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.cpp index 61a406b8..1c5cc41e 100644 --- a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.cpp +++ b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.cpp @@ -93,3 +93,4 @@ void ProjectCompileParamatersWidget::updateIcons(const QSize &/*size*/) pIconsManager->setIcon(ui->btnChooseLib, IconsManager::ACTION_MISC_FOLDER); } + diff --git a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h index c60a950e..82005cc8 100644 --- a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h +++ b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h @@ -41,7 +41,6 @@ protected: private slots: void on_btnChooseLib_clicked(); - // SettingsWidget interface protected: void updateIcons(const QSize &size) override; }; diff --git a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.ui b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.ui index ef15b4b4..5cecd205 100644 --- a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.ui +++ b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.ui @@ -52,7 +52,7 @@ - 3 + 2 diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp index 619a8a04..41882f79 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp @@ -31,7 +31,18 @@ static const QSet CppStatementKeyWords { "while", "do" }; - +const QSet CppSyntaxer::ValidIntegerSuffixes { + "u", + "ll", + "z", + "l", + "uz", + "zu", + "ull", + "llu", + "lu", + "ul" +}; const QSet CppSyntaxer::Keywords { @@ -676,6 +687,9 @@ void CppSyntaxer::procNumber(bool isFloat) if (mLine[mRun+1]=='x' || mLine[mRun+1]=='X') { mTokenId=TokenId::Hex; mRun+=2; + } else if (mLine[mRun+1]=='b' || mLine[mRun+1]=='B') { + mTokenId=TokenId::Binary; + mRun+=2; } else if (mLine[mRun+1]>='0' && mLine[mRun+1]<='7') { mTokenId=TokenId::Octal; mRun+=2; @@ -690,6 +704,9 @@ void CppSyntaxer::procNumber(bool isFloat) case TokenId::Octal: procOctNumber(); break; + case TokenId::Binary: + procBinNumber(); + break; default: procDecNumber(); } @@ -700,12 +717,6 @@ void CppSyntaxer::procDecNumber() while (mRun=mLineSize) + return; + int i=mRun; + bool shouldExit = false; + while (imRun) { + QString s=mLine.mid(mRun,i-mRun).toLower(); + if (ValidIntegerSuffixes.contains(s)) { + mRun=i; + } + } + return ; +} + +void CppSyntaxer::procFloatSuffix() +{ + if (mRun>=mLineSize) + return; + switch (mLine[mRun].unicode()) { + case 'f': + case 'F': + case 'l': + case 'L': + mRun++; + break; + } + return ; +} + void CppSyntaxer::procOr() { mTokenId = TokenId::Symbol; @@ -1427,6 +1513,8 @@ const PTokenAttribute &CppSyntaxer::getTokenAttribute() const return mHexAttribute; case TokenId::Octal: return mOctAttribute; + case TokenId::Binary: + return mOctAttribute; case TokenId::Space: return mWhitespaceAttribute; case TokenId::String: diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.h b/libs/qsynedit/qsynedit/syntaxer/cpp.h index 95971810..da1ff4e0 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.h +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.h @@ -41,6 +41,7 @@ class CppSyntaxer: public Syntaxer Hex, HexFloat, Octal, + Binary, RawString }; @@ -88,6 +89,8 @@ public: static const QSet Keywords; + static const QSet ValidIntegerSuffixes; + TokenId getTokenId(); private: void procAndSymbol(); @@ -114,6 +117,11 @@ private: void procDecNumber(); void procHexNumber(); void procOctNumber(); + void procBinNumber(); + void procNumberSuffix(); + void procIntegerSuffix(); + void procFloatSuffix(); + void procOr(); void procPlus(); void procPoint();