auto indents for comments
This commit is contained in:
parent
0985b6444b
commit
2008437342
|
@ -1638,11 +1638,12 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
|||
indentAdded = true;
|
||||
l = commentStartLine;
|
||||
} else {
|
||||
//add indent according to the beginning of the comment
|
||||
//indents according to the beginning of the comment and 2 additional space
|
||||
additionIndent = 0;
|
||||
int commentStartLine = findCommentStartLine(startLine-1);
|
||||
SynRangeState range;
|
||||
indentSpaces = leftSpaces(startLineText);
|
||||
range = mDocument->ranges(startLine-1);
|
||||
indentSpaces = leftSpaces(mDocument->getString(commentStartLine-1))+2;
|
||||
range = mDocument->ranges(commentStartLine-1);
|
||||
matchingIndents = range.matchingIndents;
|
||||
indentAdded = true;
|
||||
l = startLine;
|
||||
|
|
|
@ -1042,7 +1042,7 @@ void SynEditTextPainter::PaintLines()
|
|||
// Paint folding
|
||||
foldRange = edit->foldStartAtLine(vLine);
|
||||
if ((foldRange) && foldRange->collapsed) {
|
||||
sFold = " ... } ";
|
||||
sFold = edit->highlighter()->foldString();
|
||||
nFold = edit->stringColumns(sFold,edit->mDocument->lineColumns(vLine-1));
|
||||
attr = edit->mHighlighter->symbolAttribute();
|
||||
GetBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel,attr);
|
||||
|
|
|
@ -85,6 +85,11 @@ QSet<QString> SynHighlighter::keywords() const
|
|||
return QSet<QString>();
|
||||
}
|
||||
|
||||
QString SynHighlighter::foldString()
|
||||
{
|
||||
return " ... }";
|
||||
}
|
||||
|
||||
bool SynHighlighter::isSpaceChar(const QChar &ch)
|
||||
{
|
||||
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';
|
||||
|
|
|
@ -144,6 +144,8 @@ public:
|
|||
virtual QString languageName() = 0;
|
||||
virtual SynHighlighterLanguage language() = 0;
|
||||
|
||||
virtual QString foldString();
|
||||
|
||||
virtual bool isSpaceChar(const QChar& ch);
|
||||
virtual bool isWordBreakChar(const QChar& ch);
|
||||
bool enabled() const;
|
||||
|
|
|
@ -1687,3 +1687,8 @@ QSet<QString> SynEditCppHighlighter::keywords() const
|
|||
{
|
||||
return Keywords;
|
||||
}
|
||||
|
||||
QString SynEditCppHighlighter::foldString()
|
||||
{
|
||||
return "...}";
|
||||
}
|
||||
|
|
|
@ -213,6 +213,10 @@ public:
|
|||
// SynHighlighter interface
|
||||
public:
|
||||
QSet<QString> keywords() const override;
|
||||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
QString foldString() override;
|
||||
};
|
||||
|
||||
#endif // SYNEDITCPPHIGHLIGHTER_H
|
||||
|
|
Loading…
Reference in New Issue