2013-03-25 23:35:59 +01:00
|
|
|
#include "color.hh"
|
|
|
|
|
|
|
|
#include "exception.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
Color str_to_color(const String& color)
|
|
|
|
{
|
|
|
|
if (color == "default") return Color::Default;
|
|
|
|
if (color == "black") return Color::Black;
|
|
|
|
if (color == "red") return Color::Red;
|
|
|
|
if (color == "green") return Color::Green;
|
|
|
|
if (color == "yellow") return Color::Yellow;
|
|
|
|
if (color == "blue") return Color::Blue;
|
|
|
|
if (color == "magenta") return Color::Magenta;
|
|
|
|
if (color == "cyan") return Color::Cyan;
|
|
|
|
if (color == "white") return Color::White;
|
|
|
|
throw runtime_error("Unable to parse color '" + color + "'");
|
|
|
|
return Color::Default;
|
|
|
|
}
|
|
|
|
|
|
|
|
String color_to_str(const Color& color)
|
|
|
|
{
|
|
|
|
switch (color)
|
|
|
|
{
|
|
|
|
case Color::Default: return "default";
|
|
|
|
case Color::Black: return "black";
|
|
|
|
case Color::Red: return "red";
|
|
|
|
case Color::Green: return "green";
|
|
|
|
case Color::Yellow: return "yellow";
|
|
|
|
case Color::Blue: return "blue";
|
|
|
|
case Color::Magenta: return "magenta";
|
|
|
|
case Color::Cyan: return "cyan";
|
|
|
|
case Color::White: return "white";
|
|
|
|
}
|
|
|
|
assert(false);
|
|
|
|
return "default";
|
|
|
|
}
|
|
|
|
|
2013-03-29 19:31:06 +01:00
|
|
|
String option_to_string(const Color& color)
|
|
|
|
{
|
|
|
|
return color_to_str(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void option_from_string(const String& str, Color& color)
|
|
|
|
{
|
|
|
|
color = str_to_color(str);
|
|
|
|
}
|
|
|
|
|
2013-03-25 23:35:59 +01:00
|
|
|
}
|