2012-09-17 19:01:13 +02:00
|
|
|
#ifndef color_hh_INCLUDED
|
|
|
|
#define color_hh_INCLUDED
|
|
|
|
|
2013-03-25 23:35:59 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2012-09-17 19:01:13 +02:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-03-25 23:35:59 +01:00
|
|
|
class String;
|
|
|
|
|
2013-05-07 18:52:23 +02:00
|
|
|
enum class Colors : char
|
2012-09-17 19:01:13 +02:00
|
|
|
{
|
|
|
|
Default,
|
|
|
|
Black,
|
|
|
|
Red,
|
|
|
|
Green,
|
|
|
|
Yellow,
|
|
|
|
Blue,
|
|
|
|
Magenta,
|
|
|
|
Cyan,
|
2013-05-07 18:52:23 +02:00
|
|
|
White,
|
|
|
|
RGB,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
Colors color;
|
|
|
|
unsigned char r;
|
|
|
|
unsigned char g;
|
|
|
|
unsigned char b;
|
|
|
|
|
|
|
|
Color() : Color{Colors::Default} {}
|
|
|
|
Color(Colors c) : color{c}, r{0}, g{0}, b{0} {}
|
|
|
|
Color(unsigned char r, unsigned char g, unsigned char b)
|
|
|
|
: color{Colors::RGB}, r{r}, g{g}, b{b} {}
|
|
|
|
|
2013-07-26 00:26:43 +02:00
|
|
|
bool operator==(Color c) const
|
2013-05-07 18:52:23 +02:00
|
|
|
{ return color == c.color and r == c.r and g == c.g and b == c.b; }
|
2013-07-26 00:26:43 +02:00
|
|
|
bool operator!=(Color c) const
|
2013-05-07 18:52:23 +02:00
|
|
|
{ return color != c.color or r != c.r or g != c.g or b != c.b; }
|
2012-09-17 19:01:13 +02:00
|
|
|
};
|
|
|
|
|
2013-03-06 20:25:23 +01:00
|
|
|
using ColorPair = std::pair<Color, Color>;
|
|
|
|
|
2013-03-25 23:35:59 +01:00
|
|
|
Color str_to_color(const String& color);
|
2013-07-26 00:26:43 +02:00
|
|
|
String color_to_str(Color color);
|
2013-03-25 23:35:59 +01:00
|
|
|
|
2013-07-26 00:26:43 +02:00
|
|
|
String option_to_string(Color color);
|
2013-03-29 19:31:06 +01:00
|
|
|
void option_from_string(const String& str, Color& color);
|
|
|
|
|
2012-09-17 19:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // color_hh_INCLUDED
|