forked from qt-creator/qt-creator
Move some code from OutputWindow to OutputFormatter
That's where it belongs: The logic there is applicable to all output formatters, not just those used via an output window. Change-Id: Idf4ca8d22631ca96feb97553f28724c0275e0bf8 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -42,14 +42,14 @@ VcsOutputFormatter::VcsOutputFormatter() :
|
||||
{
|
||||
}
|
||||
|
||||
void VcsOutputFormatter::appendMessage(const QString &text, Utils::OutputFormat format)
|
||||
void VcsOutputFormatter::doAppendMessage(const QString &text, Utils::OutputFormat format)
|
||||
{
|
||||
QRegularExpressionMatchIterator it = m_regexp.globalMatch(text);
|
||||
int begin = 0;
|
||||
while (it.hasNext()) {
|
||||
const QRegularExpressionMatch match = it.next();
|
||||
const QTextCharFormat normalFormat = charFormat(format);
|
||||
OutputFormatter::appendMessage(text.mid(begin, match.capturedStart() - begin), format);
|
||||
OutputFormatter::doAppendMessage(text.mid(begin, match.capturedStart() - begin), format);
|
||||
QTextCursor tc = plainTextEdit()->textCursor();
|
||||
QStringView url = match.capturedView();
|
||||
begin = match.capturedEnd();
|
||||
@@ -61,7 +61,7 @@ void VcsOutputFormatter::appendMessage(const QString &text, Utils::OutputFormat
|
||||
tc.insertText(url.toString(), linkFormat(normalFormat, url.toString()));
|
||||
tc.movePosition(QTextCursor::End);
|
||||
}
|
||||
OutputFormatter::appendMessage(text.mid(begin), format);
|
||||
OutputFormatter::doAppendMessage(text.mid(begin), format);
|
||||
}
|
||||
|
||||
void VcsOutputFormatter::handleLink(const QString &href)
|
||||
|
||||
@@ -37,7 +37,7 @@ class VcsOutputFormatter : public Utils::OutputFormatter
|
||||
public:
|
||||
VcsOutputFormatter();
|
||||
~VcsOutputFormatter() override = default;
|
||||
void appendMessage(const QString &text, Utils::OutputFormat format) override;
|
||||
void doAppendMessage(const QString &text, Utils::OutputFormat format) override;
|
||||
void handleLink(const QString &href) override;
|
||||
void fillLinkContextMenu(QMenu *menu, const QString &workingDirectory, const QString &href);
|
||||
|
||||
|
||||
@@ -228,10 +228,7 @@ void OutputWindowPlainTextEdit::appendLines(const QString &s, const QString &rep
|
||||
|
||||
const int previousLineCount = document()->lineCount();
|
||||
|
||||
const QChar newLine('\n');
|
||||
const QChar lastChar = s.at(s.size() - 1);
|
||||
const bool appendNewline = (lastChar != '\r' && lastChar != newLine);
|
||||
m_formatter->appendMessage(appendNewline ? s + newLine : s, m_format);
|
||||
m_formatter->appendMessage(s, m_format);
|
||||
|
||||
// Scroll down
|
||||
moveCursor(QTextCursor::End);
|
||||
|
||||
Reference in New Issue
Block a user