diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-07-15 20:11:47 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-07-15 20:11:47 +0100 |
| commit | 032b6211503bb0491e4df38e7f62437a1f35b6d0 (patch) | |
| tree | 9b99c7184bcbfba47fa5f2e7828a6a747e6fcc9f /src/face.hh | |
| parent | e6699c66ede2d482fe2a6d16c3367913c5116dad (diff) | |
Use strongly typed enum for Face Attribute, add Dim
Diffstat (limited to 'src/face.hh')
| -rw-r--r-- | src/face.hh | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/face.hh b/src/face.hh index 1914ff7b..00bb4e08 100644 --- a/src/face.hh +++ b/src/face.hh @@ -6,16 +6,36 @@ namespace Kakoune { -using Attribute = char; -enum Attributes -{ - Normal = 0, - Underline = 1, - Reverse = 2, - Blink = 4, - Bold = 8 +enum class Attribute : int +{ + Normal = 0, + Underline = 1 << 1, + Reverse = 1 << 2, + Blink = 1 << 3, + Bold = 1 << 4, + Dim = 1 << 5 }; +inline constexpr Attribute operator|(Attribute lhs, Attribute rhs) +{ + return (Attribute)((int) lhs | (int) rhs); +} + +inline Attribute& operator|=(Attribute& lhs, Attribute rhs) +{ + return (Attribute&)((int&) lhs |= (int) rhs); +} + +inline constexpr bool operator&(Attribute lhs, Attribute rhs) +{ + return ((int) lhs & (int) rhs) != 0; +} + +inline Attribute& operator&=(Attribute& lhs, Attribute rhs) +{ + return (Attribute&)((int&) lhs &= (int) rhs); +} + struct Face { Color fg; @@ -23,7 +43,7 @@ struct Face Attribute attributes; Face(Color fg = Colors::Default, Color bg = Colors::Default, - Attribute attributes = 0) + Attribute attributes = Attribute::Normal) : fg{fg}, bg{bg}, attributes{attributes} {} }; |
