forked from qt-creator/qt-creator
Utils: Remove the *SameLine OutputFormat enums
Presumably, they were intended for output that shouldn't get an automatic newline, but if there ever was such a thing as automatic newlines, it must have evaporated over time. All users of OutputFormatter provide a newline if they want one. Change-Id: Ibd219b7305fd503ce075d6f77930d2b538d5e2e8 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -35,8 +35,6 @@ enum OutputFormat
|
||||
DebugFormat,
|
||||
StdOutFormat,
|
||||
StdErrFormat,
|
||||
StdOutFormatSameLine,
|
||||
StdErrFormatSameLine,
|
||||
NumberOfFormats // Keep this entry last.
|
||||
};
|
||||
|
||||
|
@@ -144,26 +144,12 @@ void OutputFormatter::initFormats()
|
||||
return;
|
||||
|
||||
Theme *theme = creatorTheme();
|
||||
|
||||
// NormalMessageFormat
|
||||
d->formats[NormalMessageFormat].setForeground(theme->color(Theme::OutputPanes_NormalMessageTextColor));
|
||||
|
||||
// ErrorMessageFormat
|
||||
d->formats[ErrorMessageFormat].setForeground(theme->color(Theme::OutputPanes_ErrorMessageTextColor));
|
||||
|
||||
// LogMessageFormat
|
||||
d->formats[LogMessageFormat].setForeground(theme->color(Theme::OutputPanes_WarningMessageTextColor));
|
||||
|
||||
// StdOutFormat
|
||||
d->formats[StdOutFormat].setForeground(theme->color(Theme::OutputPanes_StdOutTextColor));
|
||||
d->formats[StdOutFormatSameLine] = d->formats[StdOutFormat];
|
||||
|
||||
// StdErrFormat
|
||||
d->formats[StdErrFormat].setForeground(theme->color(Theme::OutputPanes_StdErrTextColor));
|
||||
d->formats[StdErrFormatSameLine] = d->formats[StdErrFormat];
|
||||
|
||||
d->formats[DebugFormat].setForeground(theme->color(Theme::OutputPanes_DebugTextColor));
|
||||
|
||||
setBoldFontEnabled(d->boldFontEnabled);
|
||||
}
|
||||
|
||||
@@ -203,34 +189,7 @@ void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
|
||||
d->prependCarriageReturn = true;
|
||||
out.chop(1);
|
||||
}
|
||||
|
||||
if (format != StdOutFormatSameLine && format != StdErrFormatSameLine) {
|
||||
doAppendMessage(doNewlineEnforcement(out), format);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool enforceNewline = d->enforceNewline;
|
||||
d->enforceNewline = false;
|
||||
if (enforceNewline) {
|
||||
out.prepend('\n');
|
||||
} else {
|
||||
const int newline = out.indexOf('\n');
|
||||
plainTextEdit()->moveCursor(QTextCursor::End);
|
||||
if (newline != -1) {
|
||||
doAppendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText
|
||||
out = out.mid(newline);
|
||||
}
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
d->enforceNewline = true;
|
||||
} else {
|
||||
if (out.endsWith('\n')) {
|
||||
d->enforceNewline = true;
|
||||
out.chop(1);
|
||||
}
|
||||
doAppendMessage(out, format);
|
||||
}
|
||||
doAppendMessage(doNewlineEnforcement(out), format);
|
||||
}
|
||||
|
||||
QString OutputFormatter::doNewlineEnforcement(const QString &out)
|
||||
|
@@ -215,14 +215,14 @@ void AndroidRunner::qmlServerPortReady(Port port)
|
||||
void AndroidRunner::remoteOutput(const QString &output)
|
||||
{
|
||||
Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent);
|
||||
appendMessage(output, Utils::StdOutFormatSameLine);
|
||||
appendMessage(output, Utils::StdOutFormat);
|
||||
m_outputParser.processOutput(output);
|
||||
}
|
||||
|
||||
void AndroidRunner::remoteErrorOutput(const QString &output)
|
||||
{
|
||||
Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent);
|
||||
appendMessage(output, Utils::StdErrFormatSameLine);
|
||||
appendMessage(output, Utils::StdErrFormat);
|
||||
m_outputParser.processOutput(output);
|
||||
}
|
||||
|
||||
|
@@ -497,8 +497,8 @@ static void processOutput(TestOutputReader *outputreader, const QString &msg,
|
||||
{
|
||||
QByteArray message = msg.toUtf8();
|
||||
switch (format) {
|
||||
case Utils::OutputFormat::StdErrFormatSameLine:
|
||||
case Utils::OutputFormat::StdOutFormatSameLine:
|
||||
case Utils::OutputFormat::StdErrFormat:
|
||||
case Utils::OutputFormat::StdOutFormat:
|
||||
case Utils::OutputFormat::DebugFormat: {
|
||||
static const QByteArray gdbSpecialOut = "Qt: gdb: -nograb added to command-line options.\n"
|
||||
"\t Use the -dograb option to enforce grabbing.";
|
||||
@@ -507,7 +507,7 @@ static void processOutput(TestOutputReader *outputreader, const QString &msg,
|
||||
message.chop(1); // all messages have an additional \n at the end
|
||||
|
||||
for (auto line : message.split('\n')) {
|
||||
if (format == Utils::OutputFormat::StdOutFormatSameLine)
|
||||
if (format == Utils::OutputFormat::StdOutFormat)
|
||||
outputreader->processStdOutput(line);
|
||||
else
|
||||
outputreader->processStdError(line);
|
||||
|
@@ -1756,11 +1756,11 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c
|
||||
case AppOutput:
|
||||
case AppStuff:
|
||||
d->m_logWindow->showOutput(channel, msg);
|
||||
emit appendMessageRequested(msg, StdOutFormatSameLine, false);
|
||||
emit appendMessageRequested(msg, StdOutFormat, false);
|
||||
break;
|
||||
case AppError:
|
||||
d->m_logWindow->showOutput(channel, msg);
|
||||
emit appendMessageRequested(msg, StdErrFormatSameLine, false);
|
||||
emit appendMessageRequested(msg, StdErrFormat, false);
|
||||
break;
|
||||
default:
|
||||
d->m_logWindow->showOutput(channel, msg);
|
||||
|
@@ -128,14 +128,14 @@ public:
|
||||
{
|
||||
const QByteArray ba = m_proc.readAllStandardOutput();
|
||||
const QString msg = QString::fromLocal8Bit(ba, ba.length());
|
||||
m_runTool->appendMessage(msg, StdOutFormatSameLine);
|
||||
m_runTool->appendMessage(msg, StdOutFormat);
|
||||
}
|
||||
|
||||
void handleStandardError()
|
||||
{
|
||||
const QByteArray ba = m_proc.readAllStandardError();
|
||||
const QString msg = QString::fromLocal8Bit(ba, ba.length());
|
||||
m_runTool->appendMessage(msg, StdErrFormatSameLine);
|
||||
m_runTool->appendMessage(msg, StdErrFormat);
|
||||
}
|
||||
|
||||
void handleFinished()
|
||||
@@ -1025,10 +1025,10 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
|
||||
m_engine->showMessage(msg, channel, timeout);
|
||||
switch (channel) {
|
||||
case AppOutput:
|
||||
appendMessage(msg, StdOutFormatSameLine);
|
||||
appendMessage(msg, StdOutFormat);
|
||||
break;
|
||||
case AppError:
|
||||
appendMessage(msg, StdErrFormatSameLine);
|
||||
appendMessage(msg, StdErrFormat);
|
||||
break;
|
||||
case AppStuff:
|
||||
appendMessage(msg, DebugFormat);
|
||||
|
@@ -305,7 +305,7 @@ void ApplicationLauncherPrivate::readLocalStandardOutput()
|
||||
QByteArray data = m_guiProcess.readAllStandardOutput();
|
||||
QString msg = m_outputCodec->toUnicode(
|
||||
data.constData(), data.length(), &m_outputCodecState);
|
||||
emit q->appendMessage(msg, StdOutFormatSameLine, false);
|
||||
emit q->appendMessage(msg, StdOutFormat, false);
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::readLocalStandardError()
|
||||
@@ -313,7 +313,7 @@ void ApplicationLauncherPrivate::readLocalStandardError()
|
||||
QByteArray data = m_guiProcess.readAllStandardError();
|
||||
QString msg = m_outputCodec->toUnicode(
|
||||
data.constData(), data.length(), &m_errorCodecState);
|
||||
emit q->appendMessage(msg, StdErrFormatSameLine, false);
|
||||
emit q->appendMessage(msg, StdErrFormat, false);
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::cannotRetrieveLocalDebugOutput()
|
||||
|
@@ -1214,12 +1214,12 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::remoteStderr,
|
||||
this, [this](const QString &output) {
|
||||
appendMessage(output, Utils::StdErrFormatSameLine, false);
|
||||
appendMessage(output, Utils::StdErrFormat, false);
|
||||
});
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::remoteStdout,
|
||||
this, [this](const QString &output) {
|
||||
appendMessage(output, Utils::StdOutFormatSameLine, false);
|
||||
appendMessage(output, Utils::StdOutFormat, false);
|
||||
});
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::finished,
|
||||
|
@@ -73,8 +73,7 @@ public:
|
||||
private:
|
||||
void doAppendMessage(const QString &text, OutputFormat format) final
|
||||
{
|
||||
const bool isTrace = (format == StdErrFormat
|
||||
|| format == StdErrFormatSameLine)
|
||||
const bool isTrace = format == StdErrFormat
|
||||
&& (text.startsWith("Traceback (most recent call last):")
|
||||
|| text.startsWith("\nTraceback (most recent call last):"));
|
||||
|
||||
|
Reference in New Issue
Block a user