diff --git a/RedPandaIDE/HighlighterManager.cpp b/RedPandaIDE/HighlighterManager.cpp index ad8cf533..59b05fa8 100644 --- a/RedPandaIDE/HighlighterManager.cpp +++ b/RedPandaIDE/HighlighterManager.cpp @@ -54,7 +54,7 @@ QSynedit::PHighlighter HighlighterManager::getHighlighter(const QString &filenam QFileInfo info(filename); QString suffix = info.suffix(); QString basename = info.baseName(); - if (suffix.isEmpty() || suffix == "c" || suffix == "cpp" || suffix == "cxx" + if (suffix == "c" || suffix == "cpp" || suffix == "cxx" || suffix == "cc" || suffix == "h" || suffix == "hpp" || suffix == "hxx" || suffix == "hh" || suffix == "C" || suffix == "CPP" || suffix =="H" || suffix == "c++" @@ -64,8 +64,11 @@ QSynedit::PHighlighter HighlighterManager::getHighlighter(const QString &filenam return getGLSLHighlighter(); } else if (suffix == "s" || suffix == "asm") { return getAsmHighlighter(); - } else if (basename.compare("makefile", Qt::CaseInsensitive)==0) + } else if (basename.compare("makefile", Qt::CaseInsensitive)==0) { return getMakefileHighlighter(); + } else if (suffix.isEmpty()) { + return getCppHighlighter(); + } return QSynedit::PHighlighter(); } diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index db8ded5f..931bcee5 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -323,6 +323,8 @@ bool Editor::saveAs(const QString &name, bool fromProject){ pos++; } dialog.setDefaultSuffix(suffix); + } else { + dialog.setDefaultSuffix(""); } }); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 4e3d63f4..35796ab1 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -4309,6 +4309,7 @@ void MainWindow::onClassBrowserRefreshEnd() void MainWindow::onProjectSwitchCustomViewMode() { mProject->setModelType(ProjectModelType::Custom); + qDebug()<<"3"; ui->projectView->expand( mProjectProxyModel->mapFromSource( mProject->model()->rootIndex())); @@ -4752,8 +4753,8 @@ void MainWindow::closeProject(bool refreshEditor) mTodoModel.setIsForProject(false); // Clear error browser clearIssues(); - updateProjectView(); } + updateProjectView(); mClosingProject=false; } } diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 1b18d5c7..3d1d16c2 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3819,7 +3819,7 @@ void CppParser::internalParse(const QString &fileName) QStringList preprocessResult = mPreprocessor.result(); #ifdef QT_DEBUG - stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); +// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); // mPreprocessor.dumpDefinesTo("r:\\defines.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); #endif @@ -3833,7 +3833,7 @@ void CppParser::internalParse(const QString &fileName) if (mTokenizer.tokenCount() == 0) return; #ifdef QT_DEBUG - mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); +// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); #endif #ifdef QT_DEBUG lastIndex = -1; @@ -3844,8 +3844,8 @@ void CppParser::internalParse(const QString &fileName) break; } #ifdef QT_DEBUG - mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); - mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); +// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); +// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); #endif //reduce memory usage internalClear(); diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index 9e5db9c5..d434f0ae 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -828,7 +828,7 @@ p, li { white-space: pre-wrap; } Statically link libraries - 静态链接所有库 + 用静态链接方式链接库文件 diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 4b35a3e0..4caa8cea 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -5533,7 +5533,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& int caretY=pos.line; // step1: insert the first line of Value into current line if (text.length()>1) { - if (!mUndoing && mHighlighter && mOptions.testFlag(eoAutoIndent)) { + if (!mUndoing && mHighlighter && mHighlighter->language()==HighlighterLanguage::Cpp && mOptions.testFlag(eoAutoIndent)) { QString s = trimLeft(text[0]); if (sLeftSide.isEmpty()) { sLeftSide = GetLeftSpacing(calcIndentSpaces(caretY,s,true),true); @@ -5563,7 +5563,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& if (i==text.length()-1) { str = sRightSide; } else { - if (!mUndoing && mHighlighter && mOptions.testFlag(eoAutoIndent) && notInComment) { + if (!mUndoing && mHighlighter && mHighlighter->language()==HighlighterLanguage::Cpp && mOptions.testFlag(eoAutoIndent) && notInComment) { str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true); } else { str = ""; @@ -5573,7 +5573,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& str = text[i]; if (i==text.length()-1) str += sRightSide; - if (!mUndoing && mHighlighter && mOptions.testFlag(eoAutoIndent) && notInComment) { + if (!mUndoing && mHighlighter && mHighlighter->language()==HighlighterLanguage::Cpp && mOptions.testFlag(eoAutoIndent) && notInComment) { int indentSpaces = calcIndentSpaces(caretY,str,true); str = GetLeftSpacing(indentSpaces,true)+trimLeft(str); } diff --git a/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.cpp b/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.cpp index ed5c85d1..ef54516c 100644 --- a/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.cpp +++ b/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.cpp @@ -218,13 +218,16 @@ void MakefileHighlighter::procNull() void MakefileHighlighter::procString(bool inExpression ) { - mState = RangeState::String; mTokenID = TokenId::String; while (mLine[mRun] != 0) { - if (mLine[mRun] == '\"') { + if (mState==RangeState::DQString && mLine[mRun] == '\"') { mRun++; popState(); break; + } else if (mState==RangeState::SQString && mLine[mRun] == '\'') { + mRun++; + popState(); + break; } else if (!inExpression && mLine[mRun] == '$') { break; } else if (isSpaceChar(mLine[mRun])) { @@ -235,12 +238,19 @@ void MakefileHighlighter::procString(bool inExpression ) } -void MakefileHighlighter::procStringStart() +void MakefileHighlighter::procStringStart(StringStartType type,bool inExpression ) { mRun++; pushState(); - procString(mState!=RangeState::BraceExpression - && mState!=RangeState::ParenthesisExpression); + switch(type) { + case StringStartType::SingleQuoted: + mState = RangeState::SQString; + break; + case StringStartType::DoubleQuoted: + mState = RangeState::DQString; + break; + } + procString(inExpression); } void MakefileHighlighter::procExpressionStart(ExpressionStartType type) @@ -355,7 +365,8 @@ void MakefileHighlighter::procIdentifier() case RangeState::Unknown: mTokenID = TokenId::Target; break; - case RangeState::String: + case RangeState::DQString: + case RangeState::SQString: mTokenID = TokenId::String; break; } @@ -378,9 +389,6 @@ void MakefileHighlighter::popState() bool MakefileHighlighter::isIdentChar(const QChar &ch) const { - if (ch == '_' || ch =='-') { - return true; - } if ((ch>='0') && (ch <= '9')) { return true; } @@ -390,6 +398,16 @@ bool MakefileHighlighter::isIdentChar(const QChar &ch) const if ((ch>='A') && (ch <= 'Z')) { return true; } + switch(ch.unicode()) { + case '_': + case '%': + case '.': + case '*': + case '-': + case '+': + case '/': + return true; + } return false; } @@ -469,7 +487,8 @@ void MakefileHighlighter::next() return; } switch(mState) { - case RangeState::String: + case RangeState::DQString: + case RangeState::SQString: if (mLine[mRun] == '$') procDollar(); else @@ -484,7 +503,10 @@ void MakefileHighlighter::next() procDollar(); break; case '\"': - procStringStart(); + procStringStart(StringStartType::DoubleQuoted,false); + break; + case '\'': + procStringStart(StringStartType::SingleQuoted,false); break; case '#': procComment(); @@ -511,6 +533,12 @@ void MakefileHighlighter::next() else procSymbol(); break; + case '\"': + procStringStart(StringStartType::DoubleQuoted,true); + break; + case '\'': + procStringStart(StringStartType::SingleQuoted,true); + break; case '}': if (mState == RangeState::BraceExpression) procExpressionEnd(); @@ -523,7 +551,6 @@ void MakefileHighlighter::next() case '@': case '+': case '*': - case '%': case '^': case '<': case '?': @@ -534,6 +561,14 @@ void MakefileHighlighter::next() } else procSymbol(); break; + case '%': + if (mLine[mRun]=='D' || mLine[mRun]=='F') { + //auto variable + mRun+=2; + mTokenID = TokenId::Variable; + } else + procIdentifier(); + break; default: if (mLine[mRun]>='0' && mLine[mRun]<='9') { procNumber(); @@ -553,7 +588,10 @@ void MakefileHighlighter::next() procComment(); break; case '\"': - procStringStart(); + procStringStart(StringStartType::DoubleQuoted,false); + break; + case '\'': + procStringStart(StringStartType::SingleQuoted,false); break; case '?': case '+': diff --git a/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.h b/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.h index 05537a84..bc9c41e1 100644 --- a/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.h +++ b/libs/qsynedit/qsynedit/highlighter/makefilehighlighter.h @@ -42,7 +42,9 @@ class MakefileHighlighter : public Highlighter }; enum RangeState { - Unknown, String, + Unknown, + DQString, // Double Quoted "blahblah" + SQString, // Single Quoted 'blahblah' /* Targets, */ Prequisitions, Command, @@ -52,11 +54,16 @@ class MakefileHighlighter : public Highlighter Assignment, }; - enum ExpressionStartType { + enum class ExpressionStartType { Parenthesis, Brace }; + enum class StringStartType { + SingleQuoted, + DoubleQuoted + }; + public: explicit MakefileHighlighter(); @@ -85,7 +92,7 @@ private: void procNumber(); void procNull(); void procString(bool inExpression ); - void procStringStart(); + void procStringStart(StringStartType type, bool inExpression); void procExpressionStart(ExpressionStartType type); void procExpressionEnd(); void procSymbol(); @@ -99,15 +106,21 @@ private: void pushState(); void popState(); bool isIdentStartChar(const QChar& ch) { - if (ch == '_') { - return true; - } if ((ch>='a') && (ch <= 'z')) { return true; } if ((ch>='A') && (ch <= 'Z')) { return true; } + switch(ch.unicode()) { + case '_': + case '%': + case '.': + case '*': + case '/': + return true; + } + return false; }