diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2022-03-17 23:14:50 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-18 11:29:43 +0100 |
commit | 913374163cfc42e6119f6cecb1142d7b2b5d3bba (patch) | |
tree | 5776872f2850ccc9d0a2983f35b7a038ccdd1d61 /Userland/Libraries/LibVT/Attribute.h | |
parent | 8601f74d5ffc7f675fe577d3849f6997f30005d6 (diff) | |
download | serenity-913374163cfc42e6119f6cecb1142d7b2b5d3bba.zip |
LibVT/Kernel: Make VT::Attribute::Flags enum class, use AK EnumBits
Noticed the TODO in `Attribute.h` and realized we have as solution
to this problem already. :^)
Diffstat (limited to 'Userland/Libraries/LibVT/Attribute.h')
-rw-r--r-- | Userland/Libraries/LibVT/Attribute.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibVT/Attribute.h b/Userland/Libraries/LibVT/Attribute.h index 5bc71531fe..684a403b3a 100644 --- a/Userland/Libraries/LibVT/Attribute.h +++ b/Userland/Libraries/LibVT/Attribute.h @@ -6,6 +6,7 @@ #pragma once +#include <AK/EnumBits.h> #include <AK/Noncopyable.h> #include <AK/Vector.h> #include <LibVT/Color.h> @@ -35,15 +36,12 @@ struct Attribute { Color foreground_color { default_foreground_color }; Color background_color { default_background_color }; - constexpr Color effective_background_color() const { return flags & Negative ? foreground_color : background_color; } - constexpr Color effective_foreground_color() const { return flags & Negative ? background_color : foreground_color; } - #ifndef KERNEL String href; String href_id; #endif - enum Flags : u8 { + enum class Flags : u8 { NoAttributes = 0x00, Bold = 0x01, Italic = 0x02, @@ -52,12 +50,14 @@ struct Attribute { Blink = 0x10, Touched = 0x20, }; + AK_ENUM_BITWISE_FRIEND_OPERATORS(Flags); + + constexpr Color effective_background_color() const { return has_flag(flags, Flags::Negative) ? foreground_color : background_color; } + constexpr Color effective_foreground_color() const { return has_flag(flags, Flags::Negative) ? background_color : foreground_color; } - constexpr bool is_untouched() const { return !(flags & Touched); } + constexpr bool is_untouched() const { return has_flag(flags, Flags::Touched); } - // TODO: it would be really nice if we had a helper for enums that - // exposed bit ops for class enums... - u8 flags { Flags::NoAttributes }; + Flags flags { Flags::NoAttributes }; constexpr bool operator==(const Attribute& other) const { |