OutputFormatter: Simplify newline handling

There does not seem to be a reason to remove trailing newlines and re-
insert them on the next call. Presumably, this is related to historical
auto-newline magic.

Change-Id: If4dc8acf022d3895b41b887af25d63cca36bf8a4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2020-03-17 16:19:55 +01:00
parent 9348ac5fec
commit 34cf96d645
2 changed files with 1 additions and 21 deletions

View File

@@ -43,7 +43,6 @@ public:
QTextCursor cursor;
AnsiEscapeCodeHandler escapeCodeHandler;
bool boldFontEnabled = true;
bool enforceNewline = false;
bool prependCarriageReturn = false;
};
@@ -160,7 +159,6 @@ void OutputFormatter::handleLink(const QString &href)
void OutputFormatter::clear()
{
d->enforceNewline = false;
d->prependCarriageReturn = false;
}
@@ -189,23 +187,7 @@ void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
d->prependCarriageReturn = true;
out.chop(1);
}
doAppendMessage(doNewlineEnforcement(out), format);
}
QString OutputFormatter::doNewlineEnforcement(const QString &out)
{
QString s = out;
if (d->enforceNewline) {
s.prepend('\n');
d->enforceNewline = false;
}
if (s.endsWith('\n')) {
d->enforceNewline = true; // make appendOutputInline put in a newline next time
s.chop(1);
}
return s;
doAppendMessage(out, format);
}
} // namespace Utils

View File

@@ -72,8 +72,6 @@ protected:
QTextCursor &cursor() const;
private:
QString doNewlineEnforcement(const QString &out);
virtual void doAppendMessage(const QString &text, const QTextCharFormat &format);
Internal::OutputFormatterPrivate *d;
};