forked from qt-creator/qt-creator
CPlusPlus: Simplify MatchingText interface
Change-Id: I46878d9ca048d0c79032445f5adc27c12d27f30c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -102,7 +102,7 @@ bool MatchingText::shouldInsertMatchingText(QChar lookAhead)
|
||||
}
|
||||
|
||||
QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess,
|
||||
QChar la, int *skippedChars) const
|
||||
QChar la, int *skippedChars)
|
||||
{
|
||||
QTextCursor tc = cursor;
|
||||
QTextDocument *doc = tc.document();
|
||||
@@ -193,7 +193,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MatchingText::shouldInsertNewline(const QTextCursor &tc) const
|
||||
static bool shouldInsertNewline(const QTextCursor &tc)
|
||||
{
|
||||
QTextDocument *doc = tc.document();
|
||||
int pos = tc.selectionEnd();
|
||||
@@ -205,17 +205,14 @@ bool MatchingText::shouldInsertNewline(const QTextCursor &tc) const
|
||||
|
||||
if (! ch.isSpace())
|
||||
break;
|
||||
else if (ch == QChar::ParagraphSeparator)
|
||||
if (ch == QChar::ParagraphSeparator)
|
||||
++newlines;
|
||||
}
|
||||
|
||||
if (newlines <= 1 && doc->characterAt(pos) != QLatin1Char('}'))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return newlines <= 1 && doc->characterAt(pos) != QLatin1Char('}');
|
||||
}
|
||||
|
||||
QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const
|
||||
QString MatchingText::insertParagraphSeparator(const QTextCursor &tc)
|
||||
{
|
||||
BackwardsScanner tk(tc, MAX_NUM_LINES);
|
||||
int index = tk.startToken();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CPLUSPLUS_MATCHINGTEXT_H
|
||||
#define CPLUSPLUS_MATCHINGTEXT_H
|
||||
|
||||
@@ -42,12 +43,9 @@ public:
|
||||
static bool shouldInsertMatchingText(const QTextCursor &tc);
|
||||
static bool shouldInsertMatchingText(QChar lookAhead);
|
||||
|
||||
QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
|
||||
QChar la, int *skippedChars) const;
|
||||
QString insertParagraphSeparator(const QTextCursor &tc) const;
|
||||
|
||||
private:
|
||||
bool shouldInsertNewline(const QTextCursor &tc) const;
|
||||
static QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
|
||||
QChar la, int *skippedChars);
|
||||
static QString insertParagraphSeparator(const QTextCursor &tc);
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
Reference in New Issue
Block a user