- fix: editor folder process error
- add: function tooltip
This commit is contained in:
parent
6065c2d24f
commit
842e1f6cbd
|
@ -79,11 +79,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
|
|||
editor.highlighter()->resetState();
|
||||
} else {
|
||||
editor.highlighter()->setState(
|
||||
editor.lines()->ranges(posY-1),
|
||||
editor.lines()->braceLevels(posY-1),
|
||||
editor.lines()->bracketLevels(posY-1),
|
||||
editor.lines()->parenthesisLevels(posY-1)
|
||||
);
|
||||
editor.lines()->ranges(posY-1));
|
||||
}
|
||||
editor.highlighter()->setLine(line,posY);
|
||||
while (!editor.highlighter()->eol()) {
|
||||
|
|
|
@ -343,10 +343,7 @@ bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token,
|
|||
if (PosY == 0) {
|
||||
mHighlighter->resetState();
|
||||
} else {
|
||||
mHighlighter->setState(mLines->ranges(PosY-1),
|
||||
mLines->braceLevels(PosY-1),
|
||||
mLines->bracketLevels(PosY-1),
|
||||
mLines->parenthesisLevels(PosY-1));
|
||||
mHighlighter->setState(mLines->ranges(PosY-1));
|
||||
}
|
||||
mHighlighter->setLine(Line, PosY);
|
||||
PosX = XY.Char;
|
||||
|
@ -384,10 +381,7 @@ bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &XY, QString &Toke
|
|||
if (PosY == 0) {
|
||||
mHighlighter->resetState();
|
||||
} else {
|
||||
mHighlighter->setState(mLines->ranges(PosY-1),
|
||||
mLines->braceLevels(PosY-1),
|
||||
mLines->bracketLevels(PosY-1),
|
||||
mLines->parenthesisLevels(PosY-1));
|
||||
mHighlighter->setState(mLines->ranges(PosY-1));
|
||||
}
|
||||
mHighlighter->setLine(Line, PosY);
|
||||
PosX = XY.Char;
|
||||
|
@ -2858,7 +2852,7 @@ void SynEdit::updateModifiedStatus()
|
|||
setModified(!mUndoList->initialState());
|
||||
}
|
||||
|
||||
int SynEdit::scanFrom(int Index)
|
||||
int SynEdit::scanFrom(int Index, int canStopIndex)
|
||||
{
|
||||
SynRangeState iRange;
|
||||
int Result = Index;
|
||||
|
@ -2868,27 +2862,18 @@ int SynEdit::scanFrom(int Index)
|
|||
if (Result == 0) {
|
||||
mHighlighter->resetState();
|
||||
} else {
|
||||
mHighlighter->setState(mLines->ranges(Result-1),
|
||||
mLines->braceLevels(Result-1),
|
||||
mLines->bracketLevels(Result-1),
|
||||
mLines->parenthesisLevels(Result-1));
|
||||
mHighlighter->setState(mLines->ranges(Result-1));
|
||||
}
|
||||
do {
|
||||
mHighlighter->setLine(mLines->getString(Result), Result);
|
||||
mHighlighter->nextToEol();
|
||||
iRange = mHighlighter->getRangeState();
|
||||
{
|
||||
if (Result > canStopIndex){
|
||||
if (mLines->ranges(Result).state == iRange.state
|
||||
&& mLines->braceLevels(Result) == mHighlighter->getBraceLevel()
|
||||
&& mLines->bracketLevels(Result) == mHighlighter->getBracketLevel()
|
||||
&& mLines->parenthesisLevels(Result) == mHighlighter->getParenthesisLevel()
|
||||
)
|
||||
return Result;// avoid the final Decrement
|
||||
}
|
||||
mLines->setRange(Result,iRange);
|
||||
mLines->setParenthesisLevel(Result,mHighlighter->getParenthesisLevel());
|
||||
mLines->setBraceLevel(Result,mHighlighter->getBraceLevel());
|
||||
mLines->setBracketLevel(Result,mHighlighter->getBracketLevel());
|
||||
Result ++ ;
|
||||
} while (Result < mLines->count());
|
||||
Result--;
|
||||
|
@ -2903,9 +2888,6 @@ void SynEdit::scanRanges()
|
|||
mHighlighter->setLine(mLines->getString(i), i);
|
||||
mHighlighter->nextToEol();
|
||||
mLines->setRange(i, mHighlighter->getRangeState());
|
||||
mLines->setParenthesisLevel(i, mHighlighter->getParenthesisLevel());
|
||||
mLines->setBracketLevel(i, mHighlighter->getBracketLevel());
|
||||
mLines->setBraceLevel(i, mHighlighter->getBraceLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3067,7 +3049,6 @@ void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,P
|
|||
QString CurLine;
|
||||
bool useBraces = ( mCodeFolding.foldRegions.get(FoldIndex)->openSymbol == "{"
|
||||
&& mCodeFolding.foldRegions.get(FoldIndex)->closeSymbol == "}");
|
||||
int lastBraceLevel = 0;
|
||||
|
||||
if (!mHighlighter)
|
||||
return;
|
||||
|
@ -3083,21 +3064,8 @@ void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,P
|
|||
if (useBraces) {
|
||||
// Find an opening character on this line
|
||||
CurLine = mLines->getString(Line);
|
||||
|
||||
int curBraceLevel = mLines->braceLevels(Line);
|
||||
if (curBraceLevel > lastBraceLevel) {
|
||||
for (int i=0; i<curBraceLevel-lastBraceLevel;i++) {
|
||||
// Add it to the top list of folds
|
||||
Parent = parentFoldRanges->addByParts(
|
||||
Parent,
|
||||
TopFoldRanges,
|
||||
Line + 1,
|
||||
mCodeFolding.foldRegions.get(FoldIndex),
|
||||
Line + 1);
|
||||
parentFoldRanges = Parent->subFoldRanges;
|
||||
}
|
||||
} else if (curBraceLevel < lastBraceLevel) {
|
||||
for (int i=0; i<lastBraceLevel-curBraceLevel;i++) {
|
||||
if (mLines->rightBraces(Line)>0) {
|
||||
for (int i=0; i<mLines->rightBraces(Line);i++) {
|
||||
// Stop the recursion if we find a closing char, and return to our parent
|
||||
if (Parent) {
|
||||
Parent->toLine = Line + 1;
|
||||
|
@ -3110,16 +3078,24 @@ void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,P
|
|||
}
|
||||
}
|
||||
}
|
||||
lastBraceLevel = curBraceLevel;
|
||||
if (mLines->leftBraces(Line)>0) {
|
||||
for (int i=0; i<mLines->leftBraces(Line);i++) {
|
||||
// Add it to the top list of folds
|
||||
Parent = parentFoldRanges->addByParts(
|
||||
Parent,
|
||||
TopFoldRanges,
|
||||
Line + 1,
|
||||
mCodeFolding.foldRegions.get(FoldIndex),
|
||||
Line + 1);
|
||||
parentFoldRanges = Parent->subFoldRanges;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Find an opening character on this line
|
||||
CurLine = mLines->getString(Line);
|
||||
|
||||
mHighlighter->setState(mLines->ranges(Line),
|
||||
mLines->braceLevels(Line),
|
||||
mLines->bracketLevels(Line),
|
||||
mLines->parenthesisLevels(Line));
|
||||
mHighlighter->setState(mLines->ranges(Line));
|
||||
mHighlighter->setLine(CurLine,Line);
|
||||
|
||||
QString token;
|
||||
|
@ -5793,7 +5769,7 @@ void SynEdit::onLinesDeleted(int index, int count)
|
|||
if (mUseCodeFolding)
|
||||
foldOnListDeleted(index + 1, count);
|
||||
if (mHighlighter && mLines->count() > 0)
|
||||
scanFrom(index);
|
||||
scanFrom(index, index);
|
||||
invalidateLines(index + 1, INT_MAX);
|
||||
invalidateGutterLines(index + 1, INT_MAX);
|
||||
}
|
||||
|
@ -5803,21 +5779,21 @@ void SynEdit::onLinesInserted(int index, int count)
|
|||
if (mUseCodeFolding)
|
||||
foldOnListInserted(index + 1, count);
|
||||
if (mHighlighter && mLines->count() > 0) {
|
||||
int vLastScan = index;
|
||||
do {
|
||||
vLastScan = scanFrom(vLastScan);
|
||||
vLastScan++;
|
||||
} while (vLastScan < index + count) ;
|
||||
// int vLastScan = index;
|
||||
// do {
|
||||
scanFrom(index, index+count);
|
||||
// vLastScan++;
|
||||
// } while (vLastScan < index + count) ;
|
||||
}
|
||||
invalidateLines(index + 1, INT_MAX);
|
||||
invalidateGutterLines(index + 1, INT_MAX);
|
||||
}
|
||||
|
||||
void SynEdit::onLinesPutted(int index, int)
|
||||
void SynEdit::onLinesPutted(int index, int count)
|
||||
{
|
||||
int vEndLine = index + 1;
|
||||
if (mHighlighter) {
|
||||
vEndLine = std::max(vEndLine, scanFrom(index) + 1);
|
||||
vEndLine = std::max(vEndLine, scanFrom(index, index+count) + 1);
|
||||
// If this editor is chained then the real owner of text buffer will probably
|
||||
// have already parsed the changes, so ScanFrom will return immediately.
|
||||
if (mLines != mOrigLines)
|
||||
|
|
|
@ -446,7 +446,7 @@ private:
|
|||
void recalcCharExtent();
|
||||
QString expandAtWideGlyphs(const QString& S);
|
||||
void updateModifiedStatus();
|
||||
int scanFrom(int Index);
|
||||
int scanFrom(int Index, int canStopIndex);
|
||||
void scanRanges();
|
||||
void uncollapse(PSynEditFoldRange FoldRange);
|
||||
void collapse(PSynEditFoldRange FoldRange);
|
||||
|
|
|
@ -27,7 +27,7 @@ static void ListIndexOutOfBounds(int index) {
|
|||
int SynEditStringList::parenthesisLevels(int Index)
|
||||
{
|
||||
if (Index>=0 && Index < mList.size()) {
|
||||
return mList[Index]->fParenthesisLevel;
|
||||
return mList[Index]->fRange.parenthesisLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ int SynEditStringList::parenthesisLevels(int Index)
|
|||
int SynEditStringList::bracketLevels(int Index)
|
||||
{
|
||||
if (Index>=0 && Index < mList.size()) {
|
||||
return mList[Index]->fBracketLevel;
|
||||
return mList[Index]->fRange.bracketLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ int SynEditStringList::bracketLevels(int Index)
|
|||
int SynEditStringList::braceLevels(int Index)
|
||||
{
|
||||
if (Index>=0 && Index < mList.size()) {
|
||||
return mList[Index]->fBraceLevel;
|
||||
return mList[Index]->fRange.braceLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -70,6 +70,22 @@ int SynEditStringList::lineColumns(int Index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SynEditStringList::leftBraces(int Index)
|
||||
{
|
||||
if (Index>=0 && Index < mList.size()) {
|
||||
return mList[Index]->fRange.leftBraces;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SynEditStringList::rightBraces(int Index)
|
||||
{
|
||||
if (Index>=0 && Index < mList.size()) {
|
||||
return mList[Index]->fRange.rightBraces;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SynEditStringList::lengthOfLongestLine()
|
||||
{
|
||||
if (mIndexOfLongestLine < 0) {
|
||||
|
@ -104,12 +120,14 @@ QString SynEditStringList::lineBreak()
|
|||
return "\n";
|
||||
}
|
||||
|
||||
SynRangeState SynEditStringList::ranges(int Index)
|
||||
const SynRangeState& SynEditStringList::ranges(int Index)
|
||||
{
|
||||
if (Index>=0 && Index < mList.size()) {
|
||||
return mList[Index]->fRange;
|
||||
} else
|
||||
return {0,0};
|
||||
} else {
|
||||
ListIndexOutOfBounds(Index);
|
||||
}
|
||||
return {0};
|
||||
}
|
||||
|
||||
void SynEditStringList::InsertItem(int Index, const QString &s)
|
||||
|
@ -147,7 +165,7 @@ void SynEditStringList::setAppendNewLineAtEOF(bool appendNewLineAtEOF)
|
|||
mAppendNewLineAtEOF = appendNewLineAtEOF;
|
||||
}
|
||||
|
||||
void SynEditStringList::setRange(int Index, SynRangeState ARange)
|
||||
void SynEditStringList::setRange(int Index, const SynRangeState& ARange)
|
||||
{
|
||||
if (Index<0 || Index>=mList.count()) {
|
||||
ListIndexOutOfBounds(Index);
|
||||
|
@ -157,36 +175,6 @@ void SynEditStringList::setRange(int Index, SynRangeState ARange)
|
|||
endUpdate();
|
||||
}
|
||||
|
||||
void SynEditStringList::setParenthesisLevel(int Index, int level)
|
||||
{
|
||||
if (Index<0 || Index>=mList.count()) {
|
||||
ListIndexOutOfBounds(Index);
|
||||
}
|
||||
beginUpdate();
|
||||
mList[Index]->fParenthesisLevel = level;
|
||||
endUpdate();
|
||||
}
|
||||
|
||||
void SynEditStringList::setBracketLevel(int Index, int level)
|
||||
{
|
||||
if (Index<0 || Index>=mList.count()) {
|
||||
ListIndexOutOfBounds(Index);
|
||||
}
|
||||
beginUpdate();
|
||||
mList[Index]->fBracketLevel = level;
|
||||
endUpdate();
|
||||
}
|
||||
|
||||
void SynEditStringList::setBraceLevel(int Index, int level)
|
||||
{
|
||||
if (Index<0 || Index>=mList.count()) {
|
||||
ListIndexOutOfBounds(Index);
|
||||
}
|
||||
beginUpdate();
|
||||
mList[Index]->fBraceLevel = level;
|
||||
endUpdate();
|
||||
}
|
||||
|
||||
QString SynEditStringList::getString(int Index)
|
||||
{
|
||||
if (Index<0 || Index>=mList.count()) {
|
||||
|
@ -687,11 +675,8 @@ void SynEditStringList::invalidAllLineColumns()
|
|||
SynEditStringRec::SynEditStringRec():
|
||||
fString(),
|
||||
fObject(nullptr),
|
||||
fRange{0,0},
|
||||
fColumns(-1),
|
||||
fParenthesisLevel(0),
|
||||
fBracketLevel(0),
|
||||
fBraceLevel(0)
|
||||
fRange{0,0,0,0,0,0,0},
|
||||
fColumns(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@ struct SynEditStringRec {
|
|||
void * fObject;
|
||||
SynRangeState fRange;
|
||||
int fColumns; //
|
||||
int fParenthesisLevel;
|
||||
int fBracketLevel;
|
||||
int fBraceLevel;
|
||||
|
||||
public:
|
||||
explicit SynEditStringRec();
|
||||
|
@ -55,13 +52,12 @@ public:
|
|||
int bracketLevels(int Index);
|
||||
int braceLevels(int Index);
|
||||
int lineColumns(int Index);
|
||||
int leftBraces(int Index);
|
||||
int rightBraces(int Index);
|
||||
int lengthOfLongestLine();
|
||||
QString lineBreak();
|
||||
SynRangeState ranges(int Index);
|
||||
void setRange(int Index, SynRangeState ARange);
|
||||
void setParenthesisLevel(int Index, int level);
|
||||
void setBracketLevel(int Index, int level);
|
||||
void setBraceLevel(int Index, int level);
|
||||
const SynRangeState& ranges(int Index);
|
||||
void setRange(int Index, const SynRangeState& ARange);
|
||||
QString getString(int Index);
|
||||
int count();
|
||||
void* getObject(int Index);
|
||||
|
|
|
@ -821,11 +821,7 @@ void SynEditTextPainter::PaintLines()
|
|||
edit->mHighlighter->resetState();
|
||||
} else {
|
||||
edit->mHighlighter->setState(
|
||||
edit->mLines->ranges(vLine-2),
|
||||
edit->mLines->braceLevels(vLine-2),
|
||||
edit->mLines->bracketLevels(vLine-2),
|
||||
edit->mLines->parenthesisLevels(vLine-2)
|
||||
);
|
||||
edit->mLines->ranges(vLine-2));
|
||||
}
|
||||
edit->mHighlighter->setLine(sLine, vLine - 1);
|
||||
// Try to concatenate as many tokens as possible to minimize the count
|
||||
|
@ -860,17 +856,17 @@ void SynEditTextPainter::PaintLines()
|
|||
// It's at least partially visible. Get the token attributes now.
|
||||
attr = edit->mHighlighter->getTokenAttribute();
|
||||
if (sToken == "[") {
|
||||
GetBraceColorAttr(edit->mHighlighter->getBracketLevel(),attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().bracketLevel,attr);
|
||||
} else if (sToken == "]") {
|
||||
GetBraceColorAttr(edit->mHighlighter->getBracketLevel()+1,attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().bracketLevel+1,attr);
|
||||
} else if (sToken == "(") {
|
||||
GetBraceColorAttr(edit->mHighlighter->getParenthesisLevel(),attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().parenthesisLevel,attr);
|
||||
} else if (sToken == ")") {
|
||||
GetBraceColorAttr(edit->mHighlighter->getParenthesisLevel()+1,attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().parenthesisLevel+1,attr);
|
||||
} else if (sToken == "{") {
|
||||
GetBraceColorAttr(edit->mHighlighter->getBraceLevel(),attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel,attr);
|
||||
} else if (sToken == "}") {
|
||||
GetBraceColorAttr(edit->mHighlighter->getBraceLevel()+1,attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel+1,attr);
|
||||
}
|
||||
AddHighlightToken(sToken, nTokenColumnsBefore - (vFirstChar - FirstCol),
|
||||
nTokenColumnLen, vLine,attr);
|
||||
|
@ -908,7 +904,7 @@ void SynEditTextPainter::PaintLines()
|
|||
sFold = " ... } ";
|
||||
nFold = edit->stringColumns(sFold,edit->mLines->lineColumns(vLine-1));
|
||||
attr = edit->mHighlighter->symbolAttribute();
|
||||
GetBraceColorAttr(edit->mHighlighter->getBraceLevel(),attr);
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel,attr);
|
||||
AddHighlightToken(sFold,edit->mLines->lineColumns(vLine-1)+1 - (vFirstChar - FirstCol)
|
||||
, nFold, vLine, attr);
|
||||
}
|
||||
|
|
|
@ -63,10 +63,7 @@ void SynExporter::ExportRange(PSynEditStringList ALines, BufferCoord Start, Buff
|
|||
if (Start.Line == 1)
|
||||
mHighlighter->resetState();
|
||||
else
|
||||
mHighlighter->setState(ALines->ranges(Start.Line-2),
|
||||
ALines->braceLevels(Start.Line-2),
|
||||
ALines->bracketLevels(Start.Line-2),
|
||||
ALines->parenthesisLevels(Start.Line-2));
|
||||
mHighlighter->setState(ALines->ranges(Start.Line-2));
|
||||
for (int i = Start.Line; i<=Stop.Line; i++) {
|
||||
QString Line = ALines->getString(i-1);
|
||||
// order is important, since Start.Y might be equal to Stop.Y
|
||||
|
|
|
@ -373,10 +373,10 @@ bool SynEditASMHighlighter::isLastLineStringNotFinished(int state) const
|
|||
|
||||
SynRangeState SynEditASMHighlighter::getRangeState() const
|
||||
{
|
||||
return {0,0};
|
||||
return {0,0,0,0,0,0,0};
|
||||
}
|
||||
|
||||
void SynEditASMHighlighter::setState(SynRangeState , int , int , int)
|
||||
void SynEditASMHighlighter::setState(const SynRangeState&)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
bool isLastLineCommentNotFinished(int state) const override;
|
||||
bool isLastLineStringNotFinished(int state) const override;
|
||||
SynRangeState getRangeState() const override;
|
||||
void setState(SynRangeState rangeState, int braceLevel, int bracketLevel, int parenthesisLevel) override;
|
||||
void setState(const SynRangeState& rangeState) override;
|
||||
void resetState() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,21 +48,6 @@ PSynHighlighterAttribute SynHighlighter::symbolAttribute() const
|
|||
return mSymbolAttribute;
|
||||
}
|
||||
|
||||
int SynHighlighter::getBraceLevel() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SynHighlighter::getBracketLevel() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SynHighlighter::getParenthesisLevel() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SynHighlighterTokenType SynHighlighter::getTokenType()
|
||||
{
|
||||
return SynHighlighterTokenType::Default;
|
||||
|
@ -223,3 +208,14 @@ SynHighlighterAttribute::SynHighlighterAttribute(const QString &name):
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
bool SynRangeState::operator==(const SynRangeState &s2)
|
||||
{
|
||||
return (state == s2.state)
|
||||
&& (spaceState == s2.spaceState)
|
||||
&& (braceLevel == s2.braceLevel)
|
||||
&& (bracketLevel == s2.bracketLevel)
|
||||
&& (parenthesisLevel == s2.parenthesisLevel)
|
||||
&& (leftBraces == s2.leftBraces)
|
||||
&& (rightBraces == s2.rightBraces);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,16 @@
|
|||
#include <QVector>
|
||||
#include "../Types.h"
|
||||
|
||||
typedef struct {
|
||||
struct SynRangeState {
|
||||
int state;
|
||||
int spaceState;
|
||||
} SynRangeState;
|
||||
int braceLevel;
|
||||
int bracketLevel;
|
||||
int parenthesisLevel;
|
||||
int leftBraces;
|
||||
int rightBraces;
|
||||
bool operator==(const SynRangeState& s2);
|
||||
};
|
||||
|
||||
typedef int SynTokenKind;
|
||||
|
||||
|
@ -92,9 +98,6 @@ public:
|
|||
virtual bool isLastLineStringNotFinished(int state) const = 0;
|
||||
virtual bool eol() const = 0;
|
||||
virtual SynRangeState getRangeState() const = 0;
|
||||
virtual int getBraceLevel() const;
|
||||
virtual int getBracketLevel() const;
|
||||
virtual int getParenthesisLevel() const;
|
||||
virtual QString getToken() const=0;
|
||||
virtual PSynHighlighterAttribute getTokenAttribute() const=0;
|
||||
virtual SynHighlighterTokenType getTokenType();
|
||||
|
@ -103,7 +106,7 @@ public:
|
|||
virtual bool isKeyword(const QString& word);
|
||||
virtual void next() = 0;
|
||||
virtual void nextToEol();
|
||||
virtual void setState(SynRangeState rangeState, int braceLevel, int bracketLevel, int parenthesisLevel) = 0;
|
||||
virtual void setState(const SynRangeState& rangeState) = 0;
|
||||
virtual void setLine(const QString& newLine, int lineNumber) = 0;
|
||||
virtual void resetState() = 0;
|
||||
|
||||
|
|
|
@ -155,9 +155,11 @@ SynEditCppHighlighter::SynEditCppHighlighter(): SynHighlighter()
|
|||
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
mRange.spaceState = RangeState::rsUnknown;
|
||||
mParenthesisLevel = 0;
|
||||
mBracketLevel = 0;
|
||||
mBraceLevel = 0;
|
||||
mRange.braceLevel = 0;
|
||||
mRange.bracketLevel = 0;
|
||||
mRange.parenthesisLevel = 0;
|
||||
mRange.leftBraces = 0;
|
||||
mRange.rightBraces = 0;
|
||||
mAsmStart = false;
|
||||
}
|
||||
|
||||
|
@ -364,7 +366,13 @@ void SynEditCppHighlighter::braceCloseProc()
|
|||
if (mRange.state == RangeState::rsAsmBlock) {
|
||||
mRange.state = rsUnknown;
|
||||
}
|
||||
mBraceLevel -= 1;
|
||||
|
||||
mRange.braceLevel -= 1;
|
||||
if (mRange.leftBraces<=mRange.rightBraces) {
|
||||
mRange.rightBraces++ ;
|
||||
} else {
|
||||
mRange.leftBraces--;
|
||||
}
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::braceOpenProc()
|
||||
|
@ -376,7 +384,8 @@ void SynEditCppHighlighter::braceOpenProc()
|
|||
mRange.state = RangeState::rsAsmBlock;
|
||||
mAsmStart = true;
|
||||
}
|
||||
mBraceLevel += 1;
|
||||
mRange.braceLevel += 1;
|
||||
mRange.leftBraces++;
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::colonProc()
|
||||
|
@ -876,7 +885,7 @@ void SynEditCppHighlighter::roundCloseProc()
|
|||
mRun += 1;
|
||||
mTokenId = TokenKind::Symbol;
|
||||
mExtTokenId = ExtTokenKind::RoundClose;
|
||||
mParenthesisLevel -= 1;
|
||||
mRange.parenthesisLevel--;
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::roundOpenProc()
|
||||
|
@ -884,7 +893,7 @@ void SynEditCppHighlighter::roundOpenProc()
|
|||
mRun += 1;
|
||||
mTokenId = TokenKind::Symbol;
|
||||
mExtTokenId = ExtTokenKind::RoundOpen;
|
||||
mParenthesisLevel += 1;
|
||||
mRange.parenthesisLevel++;
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::semiColonProc()
|
||||
|
@ -946,7 +955,7 @@ void SynEditCppHighlighter::squareCloseProc()
|
|||
mRun+=1;
|
||||
mTokenId = TokenKind::Symbol;
|
||||
mExtTokenId = ExtTokenKind::SquareClose;
|
||||
mBracketLevel+=1;
|
||||
mRange.bracketLevel--;
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::squareOpenProc()
|
||||
|
@ -954,7 +963,7 @@ void SynEditCppHighlighter::squareOpenProc()
|
|||
mRun+=1;
|
||||
mTokenId = TokenKind::Symbol;
|
||||
mExtTokenId = ExtTokenKind::SquareOpen;
|
||||
mBracketLevel +=1;
|
||||
mRange.bracketLevel++;
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::starProc()
|
||||
|
@ -1470,24 +1479,11 @@ void SynEditCppHighlighter::setLine(const QString &newLine, int lineNumber)
|
|||
mLine = mLineString.data();
|
||||
mLineNumber = lineNumber;
|
||||
mRun = 0;
|
||||
mRange.leftBraces = 0;
|
||||
mRange.rightBraces = 0;
|
||||
next();
|
||||
}
|
||||
|
||||
int SynEditCppHighlighter::getBraceLevel() const
|
||||
{
|
||||
return mBraceLevel;
|
||||
}
|
||||
|
||||
int SynEditCppHighlighter::getBracketLevel() const
|
||||
{
|
||||
return mBracketLevel;
|
||||
}
|
||||
|
||||
int SynEditCppHighlighter::getParenthesisLevel() const
|
||||
{
|
||||
return mParenthesisLevel;
|
||||
}
|
||||
|
||||
bool SynEditCppHighlighter::isKeyword(const QString &word)
|
||||
{
|
||||
return Keywords.contains(word);
|
||||
|
@ -1545,21 +1541,22 @@ SynHighlighterTokenType SynEditCppHighlighter::getTokenType()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::setState(SynRangeState rangeState, int braceLevel, int bracketLevel, int parenthesisLevel)
|
||||
void SynEditCppHighlighter::setState(const SynRangeState& rangeState)
|
||||
{
|
||||
mRange = rangeState;
|
||||
mBraceLevel = braceLevel;
|
||||
mBracketLevel = bracketLevel;
|
||||
mParenthesisLevel = parenthesisLevel;
|
||||
mRange.leftBraces = 0;
|
||||
mRange.rightBraces = 0;
|
||||
}
|
||||
|
||||
void SynEditCppHighlighter::resetState()
|
||||
{
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
mRange.spaceState = RangeState::rsUnknown;
|
||||
mBracketLevel = 0;
|
||||
mBraceLevel = 0;
|
||||
mParenthesisLevel = 0;
|
||||
mRange.braceLevel = 0;
|
||||
mRange.bracketLevel = 0;
|
||||
mRange.parenthesisLevel = 0;
|
||||
mRange.leftBraces = 0;
|
||||
mRange.rightBraces = 0;
|
||||
}
|
||||
|
||||
SynHighlighterClass SynEditCppHighlighter::getClass() const
|
||||
|
|
|
@ -130,9 +130,6 @@ private:
|
|||
bool mAsmStart;
|
||||
SynRangeState mRange;
|
||||
// SynRangeState mSpaceRange;
|
||||
int mParenthesisLevel;
|
||||
int mBracketLevel;
|
||||
int mBraceLevel;
|
||||
QString mLineString;
|
||||
QChar* mLine;
|
||||
int mLineSize;
|
||||
|
@ -173,12 +170,9 @@ public:
|
|||
int getTokenPos() override;
|
||||
void next() override;
|
||||
void setLine(const QString &newLine, int lineNumber) override;
|
||||
int getBraceLevel() const override;
|
||||
int getBracketLevel() const override;
|
||||
int getParenthesisLevel() const override;
|
||||
bool isKeyword(const QString &word) override;
|
||||
SynHighlighterTokenType getTokenType() override;
|
||||
void setState(SynRangeState rangeState, int braceLevel, int bracketLevel, int parenthesisLevel) override;
|
||||
void setState(const SynRangeState& rangeState) override;
|
||||
void resetState() override;
|
||||
SynHighlighterClass getClass() const override;
|
||||
QString getName() const override;
|
||||
|
|
|
@ -66,10 +66,10 @@ void FunctionTooltipWidget::setIndex(int newIndex)
|
|||
mIndex = newIndex;
|
||||
}
|
||||
|
||||
QStringList FunctionTooltipWidget::splitArgs(const QString &argStr)
|
||||
QStringList FunctionTooltipWidget::splitArgs(QString argStr)
|
||||
{
|
||||
int i = 0;
|
||||
// Split up argument string by ,
|
||||
int i;
|
||||
if (argStr.startsWith('(')) {
|
||||
i = 1; // assume it starts with ( and ends with )
|
||||
} else {
|
||||
|
@ -79,51 +79,18 @@ QStringList FunctionTooltipWidget::splitArgs(const QString &argStr)
|
|||
|
||||
QStringList result;
|
||||
while (i < argStr.length()) {
|
||||
if ((argStr[i] == ',') ||
|
||||
((i == argStr.length()-1) && (argStr[i] == ')'))) {
|
||||
if ((argStr[i] == ',')) {
|
||||
// We've found "int* a" for example
|
||||
QString s = argStr.mid(paramStart,i-paramStart);
|
||||
|
||||
//remove default value
|
||||
int assignPos = s.indexOf('=');
|
||||
if (assignPos >= 0) {
|
||||
s.truncate(assignPos);
|
||||
s = s.trimmed();
|
||||
}
|
||||
// we don't support function pointer parameters now, till we can tokenize function parameters
|
||||
// {
|
||||
// // Can be a function pointer. If so, scan after last )
|
||||
// BracePos := LastPos(')', S);
|
||||
// if (BracePos > 0) then // it's a function pointer... begin
|
||||
// SpacePos := LastPos(' ', Copy(S, BracePos, MaxInt)) // start search at brace
|
||||
// end else begin
|
||||
// }
|
||||
int spacePos = s.lastIndexOf(' '); // Cut up at last space
|
||||
if (spacePos >= 0) {
|
||||
args = "";
|
||||
int bracketPos = s.indexOf('[');
|
||||
if (bracketPos >= 0) {
|
||||
args = s.mid(bracketPos);
|
||||
s.truncate(bracketPos);
|
||||
}
|
||||
addStatement(
|
||||
functionStatement,
|
||||
mCurrentFile,
|
||||
"", // do not override hint
|
||||
s.mid(0,spacePos), // 'int*'
|
||||
s.mid(spacePos+1), // a
|
||||
args,
|
||||
"",
|
||||
functionStatement->definitionLine,
|
||||
StatementKind::skParameter,
|
||||
StatementScope::ssLocal,
|
||||
StatementClassScope::scsNone,
|
||||
true,
|
||||
false);
|
||||
}
|
||||
result.append(s);
|
||||
paramStart = i + 1; // step over ,
|
||||
}
|
||||
i++;
|
||||
}
|
||||
QString s = argStr.mid(paramStart,i-paramStart);
|
||||
s=s.trimmed();
|
||||
if (!s.isEmpty()) {
|
||||
result.append(s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
void setIndex(int newIndex);
|
||||
signals:
|
||||
private:
|
||||
QStringList splitArgs(const QString& args);
|
||||
QStringList splitArgs(QString args);
|
||||
private:
|
||||
QLabel* mInfoLabel;
|
||||
QLabel* mTotalLabel;
|
||||
|
|
Loading…
Reference in New Issue