forked from qt-creator/qt-creator
OutputFormatter: Re-add handling of stand-alone carriage return
Amends 054e7c2164
.
Change-Id: If8ee94c3377ff71c8b5d87d431d8b6a2c87bb6f6
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -108,8 +108,16 @@ QList<FormattedText> OutputFormatter::parseAnsi(const QString &text, const QText
|
|||||||
|
|
||||||
void OutputFormatter::append(const QString &text, const QTextCharFormat &format)
|
void OutputFormatter::append(const QString &text, const QTextCharFormat &format)
|
||||||
{
|
{
|
||||||
if (!text.isEmpty())
|
int startPos = 0;
|
||||||
d->cursor.insertText(text, format);
|
int crPos = -1;
|
||||||
|
while ((crPos = text.indexOf('\r', startPos)) >= 0) {
|
||||||
|
d->cursor.insertText(text.mid(startPos, crPos - startPos), format);
|
||||||
|
d->cursor.clearSelection();
|
||||||
|
d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
|
||||||
|
startPos = crPos + 1;
|
||||||
|
}
|
||||||
|
if (startPos < text.count())
|
||||||
|
d->cursor.insertText(text.mid(startPos), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCursor &OutputFormatter::cursor() const
|
QTextCursor &OutputFormatter::cursor() const
|
||||||
|
@@ -555,6 +555,7 @@ void Internal::CorePlugin::testOutputFormatter()
|
|||||||
"A next A\n"
|
"A next A\n"
|
||||||
"A end of next A\n"
|
"A end of next A\n"
|
||||||
" A trick\r\n"
|
" A trick\r\n"
|
||||||
|
"line with \r embedded carriage return\n"
|
||||||
"B to be handled by B\n";
|
"B to be handled by B\n";
|
||||||
const QString output =
|
const QString output =
|
||||||
"handled by B\n"
|
"handled by B\n"
|
||||||
@@ -566,6 +567,7 @@ void Internal::CorePlugin::testOutputFormatter()
|
|||||||
"handled by A\n"
|
"handled by A\n"
|
||||||
"handled by A\n"
|
"handled by A\n"
|
||||||
" A trick\n"
|
" A trick\n"
|
||||||
|
" embedded carriage return\n"
|
||||||
"handled by B\n";
|
"handled by B\n";
|
||||||
TestFormatterA formatterA;
|
TestFormatterA formatterA;
|
||||||
TestFormatterB formatterB;
|
TestFormatterB formatterB;
|
||||||
|
Reference in New Issue
Block a user