From 8aeb0e4b77a0f6905981df5f2d9c4622d55a12fb Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Wed, 15 Jul 2020 12:08:11 +1000 Subject: Feature [feature-requests:1368]. Add BraceMatchNext API. --- src/Document.cxx | 4 ++-- src/Document.h | 2 +- src/Editor.cxx | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Document.cxx b/src/Document.cxx index dcb26acdf..95792fa1f 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -2657,7 +2657,7 @@ static char BraceOpposite(char ch) noexcept { } // TODO: should be able to extend styled region to find matching brace -Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxReStyle*/) noexcept { +Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxReStyle*/, Sci::Position startPos, bool useStartPos) noexcept { const char chBrace = CharAt(position); const char chSeek = BraceOpposite(chBrace); if (chSeek == '\0') @@ -2667,7 +2667,7 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe if (chBrace == '(' || chBrace == '[' || chBrace == '{' || chBrace == '<') direction = 1; int depth = 1; - position = NextPosition(position, direction); + position = useStartPos ? startPos : NextPosition(position, direction); while ((position >= 0) && (position < LengthNoExcept())) { const char chAtPos = CharAt(position); const int styAtPos = StyleIndexAt(position); diff --git a/src/Document.h b/src/Document.h index 6e8507f04..37c37c4b8 100644 --- a/src/Document.h +++ b/src/Document.h @@ -501,7 +501,7 @@ public: Sci::Position ParaUp(Sci::Position pos) const; Sci::Position ParaDown(Sci::Position pos) const; int IndentSize() const noexcept { return actualIndentInChars; } - Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle) noexcept; + Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle, Sci::Position startPos, bool useStartPos) noexcept; private: void NotifyModifyAttempt(); diff --git a/src/Editor.cxx b/src/Editor.cxx index 45cc42804..28fa89120 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7646,7 +7646,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_BRACEMATCH: // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it - return pdoc->BraceMatch(static_cast(wParam), lParam); + return pdoc->BraceMatch(static_cast(wParam), lParam, 0, false); + + case SCI_BRACEMATCHNEXT: + return pdoc->BraceMatch(static_cast(wParam), 0, lParam, true); case SCI_GETVIEWEOL: return vs.viewEOL; -- cgit v1.2.3