2014-07-11 01:27:04 +02:00
|
|
|
#ifndef face_hh_INCLUDED
|
|
|
|
#define face_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "color.hh"
|
2014-11-12 21:31:56 +01:00
|
|
|
#include "flags.hh"
|
2014-07-11 01:27:04 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-07-15 21:11:47 +02:00
|
|
|
enum class Attribute : int
|
|
|
|
{
|
|
|
|
Normal = 0,
|
2015-10-23 14:34:03 +02:00
|
|
|
Exclusive = 1 << 1,
|
|
|
|
Underline = 1 << 2,
|
|
|
|
Reverse = 1 << 3,
|
|
|
|
Blink = 1 << 4,
|
|
|
|
Bold = 1 << 5,
|
|
|
|
Dim = 1 << 6,
|
|
|
|
Italic = 1 << 7,
|
2014-07-11 01:27:04 +02:00
|
|
|
};
|
|
|
|
|
2017-03-15 18:55:34 +01:00
|
|
|
constexpr bool with_bit_ops(Meta::Type<Attribute>) { return true; }
|
2014-07-15 21:11:47 +02:00
|
|
|
|
2014-07-11 01:27:04 +02:00
|
|
|
struct Face
|
|
|
|
{
|
|
|
|
Color fg;
|
|
|
|
Color bg;
|
|
|
|
Attribute attributes;
|
|
|
|
|
2015-04-25 11:47:39 +02:00
|
|
|
constexpr Face(Color fg = Color::Default, Color bg = Color::Default,
|
2014-07-15 21:11:47 +02:00
|
|
|
Attribute attributes = Attribute::Normal)
|
2014-07-11 01:27:04 +02:00
|
|
|
: fg{fg}, bg{bg}, attributes{attributes} {}
|
|
|
|
};
|
|
|
|
|
2015-03-21 17:32:22 +01:00
|
|
|
constexpr bool operator==(const Face& lhs, const Face& rhs)
|
2014-07-11 01:27:04 +02:00
|
|
|
{
|
|
|
|
return lhs.fg == rhs.fg and
|
|
|
|
lhs.bg == rhs.bg and
|
|
|
|
lhs.attributes == rhs.attributes;
|
|
|
|
}
|
|
|
|
|
2015-03-21 17:32:22 +01:00
|
|
|
constexpr bool operator!=(const Face& lhs, const Face& rhs)
|
2014-07-11 01:27:04 +02:00
|
|
|
{
|
|
|
|
return not (lhs == rhs);
|
|
|
|
}
|
|
|
|
|
2015-08-23 13:13:14 +02:00
|
|
|
constexpr Face merge_faces(const Face& base, const Face& face)
|
|
|
|
{
|
2015-10-23 14:34:03 +02:00
|
|
|
return face.attributes & Attribute::Exclusive ?
|
|
|
|
face : Face{ face.fg == Color::Default ? base.fg : face.fg,
|
|
|
|
face.bg == Color::Default ? base.bg : face.bg,
|
|
|
|
face.attributes | base.attributes };
|
2015-08-23 13:13:14 +02:00
|
|
|
}
|
|
|
|
|
2014-07-11 01:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // face_hh_INCLUDED
|