bool CommentBraceCheck(int pos)
{
if (scintilla.GetStyleAt(pos) != 1)
{
return false;
}
int startPos, endPos;
for (startPos = scintilla.PositionBefore(pos); ;
startPos = scintilla.PositionBefore(startPos))
{
if (scintilla.GetStyleAt(startPos) != 1)
{
startPos = scintilla.PositionAfter(startPos);
break;
}
if (startPos == 0)
{
break;
}
}
startPos = scintilla.PositionAfter(startPos);
startPos = scintilla.PositionAfter(startPos);
for (endPos = pos; ; )
{
int oldEndPos = endPos;
endPos = scintilla.PositionAfter(endPos);
if (scintilla.GetStyleAt(endPos) != 1)
{
endPos = scintilla.PositionBefore(endPos);
break;
}
}
int eqs = 0;
int checkEqPos;
for (checkEqPos = scintilla.PositionAfter(startPos);
scintilla.GetCharAt(checkEqPos) == '=';
checkEqPos = scintilla.PositionAfter(checkEqPos))
{
eqs++;
}
int matchEqs = 0;
for (checkEqPos = scintilla.PositionBefore(endPos);
scintilla.GetCharAt(checkEqPos) == '=';
checkEqPos = scintilla.PositionBefore(checkEqPos))
{
matchEqs++;
}
if (scintilla.GetCharAt(endPos) != ']' || eqs != matchEqs || scintilla.GetCharAt(checkEqPos) != ']')
{
if (pos < startPos || pos > (startPos + eqs + 1))
{
return false;
}
scintilla.BraceBadLight(startPos);
return true;
}
if (pos >= startPos && pos <= (startPos + eqs + 1)
|| pos <= endPos && pos >= (endPos - eqs - 1))
{
scintilla.BraceHighlight(startPos, endPos);
return true;
}
return false;
}