diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 722b4886b56..a76ea49ea7d 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -151,7 +151,7 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) : m_cancelBuildButton(new QToolButton), m_zoomInButton(new QToolButton), m_zoomOutButton(new QToolButton), - m_escapeCodeHandler(new Utils::AnsiEscapeCodeHandler) + m_formatter(new Utils::OutputFormatter) { Core::Context context(C_COMPILE_OUTPUT); m_outputWindow = new CompileOutputTextEdit(context); @@ -160,6 +160,7 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) : m_outputWindow->setReadOnly(true); m_outputWindow->setUndoRedoEnabled(false); m_outputWindow->setMaxCharCount(Core::Constants::DEFAULT_MAX_CHAR_COUNT); + m_outputWindow->setFormatter(m_formatter); // Let selected text be colored as if the text edit was editable, // otherwise the highlight for searching is too light @@ -210,7 +211,7 @@ CompileOutputWindow::~CompileOutputWindow() delete m_cancelBuildButton; delete m_zoomInButton; delete m_zoomOutButton; - delete m_escapeCodeHandler; + delete m_formatter; } void CompileOutputWindow::updateZoomEnabled() @@ -256,31 +257,24 @@ QList CompileOutputWindow::toolBarWidgets() const void CompileOutputWindow::appendText(const QString &text, BuildStep::OutputFormat format) { - using Utils::Theme; - Theme *theme = Utils::creatorTheme(); - QTextCharFormat textFormat; + Utils::OutputFormat fmt = Utils::NormalMessageFormat; switch (format) { case BuildStep::OutputFormat::Stdout: - textFormat.setForeground(theme->color(Theme::TextColorNormal)); - textFormat.setFontWeight(QFont::Normal); + fmt = Utils::StdOutFormat; break; case BuildStep::OutputFormat::Stderr: - textFormat.setForeground(theme->color(Theme::OutputPanes_ErrorMessageTextColor)); - textFormat.setFontWeight(QFont::Normal); + fmt = Utils::StdErrFormat; break; case BuildStep::OutputFormat::NormalMessage: - textFormat.setForeground(theme->color(Theme::OutputPanes_MessageOutput)); + fmt = Utils::NormalMessageFormat; break; case BuildStep::OutputFormat::ErrorMessage: - textFormat.setForeground(theme->color(Theme::OutputPanes_ErrorMessageTextColor)); - textFormat.setFontWeight(QFont::Bold); + fmt = Utils::ErrorMessageFormat; break; } - foreach (const Utils::FormattedText &output, - m_escapeCodeHandler->parseText(Utils::FormattedText(text, textFormat))) - m_outputWindow->appendText(output.text, output.format); + m_outputWindow->appendMessage(text, fmt); } void CompileOutputWindow::clearContents() @@ -362,8 +356,7 @@ void CompileOutputWindow::showPositionOf(const Task &task) void CompileOutputWindow::flush() { - if (m_escapeCodeHandler) - m_escapeCodeHandler->endFormatScope(); + m_formatter->flush(); } #include "compileoutputwindow.moc" diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index 3e9e3b0b517..9ff9c8ac92e 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -37,7 +37,7 @@ class QTextCharFormat; class QToolButton; QT_END_NAMESPACE -namespace Utils { class AnsiEscapeCodeHandler; } +namespace Utils { class OutputFormatter; } namespace ProjectExplorer { @@ -91,7 +91,7 @@ private: QToolButton *m_cancelBuildButton; QToolButton *m_zoomInButton; QToolButton *m_zoomOutButton; - Utils::AnsiEscapeCodeHandler *m_escapeCodeHandler; + Utils::OutputFormatter *m_formatter; }; } // namespace Internal