diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-06 11:37:03 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-06 11:37:03 +0100 |
commit | 2ad0ec325a00628eed113984e03cd6a222acfe5a (patch) | |
tree | 74d2c991f419f38e77e525206bf1d34c9b9e14c5 /AK | |
parent | 1c8f01773059cd858dba76983a6fb721faa515fd (diff) | |
download | serenity-2ad0ec325a00628eed113984e03cd6a222acfe5a.zip |
AK: Get rid of TStyle (output styling helper for LogStream)
This didn't end up getting used, so let's get rid of it.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/LogStream.cpp | 20 | ||||
-rw-r--r-- | AK/LogStream.h | 54 | ||||
-rw-r--r-- | AK/TestSuite.h | 2 |
3 files changed, 2 insertions, 74 deletions
diff --git a/AK/LogStream.cpp b/AK/LogStream.cpp index 0d92bea067..cf093b0dfa 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 ff685caa5c..55f7132278 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<int> 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 478b18b652..ed1a3e27fa 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) |