From 2ad0ec325a00628eed113984e03cd6a222acfe5a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Nov 2019 11:37:03 +0100 Subject: [PATCH] AK: Get rid of TStyle (output styling helper for LogStream) This didn't end up getting used, so let's get rid of it. --- AK/LogStream.cpp | 20 +----------------- AK/LogStream.h | 54 ------------------------------------------------ AK/TestSuite.h | 2 +- 3 files changed, 2 insertions(+), 74 deletions(-) diff --git a/AK/LogStream.cpp b/AK/LogStream.cpp index 0d92bea0672..cf093b0dfa5 100644 --- a/AK/LogStream.cpp +++ b/AK/LogStream.cpp @@ -31,24 +31,6 @@ const LogStream& operator<<(const LogStream& stream, const void* value) return stream << String::format("%p", value); } -const LogStream& operator<<(const LogStream& stream, const TStyle& style) -{ - stream << "\033["; - - if (style.color() != TStyle::Color::NoColor) - stream << ((int)style.color() + 30) << (style.attributes() ? ";" : ""); - else - stream << '0'; - - if (style.attributes() & TStyle::Attribute::Bold) - stream << '1'; - - stream << 'm'; - - stream.m_needs_style_reset = true; - return stream; -} - #ifdef USERLAND static TriState got_process_name = TriState::Unknown; static char process_name_buffer[256]; @@ -65,7 +47,7 @@ DebugLogStream dbg() got_process_name = TriState::False; } if (got_process_name == TriState::True) - stream << TStyle(TStyle::Color::Brown, TStyle::Attribute::Bold) << process_name_buffer << '(' << getpid() << ")" << TStyle(TStyle::None) << ": "; + stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: "; #endif return stream; } diff --git a/AK/LogStream.h b/AK/LogStream.h index ff685caa5cf..55f71322784 100644 --- a/AK/LogStream.h +++ b/AK/LogStream.h @@ -14,52 +14,6 @@ namespace AK { class String; class StringView; -class TStyle { -public: - enum NoneTag { None }; - - enum Color { - Black = 0, - Red, - Green, - Brown, - Blue, - Magenta, - Cyan, - LightGray, - DarkGray, - BrightRed, - BrightGreen, - Yellow, - BrightBlue, - BrightMagenta, - BrightCyan, - White, - NoColor = 255, - }; - enum Attribute { - NoAttribute = 0, - Bold = 1, - }; - - TStyle() {} - TStyle(NoneTag) {} - TStyle(Color color, unsigned attributes = NoAttribute) - : m_color(color) - , m_attributes(attributes) - { - } - - ~TStyle() {} - - Color color() const { return m_color; } - unsigned attributes() const { return m_attributes; } - -private: - Color m_color { NoColor }; - unsigned m_attributes { NoAttribute }; -}; - class LogStream { public: LogStream() @@ -72,10 +26,6 @@ public: virtual void write(const char*, int) const = 0; -protected: - friend const LogStream& operator<<(const LogStream&, const TStyle&); - mutable bool m_needs_style_reset { false }; - private: #ifdef USERLAND ScopedValueRollback m_errno_restorer; @@ -87,8 +37,6 @@ public: DebugLogStream() {} virtual ~DebugLogStream() override { - if (m_needs_style_reset) - write("\033[0m", 4); char newline = '\n'; write(&newline, 1); } @@ -114,7 +62,6 @@ const LogStream& operator<<(const LogStream&, const StringView&); const LogStream& operator<<(const LogStream&, int); const LogStream& operator<<(const LogStream&, unsigned); const LogStream& operator<<(const LogStream&, const void*); -const LogStream& operator<<(const LogStream& stream, const TStyle&); inline const LogStream& operator<<(const LogStream& stream, char value) { @@ -133,4 +80,3 @@ DebugLogStream dbg(); using AK::dbg; using AK::LogStream; -using AK::TStyle; diff --git a/AK/TestSuite.h b/AK/TestSuite.h index 478b18b6529..ed1a3e27fa2 100644 --- a/AK/TestSuite.h +++ b/AK/TestSuite.h @@ -252,7 +252,7 @@ using AK::TestSuite; auto ___aev1 = one; \ auto ___aev2 = two; \ if (___aev1 != ___aev2) { \ - dbg() << TStyle(TStyle::Red, TStyle::Bold) << "FAIL" << TStyle() << ": " __FILE__ ":" << __LINE__ << ": assertEqual(" ___str(one) ", " ___str(two) ") failed"; \ + dbg() << "\033[31;1mFAIL\033[0m: " __FILE__ ":" << __LINE__ << ": assertEqual(" ___str(one) ", " ___str(two) ") failed"; \ } \ } while (0)