From 89f8d9ae210e54fb3316ba1df802c2870a56e81f Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 13 Apr 2024 18:01:32 +0800 Subject: [PATCH] - 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;