- enhancement: Syntax color support for binaray integer literals.
- enhancement: Syntax color support for suffix in integer/float literals.
This commit is contained in:
parent
b176215d1f
commit
9c04759602
4
NEWS.md
4
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
|
||||
|
||||
|
|
|
@ -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<ProjectType>(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");
|
||||
|
|
|
@ -93,3 +93,4 @@ void ProjectCompileParamatersWidget::updateIcons(const QSize &/*size*/)
|
|||
pIconsManager->setIcon(ui->btnChooseLib, IconsManager::ACTION_MISC_FOLDER);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ protected:
|
|||
private slots:
|
||||
void on_btnChooseLib_clicked();
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void updateIcons(const QSize &size) override;
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabCommands">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabCCompiler">
|
||||
<attribute name="title">
|
||||
|
|
|
@ -31,7 +31,18 @@ static const QSet<QString> CppStatementKeyWords {
|
|||
"while",
|
||||
"do"
|
||||
};
|
||||
|
||||
const QSet<QString> CppSyntaxer::ValidIntegerSuffixes {
|
||||
"u",
|
||||
"ll",
|
||||
"z",
|
||||
"l",
|
||||
"uz",
|
||||
"zu",
|
||||
"ull",
|
||||
"llu",
|
||||
"lu",
|
||||
"ul"
|
||||
};
|
||||
|
||||
|
||||
const QSet<QString> 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) {
|
||||
switch(mLine[mRun].unicode()) {
|
||||
case '\'':
|
||||
if (mTokenId != TokenId::Number) {
|
||||
return;
|
||||
}
|
||||
mRun++;
|
||||
break;
|
||||
case '.':
|
||||
if (mTokenId != TokenId::Number) {
|
||||
mTokenId = TokenId::Unknown;
|
||||
|
@ -724,6 +735,7 @@ void CppSyntaxer::procDecNumber()
|
|||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '\'':
|
||||
mRun++;
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -734,6 +746,7 @@ void CppSyntaxer::procDecNumber()
|
|||
mRun++;
|
||||
break;
|
||||
default:
|
||||
procNumberSuffix();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -774,6 +787,7 @@ void CppSyntaxer::procHexNumber()
|
|||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case '\'':
|
||||
mRun++;
|
||||
break;
|
||||
case 'p':
|
||||
|
@ -784,6 +798,7 @@ void CppSyntaxer::procHexNumber()
|
|||
mRun++;
|
||||
break;
|
||||
default:
|
||||
procNumberSuffix();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -802,14 +817,85 @@ void CppSyntaxer::procOctNumber()
|
|||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '\'':
|
||||
mRun++;
|
||||
break;
|
||||
default:
|
||||
procIntegerSuffix();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CppSyntaxer::procBinNumber()
|
||||
{
|
||||
while (mRun<mLineSize) {
|
||||
switch(mLine[mRun].unicode()) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '\'':
|
||||
mRun++;
|
||||
break;
|
||||
default:
|
||||
procIntegerSuffix();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CppSyntaxer::procNumberSuffix()
|
||||
{
|
||||
if (mTokenId==TokenId::HexFloat
|
||||
|| mTokenId==TokenId::Float )
|
||||
procFloatSuffix();
|
||||
else
|
||||
procIntegerSuffix();
|
||||
}
|
||||
|
||||
void CppSyntaxer::procIntegerSuffix()
|
||||
{
|
||||
if (mRun>=mLineSize)
|
||||
return;
|
||||
int i=mRun;
|
||||
bool shouldExit = false;
|
||||
while (i<mLineSize && !shouldExit) {
|
||||
switch (mLine[i].unicode()) {
|
||||
case 'u':
|
||||
case 'U':
|
||||
case 'l':
|
||||
case 'L':
|
||||
case 'z':
|
||||
case 'Z':
|
||||
i++;
|
||||
break;
|
||||
default:
|
||||
shouldExit=true;
|
||||
}
|
||||
}
|
||||
if (i>mRun) {
|
||||
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:
|
||||
|
|
|
@ -41,6 +41,7 @@ class CppSyntaxer: public Syntaxer
|
|||
Hex,
|
||||
HexFloat,
|
||||
Octal,
|
||||
Binary,
|
||||
RawString
|
||||
};
|
||||
|
||||
|
@ -88,6 +89,8 @@ public:
|
|||
|
||||
static const QSet<QString> Keywords;
|
||||
|
||||
static const QSet<QString> 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();
|
||||
|
|
Loading…
Reference in New Issue