From e3145d680f6448b22b09959d57bf61ed8abf4e9d Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 13 Apr 2024 10:39:55 +0800 Subject: [PATCH 01/15] - fix: Shouldn't consider preceeding '&'/'*' when popping completion suggest list for variable members. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 4 ++++ RedPandaIDE/parser/cppparser.cpp | 29 +++++++++++++++++------------ RedPandaIDE/parser/cppparser.h | 8 +++++++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5ed6addd..70dc9de9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -138,6 +138,7 @@ Red Panda C++ Version 2.27 - enhancement: Auto hide Project menu if no project openning. - fix: Toggle breakpoint by shortcut may use wrong line. - fix: Size of the icons in problem and problem set panel are not correct. + - fix: Shouldn't consider preceeding '&'/'*' when popping completion suggest list for variable members. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index ab73f887..85d6001e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -2341,6 +2341,10 @@ QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion( QStringList &memberExpression) { QStringList expression = getExpressionAtPosition(pos); + // *(Deference) and &(Address-of) has low precedence than '.'/'->', + // so don't includes them in the owner expression in comletion calculation + while (!expression.isEmpty() && (expression.front()=='*' || expression.front()=='&')) + expression.pop_front(); return getOwnerExpressionAndMember(expression,memberOperator,memberExpression); } diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 9a12a39e..394835cd 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -4755,7 +4755,7 @@ PEvalStatement CppParser::doEvalPointerToMembers( if (pos>=phraseExpression.length()) return PEvalStatement(); //find the start scope statement - PEvalStatement currentResult = doEvalCCast( + PEvalStatement currentResult = doEvalTypeCast( fileName, phraseExpression, pos, @@ -4771,7 +4771,7 @@ PEvalStatement CppParser::doEvalPointerToMembers( || phraseExpression[pos]=="->*")) { pos++; currentResult = - doEvalCCast( + doEvalTypeCast( fileName, phraseExpression, pos, @@ -4788,7 +4788,7 @@ PEvalStatement CppParser::doEvalPointerToMembers( return currentResult; } -PEvalStatement CppParser::doEvalCCast(const QString &fileName, +PEvalStatement CppParser::doEvalTypeCast(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement& scope, @@ -4799,8 +4799,9 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, return PEvalStatement(); PEvalStatement result; if (phraseExpression[pos]=="*") { + //deference pos++; //skip "*" - result = doEvalCCast( + result = doEvalTypeCast( fileName, phraseExpression, pos, @@ -4862,8 +4863,9 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, result->pointerLevel--; } } else if (phraseExpression[pos]=="&") { + //Address-of pos++; //skip "&" - result = doEvalCCast( + result = doEvalTypeCast( fileName, phraseExpression, pos, @@ -4875,8 +4877,9 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, } } else if (phraseExpression[pos]=="++" || phraseExpression[pos]=="--") { + // Prefix increment and decrement pos++; //skip "++" or "--" - result = doEvalCCast( + result = doEvalTypeCast( fileName, phraseExpression, pos, @@ -4884,6 +4887,7 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, previousResult, freeScoped); } else if (phraseExpression[pos]=="(") { + //Type Cast //parse int startPos = pos; pos++; @@ -4904,7 +4908,7 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, pos++; // skip ")" // qDebug()<<"parse type cast exp"; //it's a type cast - result = doEvalCCast(fileName, + result = doEvalTypeCast(fileName, phraseExpression, pos, scope, @@ -4930,11 +4934,6 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, scope, previousResult, freeScoped); -// if (result) { -// qDebug()<kind<baseType; -// } else { -// qDebug()<<"!!!!!!!!!!!not found"; -// } return result; } @@ -4963,8 +4962,10 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, if (!result) break; if (phraseExpression[pos]=="++" || phraseExpression[pos]=="--") { + //Suffix/postfix increment and decrement pos++; //just skip it } else if (phraseExpression[pos] == "(") { + // Function call if (result->kind == EvalStatementKind::Type) { doSkipInExpression(phraseExpression,pos,"(",")"); result->kind = EvalStatementKind::Variable; @@ -5025,11 +5026,13 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, result = PEvalStatement(); } } else if (phraseExpression[pos] == "{") { + // Varaible Initialization if (result->kind == EvalStatementKind::Type) { doSkipInExpression(phraseExpression,pos,"{","}"); result->kind = EvalStatementKind::Variable; } } else if (phraseExpression[pos] == "[") { + //Array subscripting //skip to "]" doSkipInExpression(phraseExpression,pos,"[","]"); if (result->kind == EvalStatementKind::Type) { @@ -5079,6 +5082,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, } } } else if (phraseExpression[pos] == ".") { + //Structure and union member access pos++; lastResult = result; result = doEvalScopeResolution( @@ -5089,6 +5093,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, result, false); } else if (phraseExpression[pos] == "->") { + // Structure and union member access through pointer pos++; if (result->pointerLevel==0) { // iterator diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 40f02b19..0af6fe1e 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -339,13 +339,19 @@ private: const PStatement& scope, const PEvalStatement& previousResult, bool freeScoped) const; - PEvalStatement doEvalCCast( + + /* + * Dereference / Address-of / Type Cast / Prefix increment and decrement + * */ + PEvalStatement doEvalTypeCast( const QString& fileName, const QStringList& phraseExpression, int &pos, const PStatement& scope, const PEvalStatement& previousResult, bool freeScoped) const; + + PEvalStatement doEvalMemberAccess( const QString& fileName, const QStringList& phraseExpression, From ab30ede5c5c374d84e00721ae91aaa1d5c714f68 Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Sat, 13 Apr 2024 17:45:55 +0800 Subject: [PATCH 02/15] Add rasterized icons in Arch Linux package (#383) * add rasterized icons in arch linux package * fix missing deps in chroot-ed build --- packages/archlinux/PKGBUILD.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/archlinux/PKGBUILD.in b/packages/archlinux/PKGBUILD.in index 4be8f74f..10f8415a 100644 --- a/packages/archlinux/PKGBUILD.in +++ b/packages/archlinux/PKGBUILD.in @@ -7,7 +7,7 @@ arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64' 'riscv64') url="https://github.com/royqh1979/$_pkgname" license=('GPL3') depends=(qt5-base qt5-svg gcc gdb) -makedepends=(qt5-tools) +makedepends=(qt5-tools imagemagick librsvg) optdepends=( 'clang: C/C++ compiler (alternative)' ) @@ -42,4 +42,13 @@ package() { cd redpanda-build make INSTALL_ROOT="$pkgdir" install + + for size in 16 22 24 32 36 48 64 72 96 128 192 256 512; do + mkdir -p "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps" + magick convert \ + -background none \ + "$pkgdir/usr/share/icons/hicolor/scalable/apps/redpandaide.svg" \ + -resize ${size}x${size} \ + "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/redpandaide.png" + done } From 89f8d9ae210e54fb3316ba1df802c2870a56e81f Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 13 Apr 2024 18:01:32 +0800 Subject: [PATCH 03/15] - fix: Positions of current matching parenthesis not correctly updated. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 10 +++-- libs/qsynedit/qsynedit/qsynedit.cpp | 12 ------ libs/qsynedit/qsynedit/qsynedit.h | 66 +++++++---------------------- 4 files changed, 22 insertions(+), 67 deletions(-) diff --git a/NEWS.md b/NEWS.md index 70dc9de9..f1ae9119 100644 --- a/NEWS.md +++ b/NEWS.md @@ -139,6 +139,7 @@ Red Panda C++ Version 2.27 - fix: Toggle breakpoint by shortcut may use wrong line. - fix: Size of the icons in problem and problem set panel are not correct. - fix: Shouldn't consider preceeding '&'/'*' when popping completion suggest list for variable members. + - fix: Positions of current matching parenthesis not correctly updated. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 85d6001e..8ecd0526 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1859,6 +1859,12 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes) if (changes.testFlag(QSynedit::StatusChange::CaretX) || changes.testFlag(QSynedit::StatusChange::CaretY)) { + if (pSettings->editor().highlightMathingBraces()) { + invalidateLine(mHighlightCharPos1.line); + invalidateLine(mHighlightCharPos2.line); + } + mHighlightCharPos1 = QSynedit::BufferCoord{0,0}; + mHighlightCharPos2 = QSynedit::BufferCoord{0,0}; if (mTabStopBegin >=0) { if (mTabStopY==caretY()) { if (mLineAfterTabStop.isEmpty()) { @@ -1885,10 +1891,6 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes) } } } else if (!selAvail() && pSettings->editor().highlightMathingBraces()){ - invalidateLine(mHighlightCharPos1.line); - invalidateLine(mHighlightCharPos2.line); - mHighlightCharPos1 = QSynedit::BufferCoord{0,0}; - mHighlightCharPos2 = QSynedit::BufferCoord{0,0}; // Is there a bracket char before us? int lineLength = lineText().length(); int ch = caretX() - 2; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index b1cda448..1bbb7d55 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -5380,11 +5380,6 @@ int QSynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList sLeftSide += QString(pos.ch - 1 - sLeftSide.length(),' '); } sRightSide = line.mid(pos.ch - 1); -// if (mUndoing) { -// SpaceCount = 0; -// } else { -// SpaceCount = leftSpaces(sLeftSide); -// } int caretY=pos.line; // step1: insert the first line of Value into current line if (text.length()>1) { @@ -5406,14 +5401,7 @@ int QSynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList // step2: insert remaining lines of Value for (int i=1;iisCommentNotFinished( -// mHighlighter->getRangeState().state) -// && !mHighlighter->isStringNotFinished( -// mHighlighter->getRangeState().state); -// } caretY=pos.line+i; -// mStatusChanges.setFlag(SynStatusChange::scCaretY); if (text[i].isEmpty()) { if (i==text.length()-1) { str = sRightSide; diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index d39fa2de..34627d7b 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -449,30 +449,26 @@ public: void setBackgroundColor(const QColor &newBackgroundColor); bool isEmpty(); + + int mouseSelectionScrollSpeed() const; + void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed); + + ScrollStyle scrollBars() const; + void setScrollBars(ScrollStyle newScrollBars); + + double lineSpacingFactor() const; + void setLineSpacingFactor(double newLineSpacingFactor); + + const QDateTime &lastModifyTime() const; + + const PFormatter &formatter() const; + void setFormatter(const PFormatter &newFormatter); signals: void linesDeleted(int FirstLine, int Count); void linesInserted(int FirstLine, int Count); - void changed(); - -// void chainUndoAdded(); -// void chainRedoAdded(); -// void chainLinesChanging(); -// void chainLinesChanged(); -// void chainListCleared(); - -// void chainListDeleted(int Index, int Count); -// void chainListInserted(int Index, int Count); -// void chainListPutted(int Index, int Count); - -// void filesDropped(int X,int Y, const QStringList& AFiles); void gutterClicked(Qt::MouseButton button, int x, int y, int line); -// void imeInputed(const QString& s); - -// void contextHelp(const QString& word); - void statusChanged(StatusChanges changes); - void fontChanged(); void tabSizeChanged(); protected: @@ -727,11 +723,6 @@ private: StatusChanges mStatusChanges; int mLastKey; Qt::KeyboardModifiers mLastKeyModifiers; - //fSearchEngine: TSynEditSearchCustom; - //fHookedCommandHandlers: TList; - //fKbdHandler: TSynEditKbdHandler; - // fFocusList: TList; - // fPlugins: TList; QTimer* mScrollTimer; PSynEdit fChainedEditor; @@ -740,20 +731,7 @@ private: bool mIsScrolling; int mOptionLock; // lock counter to prevent recalculate glyph widths while change settings; bool mUndoing; - // event handlers - // ProcessCommandProc mOnCommandProcessed; - // MouseCursorProc mOnMouseCursor; - // PaintProc mOnPaint; -// SynPreparePaintHighlightTokenProc mOnPaintHighlightToken; - // ProcessCommandProc mOnProcessingCommand; - // ProcessCommandProc mOnProcessingUserCommand; - -// SynSpecialLineColorsProc mOnSpecialLineColors; -// SynEditingAreasProc mOnEditingAreas; -// SynGutterGetTextProc mOnGutterGetText; -// SynTGutterPaintProc mOnGutterPaint; int mGutterWidth; - //caret blink related int m_blinkTimerId; int m_blinkStatus; @@ -799,23 +777,9 @@ protected: bool viewportEvent(QEvent * event) override; // QWidget interface - public: +public: QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; - int mouseSelectionScrollSpeed() const; - void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed); - - ScrollStyle scrollBars() const; - void setScrollBars(ScrollStyle newScrollBars); - - double lineSpacingFactor() const; - void setLineSpacingFactor(double newLineSpacingFactor); - - const QDateTime &lastModifyTime() const; - - const PFormatter &formatter() const; - void setFormatter(const PFormatter &newFormatter); - protected: void dragEnterEvent(QDragEnterEvent *event) override; void dropEvent(QDropEvent *event) override; From 56310e83635a489d9dde3e9e0199caeb75f17e68 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 13 Apr 2024 22:37:09 +0800 Subject: [PATCH 04/15] - fix: Can't show correct completion info for vars declared with template parameters ending with ">>". --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index f1ae9119..797380ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -140,6 +140,7 @@ Red Panda C++ Version 2.27 - fix: Size of the icons in problem and problem set panel are not correct. - fix: Shouldn't consider preceeding '&'/'*' when popping completion suggest list for variable members. - fix: Positions of current matching parenthesis not correctly updated. + - fix: Can't show correct completion info for vars declared with template parameters ending with ">>". Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 394835cd..87b36b5d 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -5804,6 +5804,8 @@ PStatement CppParser::doParseEvalTypeInfo( templateLevel++; } else if (token == ">") { templateLevel--; + } else if (token == ">>") { + templateLevel-=2; } templateParams += token; } From 5d1b874bdfdb5eed2ff53f27c4d18ed007c910ac Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 09:24:39 +0800 Subject: [PATCH 05/15] fix: ">>" not correctly handled in auto var definition --- RedPandaIDE/parser/cppparser.cpp | 19 ++++++++++++++----- RedPandaIDE/parser/cppparser.h | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 87b36b5d..12b84f8f 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -4686,7 +4686,7 @@ PEvalStatement CppParser::doEvalExpression(const QString& fileName, } return result; } else - return doEvalPointerArithmetic( + return doEvalArithmeticOperation( fileName, phraseExpression, pos, @@ -4695,7 +4695,7 @@ PEvalStatement CppParser::doEvalExpression(const QString& fileName, freeScoped); } -PEvalStatement CppParser::doEvalPointerArithmetic(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped) const +PEvalStatement CppParser::doEvalArithmeticOperation(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped) const { if (pos>=phraseExpression.length()) return PEvalStatement(); @@ -6594,9 +6594,18 @@ QStringList CppParser::splitExpression(const QString &expr) for(int i=0;itokenType()!=QSynedit::TokenType::Comment - && syntaxer.getTokenAttribute()->tokenType()!=QSynedit::TokenType::Space) - result.append(syntaxer.getToken()); + QSynedit::TokenType tokenType = syntaxer.getTokenAttribute()->tokenType(); + QString token = syntaxer.getToken(); + if (tokenType == QSynedit::TokenType::Operator) { + if ( token == ">>" ) { + result.append(">"); + result.append(">"); + } else { + result.append(token); + } + } else if (tokenType!=QSynedit::TokenType::Comment + && tokenType!=QSynedit::TokenType::Space) + result.append(token); syntaxer.next(); } } diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 0af6fe1e..6a8d9f25 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -325,13 +325,15 @@ private: bool freeScoped, bool expandMacros) const; - PEvalStatement doEvalPointerArithmetic( + /* add + / minus - */ + PEvalStatement doEvalArithmeticOperation( const QString& fileName, const QStringList& phraseExpression, int &pos, const PStatement& scope, const PEvalStatement& previousResult, bool freeScoped) const; + /* Pointer to members .* / ->* */ PEvalStatement doEvalPointerToMembers( const QString& fileName, const QStringList& phraseExpression, @@ -341,7 +343,7 @@ private: bool freeScoped) const; /* - * Dereference / Address-of / Type Cast / Prefix increment and decrement + * Dereference * / Address-of & / Type Cast / Prefix increment and decrement * */ PEvalStatement doEvalTypeCast( const QString& fileName, From c6c7d92e1c4358f32657a55a8f5b3f540fea1b3b Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 10:17:17 +0800 Subject: [PATCH 06/15] - enhancement: Auto type induction for "std::make_shared"/"std::make_unique" --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 33 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 797380ef..ae0100fe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -141,6 +141,7 @@ Red Panda C++ Version 2.27 - fix: Shouldn't consider preceeding '&'/'*' when popping completion suggest list for variable members. - fix: Positions of current matching parenthesis not correctly updated. - fix: Can't show correct completion info for vars declared with template parameters ending with ">>". + - enhancement: Auto type induction for "std::make_shared"/"std::make_unique". Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 12b84f8f..5271747f 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -4108,8 +4108,18 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic, if(aliasStatement) { if (aliasStatement->typeStatement) { addedVar->type = aliasStatement->typeStatement->fullName; - if (!addedVar->type.endsWith(">")) - addedVar->type += aliasStatement->templateParams; + if (!aliasStatement->templateParams.isEmpty()) { + if (!addedVar->type.endsWith(">")) { + addedVar->type += aliasStatement->templateParams; + } else { + QString type = addedVar->type; + int pos = type.indexOf('<'); + if (pos>=0) { + type = type.left(pos); + addedVar->type = type + aliasStatement->templateParams; + } + } + } if (aliasStatement->typeStatement && STLIterators.contains(aliasStatement->typeStatement->command) && !aliasStatement->templateParams.isEmpty()) { @@ -5379,13 +5389,17 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName, pos++; } result->pointerLevel = pointerLevel; + } else if (result && result->kind == EvalStatementKind::Function + && postemplateParams = ""; + int oldPos = pos; + doSkipInExpression(phraseExpression,pos,"<",">"); + for(int i=oldPos;itemplateParams+=phraseExpression[i]; + } } } -// qDebug()<type; + if (funcStatement->fullName == "std::make_unique") + type = "unique_ptr"; PStatement effetiveTypeStatement = doParseEvalTypeInfo( fileName, funcStatement->parentScope.lock(), - funcStatement->type, + type, baseType, typeStatement, pointerLevel, From 697bdca25558f5c157605a4a54ce7698431ba4e1 Mon Sep 17 00:00:00 2001 From: zw9629 <31214590+zw9629@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:13:39 +0800 Subject: [PATCH 07/15] =?UTF-8?q?sdcc=20makefile=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20(#377)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * sdcc makefile生成优化 1.隐藏删除文件的错误提示 2.支持生成目标文件输出目录 * 修复删不了文件 * 确保能删除编译文件同时不提示任何错误 * 更正clean脚本错误(%1 2>&1)应为(%1 2>%1) 指定生成目标文件输出目录支持跨盘,跨平台(理论) * 预防配置项为相对路径 * clean 目标与>%1中间添加空格,避免错误 --- RedPandaIDE/compiler/sdccprojectcompiler.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/RedPandaIDE/compiler/sdccprojectcompiler.cpp b/RedPandaIDE/compiler/sdccprojectcompiler.cpp index a754f732..28d4e661 100644 --- a/RedPandaIDE/compiler/sdccprojectcompiler.cpp +++ b/RedPandaIDE/compiler/sdccprojectcompiler.cpp @@ -195,7 +195,7 @@ void SDCCProjectCompiler::writeMakeIncludes(QFile &file) void SDCCProjectCompiler::writeMakeClean(QFile &file) { writeln(file, "clean: clean-custom"); - writeln(file, QString("\t-$(RM) $(CLEANOBJ) > %1 2>&1").arg(NULL_FILE)); + writeln(file, QString("\t@-$(RM) $(CLEANOBJ) >%1 2>%1||:").arg(NULL_FILE)); writeln(file); } @@ -256,6 +256,7 @@ void SDCCProjectCompiler::writeMakeObjFilesRules(QFile &file) writeln(file, objStr); // Write custom build command + if (unit->overrideBuildCmd() && !unit->buildCmd().isEmpty()) { QString BuildCmd = unit->buildCmd(); BuildCmd.replace("", "\n\t"); @@ -263,8 +264,16 @@ void SDCCProjectCompiler::writeMakeObjFilesRules(QFile &file) // Or roll our own } else { if (fileType==FileType::CSource) { - writeln(file, "\t$(CC) $(CFLAGS) -c " + escapeArgumentForMakefileRecipe(shortFileName, false)); - } + if(mProject->options().folderForObjFiles.isEmpty()) { + writeln(file, "\t$(CC) $(CFLAGS) -c " + escapeArgumentForMakefileRecipe(shortFileName, false)); + }else{ + QString fullObjDir = includeTrailingPathDelimiter(mProject->options().folderForObjFiles); + QString relativeObjDir = extractRelativePath(mProject->directory(),fullObjDir); + QString objfile=extractRelativePath(generateAbsolutePath(mProject->directory(),relativeObjDir),unit->fileName()); + writeln(file, "\tpushd "+ localizePath(relativeObjDir)+" &&$(CC) $(CFLAGS) -c " + localizePath(objfile)); + } + + } } } @@ -316,7 +325,7 @@ bool SDCCProjectCompiler::prepareForCompile() parallelParam = "-j1"; } - QString makefile = + QString makefile = extractRelativePath(mProject->directory(), mProject->makeFileName()); QStringList cleanArgs{ "-f", From 44802c6315efea991b77999a249524fe4f265478 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 12:23:31 +0800 Subject: [PATCH 08/15] windows installer: Template -> template - sdcc project compiler: compile source file in subfolders. --- RedPandaIDE/compiler/projectcompiler.cpp | 3 ++- RedPandaIDE/compiler/sdccprojectcompiler.cpp | 5 +++-- RedPandaIDE/systemconsts.h | 2 ++ platform/windows/installer-scripts/redpanda.nsi | 7 +++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index 82277466..cb6dac1a 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -265,6 +265,7 @@ void ProjectCompiler::writeMakeDefines(QFile &file, bool &genModuleDef) writeln(file, "WINDRES = " + escapeArgumentForMakefileVariableValue(windres, true)); #endif writeln(file, "RM = " CLEAN_PROGRAM); + writeln(file, "CD = " CD_PROGRAM); // compiler flags writeln(file, "LIBS = " + escapeArgumentsForMakefileVariableValue(libraryArguments)); @@ -361,7 +362,7 @@ void ProjectCompiler::writeMakeClean(QFile &file) if (mProject->options().type == ProjectType::DynamicLib) { target +=" $(STATIC)"; } - writeln(file, QString("\t-$(RM) %1 > %2 2>&1").arg(target,NULL_FILE)); + writeln(file, QString("\t-$(RM) %1 >%2 2>%2 ").arg(target,NULL_FILE)); writeln(file); } diff --git a/RedPandaIDE/compiler/sdccprojectcompiler.cpp b/RedPandaIDE/compiler/sdccprojectcompiler.cpp index 28d4e661..8ef20a44 100644 --- a/RedPandaIDE/compiler/sdccprojectcompiler.cpp +++ b/RedPandaIDE/compiler/sdccprojectcompiler.cpp @@ -169,6 +169,7 @@ void SDCCProjectCompiler::writeMakeDefines(QFile &file) writeln(file, "BIN_ARG = " + escapeArgumentForMakefileVariableValue(executable, false)); writeln(file, "CFLAGS = $(INCS) " + escapeArgumentsForMakefileVariableValue(cCompileArguments)); writeln(file, "RM = " CLEAN_PROGRAM); + writeln(file, "CD = " CD_PROGRAM); writeln(file); } @@ -195,7 +196,7 @@ void SDCCProjectCompiler::writeMakeIncludes(QFile &file) void SDCCProjectCompiler::writeMakeClean(QFile &file) { writeln(file, "clean: clean-custom"); - writeln(file, QString("\t@-$(RM) $(CLEANOBJ) >%1 2>%1||:").arg(NULL_FILE)); + writeln(file, QString("\t-$(RM) $(CLEANOBJ) >%1 2>%1||:").arg(NULL_FILE)); writeln(file); } @@ -270,7 +271,7 @@ void SDCCProjectCompiler::writeMakeObjFilesRules(QFile &file) QString fullObjDir = includeTrailingPathDelimiter(mProject->options().folderForObjFiles); QString relativeObjDir = extractRelativePath(mProject->directory(),fullObjDir); QString objfile=extractRelativePath(generateAbsolutePath(mProject->directory(),relativeObjDir),unit->fileName()); - writeln(file, "\tpushd "+ localizePath(relativeObjDir)+" &&$(CC) $(CFLAGS) -c " + localizePath(objfile)); + writeln(file, "\t$(CD) "+ localizePath(relativeObjDir)+" && $(CC) $(CFLAGS) -c " + localizePath(objfile)); } } diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index d078acb5..e6225932 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -30,6 +30,7 @@ #define MAKE_PROGRAM "mingw32-make.exe" #define WINDRES_PROGRAM "windres.exe" #define CLEAN_PROGRAM "del /q /f" +#define CD_PROGRAM "cd /d" #define CPP_PROGRAM "cpp.exe" #define GIT_PROGRAM "git.exe" #define CLANG_PROGRAM "clang.exe" @@ -50,6 +51,7 @@ #define WINDRES_PROGRAM "" #define GPROF_PROGRAM "gprof" #define CLEAN_PROGRAM "rm -rf" +#define CD_PROGRAM "cd" #define CPP_PROGRAM "cpp" #define GIT_PROGRAM "git" #define CLANG_PROGRAM "clang" diff --git a/platform/windows/installer-scripts/redpanda.nsi b/platform/windows/installer-scripts/redpanda.nsi index d577385a..4bd4428d 100644 --- a/platform/windows/installer-scripts/redpanda.nsi +++ b/platform/windows/installer-scripts/redpanda.nsi @@ -131,8 +131,8 @@ Section "$(SectionMainName)" SectionMain !endif ; Write required paths - SetOutPath $INSTDIR\Templates - File /nonfatal /r "Templates\*" + SetOutPath $INSTDIR\templates + File /nonfatal /r "templates\*" SectionEnd @@ -440,8 +440,7 @@ Section "Uninstall" Delete "$INSTDIR\OpenConsole.exe" Delete "$INSTDIR\compiler_hint.lua" - RMDir /r "$INSTDIR\Lang" - RMDir /r "$INSTDIR\Templates" + RMDir /r "$INSTDIR\templates" RMDir /r "$INSTDIR\mingw32" RMDir /r "$INSTDIR\mingw64" RMDir /r "$INSTDIR\llvm-mingw" From 081d37e21fff56391df53326ba24e3973478db61 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 12:27:01 +0800 Subject: [PATCH 09/15] redirect 2>&1 --- NEWS.md | 1 + RedPandaIDE/compiler/projectcompiler.cpp | 2 +- RedPandaIDE/compiler/sdccprojectcompiler.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index ae0100fe..d4b89ba1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -142,6 +142,7 @@ Red Panda C++ Version 2.27 - fix: Positions of current matching parenthesis not correctly updated. - fix: Can't show correct completion info for vars declared with template parameters ending with ">>". - enhancement: Auto type induction for "std::make_shared"/"std::make_unique". + - sdcc project compiler: compile source file in subfolders. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index cb6dac1a..4d29a0e8 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -362,7 +362,7 @@ void ProjectCompiler::writeMakeClean(QFile &file) if (mProject->options().type == ProjectType::DynamicLib) { target +=" $(STATIC)"; } - writeln(file, QString("\t-$(RM) %1 >%2 2>%2 ").arg(target,NULL_FILE)); + writeln(file, QString("\t-$(RM) %1 >%2 2>&1").arg(target,NULL_FILE)); writeln(file); } diff --git a/RedPandaIDE/compiler/sdccprojectcompiler.cpp b/RedPandaIDE/compiler/sdccprojectcompiler.cpp index 8ef20a44..683333fe 100644 --- a/RedPandaIDE/compiler/sdccprojectcompiler.cpp +++ b/RedPandaIDE/compiler/sdccprojectcompiler.cpp @@ -196,7 +196,7 @@ void SDCCProjectCompiler::writeMakeIncludes(QFile &file) void SDCCProjectCompiler::writeMakeClean(QFile &file) { writeln(file, "clean: clean-custom"); - writeln(file, QString("\t-$(RM) $(CLEANOBJ) >%1 2>%1||:").arg(NULL_FILE)); + writeln(file, QString("\t-$(RM) $(CLEANOBJ) >%1 2>&1||:").arg(NULL_FILE)); writeln(file); } From 481ad66881000ce7f340f4fb59feb34c6614d7eb Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 18:29:37 +0800 Subject: [PATCH 10/15] update default theme lua script --- RedPandaIDE/resources/themes/default.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RedPandaIDE/resources/themes/default.lua b/RedPandaIDE/resources/themes/default.lua index 1607f412..c988f203 100644 --- a/RedPandaIDE/resources/themes/default.lua +++ b/RedPandaIDE/resources/themes/default.lua @@ -45,7 +45,7 @@ function main() PaletteButtonDisabled = "#efefef", PaletteButtonTextDisabled = "#bebebe", PaletteHighlight = "#688DB2", - PaletteHighlightedText = "#000000", + PaletteHighlightedText = "#ffffff", }, } end From 2b159eac47951b5b1878927ed72f47073169d8b4 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 18:33:02 +0800 Subject: [PATCH 11/15] fix debian update-version script info --- packages/debian/update-version.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/debian/update-version.sh b/packages/debian/update-version.sh index ee26977f..58fe87b5 100755 --- a/packages/debian/update-version.sh +++ b/packages/debian/update-version.sh @@ -12,9 +12,11 @@ cd $DEBIAN_DIR pwd oldver=`head changelog -n 1 | sed -r 's/^redpanda-cpp\s\((.*)-(.*)\)\s.*$/\1/g'` count=`head changelog -n 1 | sed -r 's/^redpanda-cpp\s\((.*)-(.*)\)\s.*$/\2/g'` -echo $oldver +echo "Old version: $oldver" + if [ "$oldver" != "$ver" ]; then + echo "Upgrade to $ver" tmpfile=$(mktemp) now=`date -R` echo "redpanda-cpp ($ver-1) unstable; urgency=medium" >> $tmpfile From 5a7589aeb16d937d47f3ff15758e6ec69d3088bb Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 21:24:21 +0800 Subject: [PATCH 12/15] - fix: project options -> compiler set -> static link & auto convert charset options not correctly loaded. --- NEWS.md | 3 ++- RedPandaIDE/settingsdialog/projectcompilerwidget.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index d4b89ba1..a4328e77 100644 --- a/NEWS.md +++ b/NEWS.md @@ -142,7 +142,8 @@ Red Panda C++ Version 2.27 - fix: Positions of current matching parenthesis not correctly updated. - fix: Can't show correct completion info for vars declared with template parameters ending with ">>". - enhancement: Auto type induction for "std::make_shared"/"std::make_unique". - - sdcc project compiler: compile source file in subfolders. + - enhancement: sdcc project compiler: compile source file in subfolders. + - fix: project options -> compiler set -> static link & auto convert charset options not correctly loaded. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp index 8baa2700..df0680d6 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp @@ -44,8 +44,8 @@ void ProjectCompilerWidget::refreshOptions() ui->tabOptions->resetUI(pSet,mOptions); - ui->chkStaticLink->setChecked(pSet->staticLink()); - ui->chkAddCharset->setChecked(pSet->autoAddCharsetParams()); + ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink); + ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset); QByteArray execEncoding = pMainWindow->project()->options().execEncoding; if (execEncoding == ENCODING_AUTO_DETECT From e78799f5610c04c609efc89f29ff6a45fbeb6c96 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 21:37:44 +0800 Subject: [PATCH 13/15] fix: -stack-protect default to Normal --- RedPandaIDE/compiler/compilerinfo.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RedPandaIDE/compiler/compilerinfo.cpp b/RedPandaIDE/compiler/compilerinfo.cpp index 0e326989..4de787f0 100644 --- a/RedPandaIDE/compiler/compilerinfo.cpp +++ b/RedPandaIDE/compiler/compilerinfo.cpp @@ -173,10 +173,11 @@ void CompilerInfo::prepareCompilerOptions() addOption(CC_CMD_OPT_WARNING_AS_ERROR, QObject::tr("Make all warnings into errors (-Werror)"), groupName, true, true, false, "-Werror"); addOption(CC_CMD_OPT_ABORT_ON_ERROR , QObject::tr("Abort compilation on first error (-Wfatal-errors)"), groupName, true, true, false, "-Wfatal-errors"); sl.clear(); - sl.append(QPair("Normal","")); - sl.append(QPair("Strong","-strong")); - sl.append(QPair("All","-all")); - addOption(CC_CMD_OPT_STACK_PROTECTOR , QObject::tr("Check for stack smashing attacks (-fstack-protector)"), groupName, false, false, true, "-fstack-protector", CompilerOptionType::Choice, sl); + sl.append(QPair("Normal","protector")); + sl.append(QPair("Explicit","protector-explicit")); + sl.append(QPair("Strong","protector-strong")); + sl.append(QPair("All","protector-all")); + addOption(CC_CMD_OPT_STACK_PROTECTOR , QObject::tr("Check for stack smashing attacks (-fstack-protector)"), groupName, false, false, true, "-fstack-", CompilerOptionType::Choice, sl); sl.clear(); sl.append(QPair("Address","address")); sl.append(QPair("Hwaddress","hwaddress")); From e184466fda44af661e3c09a44e5b9ac3a0f45808 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 14 Apr 2024 21:51:28 +0800 Subject: [PATCH 14/15] fix: options not correctly inited when project compiler set changed. --- .../settingsdialog/projectcompilerwidget.cpp | 19 ++++++++++++++----- .../settingsdialog/projectcompilerwidget.h | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp index df0680d6..79dca66e 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp @@ -44,10 +44,10 @@ void ProjectCompilerWidget::refreshOptions() ui->tabOptions->resetUI(pSet,mOptions); - ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink); - ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset); + ui->chkStaticLink->setChecked(mStaticLink); + ui->chkAddCharset->setChecked(mAddCharset); - QByteArray execEncoding = pMainWindow->project()->options().execEncoding; + QByteArray execEncoding = mExecCharset; if (execEncoding == ENCODING_AUTO_DETECT || execEncoding == ENCODING_SYSTEM_DEFAULT || execEncoding == ENCODING_UTF8) { @@ -75,11 +75,12 @@ void ProjectCompilerWidget::doLoad() Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex()); if (mOptions.isEmpty() && pSet) mOptions = pSet->compileOptions(); + mStaticLink = pMainWindow->project()->options().staticLink; + mAddCharset = pMainWindow->project()->options().addCharset; + mExecCharset = pMainWindow->project()->options().execEncoding; ui->cbCompilerSet->blockSignals(true); ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet); ui->cbCompilerSet->blockSignals(false); - ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset); - ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink); refreshOptions(); } @@ -99,6 +100,10 @@ void ProjectCompilerWidget::doSave() } else { pMainWindow->project()->options().execEncoding = ui->cbEncoding->currentData().toString().toLocal8Bit(); } + mOptions = pMainWindow->project()->options().compilerOptions; + mStaticLink = pMainWindow->project()->options().staticLink; + mAddCharset = pMainWindow->project()->options().addCharset; + mExecCharset = pMainWindow->project()->options().execEncoding; pMainWindow->project()->saveOptions(); } @@ -169,6 +174,10 @@ void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int index) return; } mOptions = pSet->compileOptions(); + mStaticLink = pSet->staticLink(); + mAddCharset = pSet->autoAddCharsetParams(); + mExecCharset = pSet->execCharset().toUtf8(); + setSettingsChanged(); //project->saveOptions(); } diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.h b/RedPandaIDE/settingsdialog/projectcompilerwidget.h index eb831e19..3a52b880 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.h +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.h @@ -37,6 +37,9 @@ private: private: Ui::ProjectCompilerWidget *ui; QMap mOptions; + bool mStaticLink; + bool mAddCharset; + QByteArray mExecCharset; // SettingsWidget interface protected: From 0662c59e9102c6db1193a9f4afc5785c1a6bb895 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 15 Apr 2024 10:56:18 +0800 Subject: [PATCH 15/15] fix: line break not correctly displayed. --- libs/qsynedit/qsynedit/painter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/qsynedit/qsynedit/painter.cpp b/libs/qsynedit/qsynedit/painter.cpp index 5ace509d..94ea053a 100644 --- a/libs/qsynedit/qsynedit/painter.cpp +++ b/libs/qsynedit/qsynedit/painter.cpp @@ -1125,7 +1125,6 @@ void QSynEditPainter::paintLines() if (mIsCurrentLine && mEdit->mInputPreeditString.length()>0) { int startPos = mEdit->mSyntaxer->getTokenPos()+1; int endPos = mEdit->mSyntaxer->getTokenPos() + sToken.length(); - //qDebug()<mCaretX<<":"<mCaretX+edit->mInputPreeditString.length(); if (!(endPos < mEdit->mCaretX || startPos >= mEdit->mCaretX+mEdit->mInputPreeditString.length())) { if (!preeditAttr) { @@ -1200,7 +1199,7 @@ void QSynEditPainter::paintLines() glyphStartCharList, oldLen, sLine.length(), - calculateGlyphPositions, + true, glyphStartPositionsList, tokenWidth); tokenLeft += tokenWidth;