From 45744b43f09fdde58cb1f07e2c18f699033bc066 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 2 May 2022 21:47:01 +0800 Subject: [PATCH] - change: highlight whole #define statement using one color - enhancement: don't highlight '\' as error - enhancement: hide add charset option in project options dialog's compiler set page, when project compiler set is clang - fix: When generating project's makefile for clang, don't add -fexec-charset / -finput-charset command line options --- NEWS.md | 4 ++ RedPandaIDE/RedPandaIDE.pro | 2 +- RedPandaIDE/compiler/compiler.cpp | 1 - RedPandaIDE/compiler/projectcompiler.cpp | 2 +- RedPandaIDE/qsynedit/highlighter/cpp.cpp | 60 ++++++++++++------- RedPandaIDE/qsynedit/highlighter/cpp.h | 3 +- .../settingsdialog/projectcompilerwidget.cpp | 7 ++- Red_Panda_CPP.pro | 2 +- 8 files changed, 51 insertions(+), 30 deletions(-) diff --git a/NEWS.md b/NEWS.md index 894203f4..e2a18de5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ Red Panda C++ Version 1.0.7 - change: use Shift+Enter to break line + - change: highlight whole #define statement using one color + - enhancement: don't highlight '\' as error + - enhancement: hide add charset option in project options dialog's compiler set page, when project compiler set is clang + - fix: When generating project's makefile for clang, don't add -fexec-charset / -finput-charset command line options Red Panda C++ Version 1.0.6 - fix: gcc compiler set name is not correct in Linux diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 306b5eaf..0b076de2 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -10,7 +10,7 @@ isEmpty(APP_NAME) { } isEmpty(APP_VERSION) { - APP_VERSION=1.0.6 + APP_VERSION=1.0.7 } diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index e82b5bb0..ff40b130 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -383,7 +383,6 @@ QString Compiler::getCCompileArguments(bool checkSyntax) QString Compiler::getCppCompileArguments(bool checkSyntax) { - return getCCompileArguments(checkSyntax); QString result; if (checkSyntax) { result += " -fsyntax-only"; diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index 5f55c4b5..6936d924 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -386,7 +386,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file) // Or roll our own } else { QString encodingStr; - if (mProject->options().addCharset) { + if (compilerSet()->compilerType() != COMPILER_CLANG && mProject->options().addCharset) { QByteArray defaultSystemEncoding = pCharsetInfoManager->getDefaultSystemEncoding(); if (unit->encoding() == ENCODING_AUTO_DETECT) { Editor* editor = mProject->unitEditor(unit); diff --git a/RedPandaIDE/qsynedit/highlighter/cpp.cpp b/RedPandaIDE/qsynedit/highlighter/cpp.cpp index dfdb368b..3535e200 100644 --- a/RedPandaIDE/qsynedit/highlighter/cpp.cpp +++ b/RedPandaIDE/qsynedit/highlighter/cpp.cpp @@ -445,32 +445,36 @@ void SynEditCppHighlighter::directiveProc() mRun+=1; } + QString directive; while (mLine[mRun]!=0 && isIdentChar(mLine[mRun])) { + directive+=mLine[mRun]; mRun+=1; } - mRange.state = RangeState::rsUnknown; -// do { -// switch(mLine[mRun].unicode()) { -// case '/': //comment? -// switch (mLine[mRun+1].unicode()) { -// case '/': // is end of directive as well -// mRange.state = RangeState::rsUnknown; -// return; -// case '*': // might be embeded only -// mRange.state = RangeState::rsDirectiveComment; -// return; -// } -// break; -// case '\\': // yet another line? -// if (mLine[mRun+1] == 0) { -// mRun+=1; -// mRange.state = RangeState::rsMultiLineDirective; -// return; -// } -// break; -// } -// mRun+=1; -// } while (mLine[mRun]!=0); + if (directive == "define") { + do { + switch(mLine[mRun].unicode()) { + case '/': //comment? + switch (mLine[mRun+1].unicode()) { + case '/': // is end of directive as well + mRange.state = RangeState::rsUnknown; + return; + case '*': // might be embeded only + mRange.state = RangeState::rsDirectiveComment; + return; + } + break; + case '\\': // yet another line? + if (mLine[mRun+1] == 0) { + mRun+=1; + mRange.state = RangeState::rsMultiLineDirective; + return; + } + break; + } + mRun+=1; + } while (mLine[mRun]!=0); + } else + mRange.state = RangeState::rsUnknown; } void SynEditCppHighlighter::directiveEndProc() @@ -972,6 +976,13 @@ void SynEditCppHighlighter::slashProc() } } +void SynEditCppHighlighter::backSlashProc() +{ + mTokenId = TokenKind::Symbol; + mExtTokenId = ExtTokenKind::BackSlash; + mRun+=1; +} + void SynEditCppHighlighter::spaceProc() { mRun += 1; @@ -1287,6 +1298,9 @@ void SynEditCppHighlighter::processChar() case '!': notSymbolProc(); break; + case '\\': + backSlashProc(); + break; case 0: nullProc(); break; diff --git a/RedPandaIDE/qsynedit/highlighter/cpp.h b/RedPandaIDE/qsynedit/highlighter/cpp.h index 7cdba6dc..aecc3c67 100644 --- a/RedPandaIDE/qsynedit/highlighter/cpp.h +++ b/RedPandaIDE/qsynedit/highlighter/cpp.h @@ -53,7 +53,7 @@ class SynEditCppHighlighter: public SynHighlighter RoundClose, RoundOpen, ScopeResolution, SemiColon, ShiftLeft, ShiftLeftAssign, ShiftRight, ShiftRightAssign, SquareClose, SquareOpen, Star, Subtract, SubtractAssign, Xor, - XorAssign + XorAssign, BackSlash }; enum RangeState { @@ -130,6 +130,7 @@ private: void roundOpenProc(); void semiColonProc(); void slashProc(); + void backSlashProc(); void spaceProc(); void squareCloseProc(); void squareOpenProc(); diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp index 3703b9d3..0fc0e40f 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp @@ -37,6 +37,8 @@ void ProjectCompilerWidget::refreshOptions() Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex()); if (!pSet) return; + ui->chkAddCharset->setVisible(pSet->compilerType()!=COMPILER_CLANG); + ui->chkAddCharset->setEnabled(pSet->compilerType()!=COMPILER_CLANG); mOptions = pSet->iniOptions(); QTabWidget* pTab = ui->tabOptions; while (pTab->count()>0) { @@ -111,7 +113,7 @@ void ProjectCompilerWidget::doLoad() void ProjectCompilerWidget::doSave() { - Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet(); + Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex()); if (!pSet) return; //read values in the options widget @@ -137,7 +139,8 @@ void ProjectCompilerWidget::doSave() } pMainWindow->project()->setCompilerSet(ui->cbCompilerSet->currentIndex()); pMainWindow->project()->options().compilerOptions = mOptions; - pMainWindow->project()->options().addCharset = ui->chkAddCharset->isChecked(); + if (pSet->compilerType()!=COMPILER_CLANG) + pMainWindow->project()->options().addCharset = ui->chkAddCharset->isChecked(); pMainWindow->project()->options().staticLink = ui->chkStaticLink->isChecked(); pMainWindow->project()->saveOptions(); } diff --git a/Red_Panda_CPP.pro b/Red_Panda_CPP.pro index 1c301e20..db09758c 100644 --- a/Red_Panda_CPP.pro +++ b/Red_Panda_CPP.pro @@ -17,7 +17,7 @@ SUBDIRS += \ APP_NAME = RedPandaCPP -APP_VERSION = 1.0.6 +APP_VERSION = 1.0.7 linux: {