diff --git a/RedPandaIDE/colorschemes/VS_Code.scheme b/RedPandaIDE/colorschemes/VS_Code.scheme index e6369033..dab90727 100644 --- a/RedPandaIDE/colorschemes/VS_Code.scheme +++ b/RedPandaIDE/colorschemes/VS_Code.scheme @@ -171,15 +171,15 @@ "foreground" : "#C0C0C0" }, "brace/parenthesis/bracket level 1" : { - "foreground" : "#569CD6" + "foreground" : "#569CD6" }, "brace/parenthesis/bracket level 2" : { "foreground" : "#D4D4D4" }, "brace/parenthesis/bracket level 3" : { - "foreground" : "#D69D85" + "foreground" : "#D69D85" }, "brace/parenthesis/bracket level 4" : { - "foreground" : "#DCDCAA" + "foreground" : "#4EC9B0" } } diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 453a88f5..8f15d0c7 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -2873,7 +2873,8 @@ int SynEdit::scanFrom(int Index, int canStopIndex) ) return Result;// avoid the final Decrement } - mLines->setRange(Result,iRange); + mLines->setRange(Result,iRange, mHighlighter->getLeftBraces(), + mHighlighter->getRightBraces()); Result ++ ; } while (Result < mLines->count()); Result--; @@ -2887,7 +2888,9 @@ void SynEdit::scanRanges() for (int i =0;icount();i++) { mHighlighter->setLine(mLines->getString(i), i); mHighlighter->nextToEol(); - mLines->setRange(i, mHighlighter->getRangeState()); + mLines->setRange(i, mHighlighter->getRangeState(), + mHighlighter->getLeftBraces(), + mHighlighter->getRightBraces()); } } } diff --git a/RedPandaIDE/qsynedit/TextBuffer.cpp b/RedPandaIDE/qsynedit/TextBuffer.cpp index f05f9ca7..0e20f76f 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.cpp +++ b/RedPandaIDE/qsynedit/TextBuffer.cpp @@ -73,7 +73,7 @@ int SynEditStringList::lineColumns(int Index) int SynEditStringList::leftBraces(int Index) { if (Index>=0 && Index < mList.size()) { - return mList[Index]->fRange.leftBraces; + return mList[Index]->fLeftBraces; } else return 0; } @@ -81,7 +81,7 @@ int SynEditStringList::leftBraces(int Index) int SynEditStringList::rightBraces(int Index) { if (Index>=0 && Index < mList.size()) { - return mList[Index]->fRange.rightBraces; + return mList[Index]->fRightBraces; } else return 0; } @@ -165,13 +165,15 @@ void SynEditStringList::setAppendNewLineAtEOF(bool appendNewLineAtEOF) mAppendNewLineAtEOF = appendNewLineAtEOF; } -void SynEditStringList::setRange(int Index, const SynRangeState& ARange) +void SynEditStringList::setRange(int Index, const SynRangeState& ARange, int ALeftBraces, int ARightBraces) { if (Index<0 || Index>=mList.count()) { ListIndexOutOfBounds(Index); } beginUpdate(); mList[Index]->fRange = ARange; + mList[Index]->fLeftBraces = ALeftBraces; + mList[Index]->fRightBraces = ARightBraces; endUpdate(); } @@ -675,7 +677,7 @@ void SynEditStringList::invalidAllLineColumns() SynEditStringRec::SynEditStringRec(): fString(), fObject(nullptr), - fRange{0,0,0,0,0,0,0}, + fRange{0,0,0,0,0}, fColumns(-1) { } diff --git a/RedPandaIDE/qsynedit/TextBuffer.h b/RedPandaIDE/qsynedit/TextBuffer.h index 90ef0f61..8304ada3 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.h +++ b/RedPandaIDE/qsynedit/TextBuffer.h @@ -21,6 +21,8 @@ struct SynEditStringRec { QString fString; void * fObject; SynRangeState fRange; + int fLeftBraces; + int fRightBraces; int fColumns; // public: @@ -57,7 +59,7 @@ public: int lengthOfLongestLine(); QString lineBreak(); const SynRangeState& ranges(int Index); - void setRange(int Index, const SynRangeState& ARange); + void setRange(int Index, const SynRangeState& ARange, int leftBraces, int rightBraces); QString getString(int Index); int count(); void* getObject(int Index); diff --git a/RedPandaIDE/qsynedit/highlighter/asm.cpp b/RedPandaIDE/qsynedit/highlighter/asm.cpp index 8b8d58cc..d5ca9f15 100644 --- a/RedPandaIDE/qsynedit/highlighter/asm.cpp +++ b/RedPandaIDE/qsynedit/highlighter/asm.cpp @@ -373,7 +373,7 @@ bool SynEditASMHighlighter::isLastLineStringNotFinished(int state) const SynRangeState SynEditASMHighlighter::getRangeState() const { - return {0,0,0,0,0,0,0}; + return {0,0,0,0,0}; } void SynEditASMHighlighter::setState(const SynRangeState&) diff --git a/RedPandaIDE/qsynedit/highlighter/base.cpp b/RedPandaIDE/qsynedit/highlighter/base.cpp index aadb56e7..ebe82037 100644 --- a/RedPandaIDE/qsynedit/highlighter/base.cpp +++ b/RedPandaIDE/qsynedit/highlighter/base.cpp @@ -64,6 +64,16 @@ void SynHighlighter::nextToEol() next(); } +int SynHighlighter::getLeftBraces() +{ + return 0; +} + +int SynHighlighter::getRightBraces() +{ + return 0; +} + bool SynHighlighter::isSpaceChar(const QChar &ch) { return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'; @@ -215,7 +225,5 @@ bool SynRangeState::operator==(const SynRangeState &s2) && (spaceState == s2.spaceState) && (braceLevel == s2.braceLevel) && (bracketLevel == s2.bracketLevel) - && (parenthesisLevel == s2.parenthesisLevel) - && (leftBraces == s2.leftBraces) - && (rightBraces == s2.rightBraces); + && (parenthesisLevel == s2.parenthesisLevel); } diff --git a/RedPandaIDE/qsynedit/highlighter/base.h b/RedPandaIDE/qsynedit/highlighter/base.h index 540e3779..66ee7ad6 100644 --- a/RedPandaIDE/qsynedit/highlighter/base.h +++ b/RedPandaIDE/qsynedit/highlighter/base.h @@ -16,8 +16,6 @@ struct SynRangeState { int braceLevel; int bracketLevel; int parenthesisLevel; - int leftBraces; - int rightBraces; bool operator==(const SynRangeState& s2); }; @@ -110,6 +108,9 @@ public: virtual void setLine(const QString& newLine, int lineNumber) = 0; virtual void resetState() = 0; + virtual int getLeftBraces(); + virtual int getRightBraces(); + virtual QString languageName() = 0; virtual SynHighlighterLanguage language() = 0; diff --git a/RedPandaIDE/qsynedit/highlighter/cpp.cpp b/RedPandaIDE/qsynedit/highlighter/cpp.cpp index 74c0343b..494b2247 100644 --- a/RedPandaIDE/qsynedit/highlighter/cpp.cpp +++ b/RedPandaIDE/qsynedit/highlighter/cpp.cpp @@ -158,8 +158,8 @@ SynEditCppHighlighter::SynEditCppHighlighter(): SynHighlighter() mRange.braceLevel = 0; mRange.bracketLevel = 0; mRange.parenthesisLevel = 0; - mRange.leftBraces = 0; - mRange.rightBraces = 0; + mLeftBraces = 0; + mRightBraces = 0; mAsmStart = false; } @@ -368,10 +368,10 @@ void SynEditCppHighlighter::braceCloseProc() } mRange.braceLevel -= 1; - if (mRange.leftBraces>0) { - mRange.leftBraces--; + if (mLeftBraces>0) { + mLeftBraces--; } else { - mRange.rightBraces++ ; + mRightBraces++ ; } } @@ -385,7 +385,7 @@ void SynEditCppHighlighter::braceOpenProc() mAsmStart = true; } mRange.braceLevel += 1; - mRange.leftBraces++; + mLeftBraces++; } void SynEditCppHighlighter::colonProc() @@ -1479,8 +1479,8 @@ void SynEditCppHighlighter::setLine(const QString &newLine, int lineNumber) mLine = mLineString.data(); mLineNumber = lineNumber; mRun = 0; - mRange.leftBraces = 0; - mRange.rightBraces = 0; + mLeftBraces = 0; + mRightBraces = 0; next(); } @@ -1544,8 +1544,6 @@ SynHighlighterTokenType SynEditCppHighlighter::getTokenType() void SynEditCppHighlighter::setState(const SynRangeState& rangeState) { mRange = rangeState; - mRange.leftBraces = 0; - mRange.rightBraces = 0; } void SynEditCppHighlighter::resetState() @@ -1555,8 +1553,6 @@ void SynEditCppHighlighter::resetState() mRange.braceLevel = 0; mRange.bracketLevel = 0; mRange.parenthesisLevel = 0; - mRange.leftBraces = 0; - mRange.rightBraces = 0; } SynHighlighterClass SynEditCppHighlighter::getClass() const @@ -1579,6 +1575,16 @@ SynHighlighterLanguage SynEditCppHighlighter::language() return SynHighlighterLanguage::Cpp; } +int SynEditCppHighlighter::getLeftBraces() +{ + return mLeftBraces; +} + +int SynEditCppHighlighter::getRightBraces() +{ + return mRightBraces; +} + SynRangeState SynEditCppHighlighter::getRangeState() const { return mRange; diff --git a/RedPandaIDE/qsynedit/highlighter/cpp.h b/RedPandaIDE/qsynedit/highlighter/cpp.h index 706b26b5..5f4c73b0 100644 --- a/RedPandaIDE/qsynedit/highlighter/cpp.h +++ b/RedPandaIDE/qsynedit/highlighter/cpp.h @@ -140,6 +140,8 @@ private: int mTokenId; ExtTokenKind mExtTokenId; int mLineNumber; + int mLeftBraces; + int mRightBraces; PSynHighlighterAttribute mAsmAttribute; PSynHighlighterAttribute mDirecAttribute; @@ -156,8 +158,6 @@ private: PSynHighlighterAttribute mGlobalVarAttribute; PSynHighlighterAttribute mLocalVarAttribute; - - // SynHighligterBase interface public: bool getTokenFinished() const override; @@ -180,6 +180,9 @@ public: QString languageName() override; SynHighlighterLanguage language() override; + int getLeftBraces() override; + int getRightBraces() override; + // SynHighlighter interface public: SynRangeState getRangeState() const override;