diff --git a/src/color.rs b/src/color.rs index 8b13789..868773e 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1 +1,478 @@ +use std::convert::TryFrom; +use std::fmt::{self, Display}; +#[derive(Debug)] +pub enum Color { + AliceBlue, // = 0xF0F8FF, + AntiqueWhite, // = 0xFAEBD7, + Aqua, // = 0x00FFFF, + Aquamarine, // = 0x7FFFD4, + Azure, // = 0xF0FFFF, + Beige, // = 0xF5F5DC, + Bisque, // = 0xFFE4C4, + Black, // = 0x000000, + BlanchedAlmond, // = 0xFFEBCD, + Blue, // = 0x0000FF, + BlueViolet, // = 0x8A2BE2, + Brown, // = 0xA52A2A, + BurlyWood, // = 0xDEB887, + CadetBlue, // = 0x5F9EA0, + Chartreuse, // = 0x7FFF00, + Chocolate, // = 0xD2691E, + Coral, // = 0xFF7F50, + CornflowerBlue, // = 0x6495ED, + Cornsilk, // = 0xFFF8DC, + Crimson, // = 0xDC143C, + Cyan, // = 0x00FFFF + DarkBlue, // = 0x00008B, + DarkCyan, // = 0x008B8B, + DarkGoldenRod, // = 0xB8860B, + DarkGray, // = 0xA9A9A9, + DarkGrey, // = 0xA9A9A9 + DarkGreen, // = 0x006400, + DarkKhaki, // = 0xBDB76B, + DarkMagenta, // = 0x8B008B, + DarkOliveGreen, // = 0x556B2F, + DarkOrange, // = 0xFF8C00, + DarkOrchid, // = 0x9932CC, + DarkRed, // = 0x8B0000, + DarkSalmon, // = 0xE9967A, + DarkSeaGreen, // = 0x8FBC8F, + DarkSlateBlue, // = 0x483D8B, + DarkSlateGray, // = 0x2F4F4F, + DarkSlateGrey, // = 0x2F4F4F + DarkTurquoise, // = 0x00CED1, + DarkViolet, // = 0x9400D3, + DeepPink, // = 0xFF1493, + DeepSkyBlue, // = 0x00BFFF, + DimGray, // = 0x696969, + DimGrey, // = 0x696969 + DodgerBlue, // = 0x1E90FF, + FireBrick, // = 0xB22222, + FloralWhite, // = 0xFFFAF0, + ForestGreen, // = 0x228B22, + Fuchsia, // = 0xFF00FF, + Gainsboro, // = 0xDCDCDC, + GhostWhite, // = 0xF8F8FF, + Gold, // = 0xFFD700, + GoldenRod, // = 0xDAA520, + Gray, // = 0x808080, + Grey, // = 0x808080 + Green, // = 0x008000, + GreenYellow, // = 0xADFF2F, + HoneyDew, // = 0xF0FFF0, + HotPink, // = 0xFF69B4, + IndianRed, // = 0xCD5C5C, + Indigo, // = 0x4B0082, + Ivory, // = 0xFFFFF0, + Khaki, // = 0xF0E68C, + Lavender, // = 0xE6E6FA, + LavenderBlush, // = 0xFFF0F5, + LawnGreen, // = 0x7CFC00, + LemonChiffon, // = 0xFFFACD, + LightBlue, // = 0xADD8E6, + LightCoral, // = 0xF08080, + LightCyan, // = 0xE0FFFF, + LightGoldenRodYellow, // = 0xFAFAD2, + LightGray, // = 0xD3D3D3, + LightGrey, // = 0xD3D3D3 + LightGreen, // = 0x90EE90, + LightPink, // = 0xFFB6C1, + LightSalmon, // = 0xFFA07A, + LightSeaGreen, // = 0x20B2AA, + LightSkyBlue, // = 0x87CEFA, + LightSlateGray, // = 0x778899, + LightSlateGrey, // = 0x778899 + LightSteelBlue, // = 0xB0C4DE, + LightYellow, // = 0xFFFFE0, + Lime, // = 0x00FF00, + LimeGreen, // = 0x32CD32, + Linen, // = 0xFAF0E6, + Magenta, // = 0xFF00FF + Maroon, // = 0x800000, + MediumAquaMarine, // = 0x66CDAA, + MediumBlue, // = 0x0000CD, + MediumOrchid, // = 0xBA55D3, + MediumPurple, // = 0x9370DB, + MediumSeaGreen, // = 0x3CB371, + MediumSlateBlue, // = 0x7B68EE, + MediumSpringGreen, // = 0x00FA9A, + MediumTurquoise, // = 0x48D1CC, + MediumVioletRed, // = 0xC71585, + MidnightBlue, // = 0x191970, + MintCream, // = 0xF5FFFA, + MistyRose, // = 0xFFE4E1, + Moccasin, // = 0xFFE4B5, + NavajoWhite, // = 0xFFDEAD, + Navy, // = 0x000080, + OldLace, // = 0xFDF5E6, + Olive, // = 0x808000, + OliveDrab, // = 0x6B8E23, + Orange, // = 0xFFA500, + OrangeRed, // = 0xFF4500, + Orchid, // = 0xDA70D6, + PaleGoldenRod, // = 0xEEE8AA, + PaleGreen, // = 0x98FB98, + PaleTurquoise, // = 0xAFEEEE, + PaleVioletRed, // = 0xDB7093, + PapayaWhip, // = 0xFFEFD5, + PeachPuff, // = 0xFFDAB9, + Peru, // = 0xCD853F, + Pink, // = 0xFFC0CB, + Plum, // = 0xDDA0DD, + PowderBlue, // = 0xB0E0E6, + Purple, // = 0x800080, + RebeccaPurple, // = 0x663399, + Red, // = 0xFF0000, + RosyBrown, // = 0xBC8F8F, + RoyalBlue, // = 0x4169E1, + SaddleBrown, // = 0x8B4513, + Salmon, // = 0xFA8072, + SandyBrown, // = 0xF4A460, + SeaGreen, // = 0x2E8B57, + SeaShell, // = 0xFFF5EE, + Sienna, // = 0xA0522D, + Silver, // = 0xC0C0C0, + SkyBlue, // = 0x87CEEB, + SlateBlue, // = 0x6A5ACD, + SlateGray, // = 0x708090, + SlateGrey, // = 0x708090 + Snow, // = 0xFFFAFA, + SpringGreen, // = 0x00FF7F, + SteelBlue, // = 0x4682B4, + Tan, // = 0xD2B48C, + Teal, // = 0x008080, + Thistle, // = 0xD8BFD8, + Tomato, // = 0xFF6347, + Turquoise, // = 0x40E0D0, + Violet, // = 0xEE82EE, + Wheat, // = 0xF5DEB3, + White, // = 0xFFFFFF, + WhiteSmoke, // = 0xF5F5F5, + Yellow, // = 0xFFFF00, + YellowGreen, // = 0x9ACD32, + RGB(u8, u8, u8), + RGBA(u8, u8, u8, u8), +} + +impl fmt::UpperHex for Color { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::AliceBlue => write!(f, "#F0F8FF"), + Self::AntiqueWhite => write!(f, "#FAEBD7"), + Self::Aqua => write!(f, "#00FFFF"), + Self::Aquamarine => write!(f, "#7FFFD4"), + Self::Azure => write!(f, "#F0FFFF"), + Self::Beige => write!(f, "#F5F5DC"), + Self::Bisque => write!(f, "#FFE4C4"), + Self::Black => write!(f, "#000000"), + Self::BlanchedAlmond => write!(f, "#FFEBCD"), + Self::Blue => write!(f, "#0000FF"), + Self::BlueViolet => write!(f, "#8A2BE2"), + Self::Brown => write!(f, "#A52A2A"), + Self::BurlyWood => write!(f, "#DEB887"), + Self::CadetBlue => write!(f, "#5F9EA0"), + Self::Chartreuse => write!(f, "#7FFF00"), + Self::Chocolate => write!(f, "#D2691E"), + Self::Coral => write!(f, "#FF7F50"), + Self::CornflowerBlue => write!(f, "#6495ED"), + Self::Cornsilk => write!(f, "#FFF8DC"), + Self::Crimson => write!(f, "#DC143C"), + Self::Cyan => write!(f, "#00FFFF"), + Self::DarkBlue => write!(f, "#00008B"), + Self::DarkCyan => write!(f, "#008B8B"), + Self::DarkGoldenRod => write!(f, "#B8860B"), + Self::DarkGray => write!(f, "#A9A9A9"), + Self::DarkGrey => write!(f, "#A9A9A9"), + Self::DarkGreen => write!(f, "#006400"), + Self::DarkKhaki => write!(f, "#BDB76B"), + Self::DarkMagenta => write!(f, "#8B008B"), + Self::DarkOliveGreen => write!(f, "#556B2F"), + Self::DarkOrange => write!(f, "#FF8C00"), + Self::DarkOrchid => write!(f, "#9932CC"), + Self::DarkRed => write!(f, "#8B0000"), + Self::DarkSalmon => write!(f, "#E9967A"), + Self::DarkSeaGreen => write!(f, "#8FBC8F"), + Self::DarkSlateBlue => write!(f, "#483D8B"), + Self::DarkSlateGray => write!(f, "#2F4F4F"), + Self::DarkSlateGrey => write!(f, "#2F4F4F"), + Self::DarkTurquoise => write!(f, "#00CED1"), + Self::DarkViolet => write!(f, "#9400D3"), + Self::DeepPink => write!(f, "#FF1493"), + Self::DeepSkyBlue => write!(f, "#00BFFF"), + Self::DimGray => write!(f, "#696969"), + Self::DimGrey => write!(f, "#696969"), + Self::DodgerBlue => write!(f, "#1E90FF"), + Self::FireBrick => write!(f, "#B22222"), + Self::FloralWhite => write!(f, "#FFFAF0"), + Self::ForestGreen => write!(f, "#228B22"), + Self::Fuchsia => write!(f, "#FF00FF"), + Self::Gainsboro => write!(f, "#DCDCDC"), + Self::GhostWhite => write!(f, "#F8F8FF"), + Self::Gold => write!(f, "#FFD700"), + Self::GoldenRod => write!(f, "#DAA520"), + Self::Gray => write!(f, "#808080"), + Self::Grey => write!(f, "#808080"), + Self::Green => write!(f, "#008000"), + Self::GreenYellow => write!(f, "#ADFF2F"), + Self::HoneyDew => write!(f, "#F0FFF0"), + Self::HotPink => write!(f, "#FF69B4"), + Self::IndianRed => write!(f, "#CD5C5C"), + Self::Indigo => write!(f, "#4B0082"), + Self::Ivory => write!(f, "#FFFFF0"), + Self::Khaki => write!(f, "#F0E68C"), + Self::Lavender => write!(f, "#E6E6FA"), + Self::LavenderBlush => write!(f, "#FFF0F5"), + Self::LawnGreen => write!(f, "#7CFC00"), + Self::LemonChiffon => write!(f, "#FFFACD"), + Self::LightBlue => write!(f, "#ADD8E6"), + Self::LightCoral => write!(f, "#F08080"), + Self::LightCyan => write!(f, "#E0FFFF"), + Self::LightGoldenRodYellow => write!(f, "#FAFAD2"), + Self::LightGray => write!(f, "#D3D3D3"), + Self::LightGrey => write!(f, "#D3D3D3"), + Self::LightGreen => write!(f, "#90EE90"), + Self::LightPink => write!(f, "#FFB6C1"), + Self::LightSalmon => write!(f, "#FFA07A"), + Self::LightSeaGreen => write!(f, "#20B2AA"), + Self::LightSkyBlue => write!(f, "#87CEFA"), + Self::LightSlateGray => write!(f, "#778899"), + Self::LightSlateGrey => write!(f, "#778899"), + Self::LightSteelBlue => write!(f, "#B0C4DE"), + Self::LightYellow => write!(f, "#FFFFE0"), + Self::Lime => write!(f, "#00FF00"), + Self::LimeGreen => write!(f, "#32CD32"), + Self::Linen => write!(f, "#FAF0E6"), + Self::Magenta => write!(f, "#FF00FF"), + Self::Maroon => write!(f, "#800000"), + Self::MediumAquaMarine => write!(f, "#66CDAA"), + Self::MediumBlue => write!(f, "#0000CD"), + Self::MediumOrchid => write!(f, "#BA55D3"), + Self::MediumPurple => write!(f, "#9370DB"), + Self::MediumSeaGreen => write!(f, "#3CB371"), + Self::MediumSlateBlue => write!(f, "#7B68EE"), + Self::MediumSpringGreen => write!(f, "#00FA9A"), + Self::MediumTurquoise => write!(f, "#48D1CC"), + Self::MediumVioletRed => write!(f, "#C71585"), + Self::MidnightBlue => write!(f, "#191970"), + Self::MintCream => write!(f, "#F5FFFA"), + Self::MistyRose => write!(f, "#FFE4E1"), + Self::Moccasin => write!(f, "#FFE4B5"), + Self::NavajoWhite => write!(f, "#FFDEAD"), + Self::Navy => write!(f, "#000080"), + Self::OldLace => write!(f, "#FDF5E6"), + Self::Olive => write!(f, "#808000"), + Self::OliveDrab => write!(f, "#6B8E23"), + Self::Orange => write!(f, "#FFA500"), + Self::OrangeRed => write!(f, "#FF4500"), + Self::Orchid => write!(f, "#DA70D6"), + Self::PaleGoldenRod => write!(f, "#EEE8AA"), + Self::PaleGreen => write!(f, "#98FB98"), + Self::PaleTurquoise => write!(f, "#AFEEEE"), + Self::PaleVioletRed => write!(f, "#DB7093"), + Self::PapayaWhip => write!(f, "#FFEFD5"), + Self::PeachPuff => write!(f, "#FFDAB9"), + Self::Peru => write!(f, "#CD853F"), + Self::Pink => write!(f, "#FFC0CB"), + Self::Plum => write!(f, "#DDA0DD"), + Self::PowderBlue => write!(f, "#B0E0E6"), + Self::Purple => write!(f, "#800080"), + Self::RebeccaPurple => write!(f, "#663399"), + Self::Red => write!(f, "#FF0000"), + Self::RosyBrown => write!(f, "#BC8F8F"), + Self::RoyalBlue => write!(f, "#4169E1"), + Self::SaddleBrown => write!(f, "#8B4513"), + Self::Salmon => write!(f, "#FA8072"), + Self::SandyBrown => write!(f, "#F4A460"), + Self::SeaGreen => write!(f, "#2E8B57"), + Self::SeaShell => write!(f, "#FFF5EE"), + Self::Sienna => write!(f, "#A0522D"), + Self::Silver => write!(f, "#C0C0C0"), + Self::SkyBlue => write!(f, "#87CEEB"), + Self::SlateBlue => write!(f, "#6A5ACD"), + Self::SlateGray => write!(f, "#708090"), + Self::SlateGrey => write!(f, "#708090"), + Self::Snow => write!(f, "#FFFAFA"), + Self::SpringGreen => write!(f, "#00FF7F"), + Self::SteelBlue => write!(f, "#4682B4"), + Self::Tan => write!(f, "#D2B48C"), + Self::Teal => write!(f, "#008080"), + Self::Thistle => write!(f, "#D8BFD8"), + Self::Tomato => write!(f, "#FF6347"), + Self::Turquoise => write!(f, "#40E0D0"), + Self::Violet => write!(f, "#EE82EE"), + Self::Wheat => write!(f, "#F5DEB3"), + Self::White => write!(f, "#FFFFFF"), + Self::WhiteSmoke => write!(f, "#F5F5F5"), + Self::Yellow => write!(f, "#FFFF00"), + Self::YellowGreen => write!(f, "#9ACD32"), + Self::RGB(r, g, b) => write!(f, "#{:X}{:X}{:X}", r, g, b), + Self::RGBA(r, g, b, a) => write!(f, "#{:X}{:X}{:X}{:X}", r, g, b, a), + } + } +} + + +impl Display for Color { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:X}", self) + } +} + +impl TryFrom<&str> for Color { + type Error = &'static str; + + fn try_from(string: &str) -> Result { + match string { + "aliceblue" => Ok(Color::AliceBlue), + "antiquewhite" => Ok(Color::AntiqueWhite), + "aqua" => Ok(Color::Aqua), + "aquamarine" => Ok(Color::Aquamarine), + "azure" => Ok(Color::Azure), + "beige" => Ok(Color::Beige), + "bisque" => Ok(Color::Bisque), + "black" => Ok(Color::Black), + "blanchedalmond" => Ok(Color::BlanchedAlmond), + "blue" => Ok(Color::Blue), + "blueviolet" => Ok(Color::BlueViolet), + "brown" => Ok(Color::Brown), + "burlywood" => Ok(Color::BurlyWood), + "cadetblue" => Ok(Color::CadetBlue), + "chartreuse" => Ok(Color::Chartreuse), + "chocolate" => Ok(Color::Chocolate), + "coral" => Ok(Color::Coral), + "cornflowerblue" => Ok(Color::CornflowerBlue), + "cornsilk" => Ok(Color::Cornsilk), + "crimson" => Ok(Color::Crimson), + "cyan" => Ok(Color::Cyan), + "darkblue" => Ok(Color::DarkBlue), + "darkcyan" => Ok(Color::DarkCyan), + "darkgoldenrod" => Ok(Color::DarkGoldenRod), + "darkgray" => Ok(Color::DarkGray), + "darkgrey" => Ok(Color::DarkGrey), + "darkgreen" => Ok(Color::DarkGreen), + "darkkhaki" => Ok(Color::DarkKhaki), + "darkmagenta" => Ok(Color::DarkMagenta), + "darkolivegreen" => Ok(Color::DarkOliveGreen), + "darkorange" => Ok(Color::DarkOrange), + "darkorchid" => Ok(Color::DarkOrchid), + "darkred" => Ok(Color::DarkRed), + "darksalmon" => Ok(Color::DarkSalmon), + "darkseagreen" => Ok(Color::DarkSeaGreen), + "darkslateblue" => Ok(Color::DarkSlateBlue), + "darkslategray" => Ok(Color::DarkSlateGray), + "darkslategrey" => Ok(Color::DarkSlateGrey), + "darkturquoise" => Ok(Color::DarkTurquoise), + "darkviolet" => Ok(Color::DarkViolet), + "deeppink" => Ok(Color::DeepPink), + "deepskyblue" => Ok(Color::DeepSkyBlue), + "dimgray" => Ok(Color::DimGray), + "dimgrey" => Ok(Color::DimGrey), + "dodgerblue" => Ok(Color::DodgerBlue), + "firebrick" => Ok(Color::FireBrick), + "floralwhite" => Ok(Color::FloralWhite), + "forestgreen" => Ok(Color::ForestGreen), + "fuchsia" => Ok(Color::Fuchsia), + "gainsboro" => Ok(Color::Gainsboro), + "ghostwhite" => Ok(Color::GhostWhite), + "gold" => Ok(Color::Gold), + "goldenrod" => Ok(Color::GoldenRod), + "gray" => Ok(Color::Gray), + "grey" => Ok(Color::Grey), + "green" => Ok(Color::Green), + "greenyellow" => Ok(Color::GreenYellow), + "honeydew" => Ok(Color::HoneyDew), + "hotpink" => Ok(Color::HotPink), + "indianred" => Ok(Color::IndianRed), + "indigo" => Ok(Color::Indigo), + "ivory" => Ok(Color::Ivory), + "khaki" => Ok(Color::Khaki), + "lavender" => Ok(Color::Lavender), + "lavenderblush" => Ok(Color::LavenderBlush), + "lawngreen" => Ok(Color::LawnGreen), + "lemonchiffon" => Ok(Color::LemonChiffon), + "lightblue" => Ok(Color::LightBlue), + "lightcoral" => Ok(Color::LightCoral), + "lightcyan" => Ok(Color::LightCyan), + "lightgoldenrodyellow" => Ok(Color::LightGoldenRodYellow), + "lightgray" => Ok(Color::LightGray), + "lightgrey" => Ok(Color::LightGrey), + "lightgreen" => Ok(Color::LightGreen), + "lightpink" => Ok(Color::LightPink), + "lightsalmon" => Ok(Color::LightSalmon), + "lightseagreen" => Ok(Color::LightSeaGreen), + "lightskyblue" => Ok(Color::LightSkyBlue), + "lightslategray" => Ok(Color::LightSlateGray), + "lightslategrey" => Ok(Color::LightSlateGrey), + "lightsteelblue" => Ok(Color::LightSteelBlue), + "lightyellow" => Ok(Color::LightYellow), + "lime" => Ok(Color::Lime), + "limegreen" => Ok(Color::LimeGreen), + "linen" => Ok(Color::Linen), + "magenta" => Ok(Color::Magenta), + "maroon" => Ok(Color::Maroon), + "mediumaquamarine" => Ok(Color::MediumAquaMarine), + "mediumblue" => Ok(Color::MediumBlue), + "mediumorchid" => Ok(Color::MediumOrchid), + "mediumpurple" => Ok(Color::MediumPurple), + "mediumseagreen" => Ok(Color::MediumSeaGreen), + "mediumslateblue" => Ok(Color::MediumSlateBlue), + "mediumspringgreen" => Ok(Color::MediumSpringGreen), + "mediumturquoise" => Ok(Color::MediumTurquoise), + "mediumvioletred" => Ok(Color::MediumVioletRed), + "midnightblue" => Ok(Color::MidnightBlue), + "mintcream" => Ok(Color::MintCream), + "mistyrose" => Ok(Color::MistyRose), + "moccasin" => Ok(Color::Moccasin), + "navajowhite" => Ok(Color::NavajoWhite), + "navy" => Ok(Color::Navy), + "oldlace" => Ok(Color::OldLace), + "olive" => Ok(Color::Olive), + "olivedrab" => Ok(Color::OliveDrab), + "orange" => Ok(Color::Orange), + "orangered" => Ok(Color::OrangeRed), + "orchid" => Ok(Color::Orchid), + "palegoldenrod" => Ok(Color::PaleGoldenRod), + "palegreen" => Ok(Color::PaleGreen), + "paleturquoise" => Ok(Color::PaleTurquoise), + "palevioletred" => Ok(Color::PaleVioletRed), + "papayawhip" => Ok(Color::PapayaWhip), + "peachpuff" => Ok(Color::PeachPuff), + "peru" => Ok(Color::Peru), + "pink" => Ok(Color::Pink), + "plum" => Ok(Color::Plum), + "powderblue" => Ok(Color::PowderBlue), + "purple" => Ok(Color::Purple), + "rebeccapurple" => Ok(Color::RebeccaPurple), + "red" => Ok(Color::Red), + "rosybrown" => Ok(Color::RosyBrown), + "royalblue" => Ok(Color::RoyalBlue), + "saddlebrown" => Ok(Color::SaddleBrown), + "salmon" => Ok(Color::Salmon), + "sandybrown" => Ok(Color::SandyBrown), + "seagreen" => Ok(Color::SeaGreen), + "seashell" => Ok(Color::SeaShell), + "sienna" => Ok(Color::Sienna), + "silver" => Ok(Color::Silver), + "skyblue" => Ok(Color::SkyBlue), + "slateblue" => Ok(Color::SlateBlue), + "slategray" => Ok(Color::SlateGray), + "slategrey" => Ok(Color::SlateGrey), + "snow" => Ok(Color::Snow), + "springgreen" => Ok(Color::SpringGreen), + "steelblue" => Ok(Color::SteelBlue), + "tan" => Ok(Color::Tan), + "teal" => Ok(Color::Teal), + "thistle" => Ok(Color::Thistle), + "tomato" => Ok(Color::Tomato), + "turquoise" => Ok(Color::Turquoise), + "violet" => Ok(Color::Violet), + "wheat" => Ok(Color::Wheat), + "white" => Ok(Color::White), + "whitesmoke" => Ok(Color::WhiteSmoke), + "yellow" => Ok(Color::Yellow), + "yellowgreen" => Ok(Color::YellowGreen), + _ => Err("invalid color"), + } + } +} \ No newline at end of file diff --git a/src/common.rs b/src/common.rs index c3b08a4..f0f5ce2 100644 --- a/src/common.rs +++ b/src/common.rs @@ -419,317 +419,6 @@ impl TryFrom<&str> for Keyword { } } -#[derive(Debug)] -pub enum Color { - AliceBlue, // = 0xF0F8FF, - AntiqueWhite, // = 0xFAEBD7, - Aqua, // = 0x00FFFF, - Aquamarine, // = 0x7FFFD4, - Azure, // = 0xF0FFFF, - Beige, // = 0xF5F5DC, - Bisque, // = 0xFFE4C4, - Black, // = 0x000000, - BlanchedAlmond, // = 0xFFEBCD, - Blue, // = 0x0000FF, - BlueViolet, // = 0x8A2BE2, - Brown, // = 0xA52A2A, - BurlyWood, // = 0xDEB887, - CadetBlue, // = 0x5F9EA0, - Chartreuse, // = 0x7FFF00, - Chocolate, // = 0xD2691E, - Coral, // = 0xFF7F50, - CornflowerBlue, // = 0x6495ED, - Cornsilk, // = 0xFFF8DC, - Crimson, // = 0xDC143C, - Cyan, //0x00FFFF - DarkBlue, // = 0x00008B, - DarkCyan, // = 0x008B8B, - DarkGoldenRod, // = 0xB8860B, - DarkGray, // = 0xA9A9A9, - DarkGrey, //0xA9A9A9 - DarkGreen, // = 0x006400, - DarkKhaki, // = 0xBDB76B, - DarkMagenta, // = 0x8B008B, - DarkOliveGreen, // = 0x556B2F, - DarkOrange, // = 0xFF8C00, - DarkOrchid, // = 0x9932CC, - DarkRed, // = 0x8B0000, - DarkSalmon, // = 0xE9967A, - DarkSeaGreen, // = 0x8FBC8F, - DarkSlateBlue, // = 0x483D8B, - DarkSlateGray, // = 0x2F4F4F, - DarkSlateGrey, //0x2F4F4F - DarkTurquoise, // = 0x00CED1, - DarkViolet, // = 0x9400D3, - DeepPink, // = 0xFF1493, - DeepSkyBlue, // = 0x00BFFF, - DimGray, // = 0x696969, - DimGrey, //0x696969 - DodgerBlue, // = 0x1E90FF, - FireBrick, // = 0xB22222, - FloralWhite, // = 0xFFFAF0, - ForestGreen, // = 0x228B22, - Fuchsia, // = 0xFF00FF, - Gainsboro, // = 0xDCDCDC, - GhostWhite, // = 0xF8F8FF, - Gold, // = 0xFFD700, - GoldenRod, // = 0xDAA520, - Gray, // = 0x808080, - Grey, //0x808080 - Green, // = 0x008000, - GreenYellow, // = 0xADFF2F, - HoneyDew, // = 0xF0FFF0, - HotPink, // = 0xFF69B4, - IndianRed, // = 0xCD5C5C, - Indigo, // = 0x4B0082, - Ivory, // = 0xFFFFF0, - Khaki, // = 0xF0E68C, - Lavender, // = 0xE6E6FA, - LavenderBlush, // = 0xFFF0F5, - LawnGreen, // = 0x7CFC00, - LemonChiffon, // = 0xFFFACD, - LightBlue, // = 0xADD8E6, - LightCoral, // = 0xF08080, - LightCyan, // = 0xE0FFFF, - LightGoldenRodYellow, // = 0xFAFAD2, - LightGray, // = 0xD3D3D3, - LightGrey, //0xD3D3D3 - LightGreen, // = 0x90EE90, - LightPink, // = 0xFFB6C1, - LightSalmon, // = 0xFFA07A, - LightSeaGreen, // = 0x20B2AA, - LightSkyBlue, // = 0x87CEFA, - LightSlateGray, // = 0x778899, - LightSlateGrey, //0x778899 - LightSteelBlue, // = 0xB0C4DE, - LightYellow, // = 0xFFFFE0, - Lime, // = 0x00FF00, - LimeGreen, // = 0x32CD32, - Linen, // = 0xFAF0E6, - Magenta, //0xFF00FF - Maroon, // = 0x800000, - MediumAquaMarine, // = 0x66CDAA, - MediumBlue, // = 0x0000CD, - MediumOrchid, // = 0xBA55D3, - MediumPurple, // = 0x9370DB, - MediumSeaGreen, // = 0x3CB371, - MediumSlateBlue, // = 0x7B68EE, - MediumSpringGreen, // = 0x00FA9A, - MediumTurquoise, // = 0x48D1CC, - MediumVioletRed, // = 0xC71585, - MidnightBlue, // = 0x191970, - MintCream, // = 0xF5FFFA, - MistyRose, // = 0xFFE4E1, - Moccasin, // = 0xFFE4B5, - NavajoWhite, // = 0xFFDEAD, - Navy, // = 0x000080, - OldLace, // = 0xFDF5E6, - Olive, // = 0x808000, - OliveDrab, // = 0x6B8E23, - Orange, // = 0xFFA500, - OrangeRed, // = 0xFF4500, - Orchid, // = 0xDA70D6, - PaleGoldenRod, // = 0xEEE8AA, - PaleGreen, // = 0x98FB98, - PaleTurquoise, // = 0xAFEEEE, - PaleVioletRed, // = 0xDB7093, - PapayaWhip, // = 0xFFEFD5, - PeachPuff, // = 0xFFDAB9, - Peru, // = 0xCD853F, - Pink, // = 0xFFC0CB, - Plum, // = 0xDDA0DD, - PowderBlue, // = 0xB0E0E6, - Purple, // = 0x800080, - RebeccaPurple, // = 0x663399, - Red, // = 0xFF0000, - RosyBrown, // = 0xBC8F8F, - RoyalBlue, // = 0x4169E1, - SaddleBrown, // = 0x8B4513, - Salmon, // = 0xFA8072, - SandyBrown, // = 0xF4A460, - SeaGreen, // = 0x2E8B57, - SeaShell, // = 0xFFF5EE, - Sienna, // = 0xA0522D, - Silver, // = 0xC0C0C0, - SkyBlue, // = 0x87CEEB, - SlateBlue, // = 0x6A5ACD, - SlateGray, // = 0x708090, - SlateGrey, //0x708090 - Snow, // = 0xFFFAFA, - SpringGreen, // = 0x00FF7F, - SteelBlue, // = 0x4682B4, - Tan, // = 0xD2B48C, - Teal, // = 0x008080, - Thistle, // = 0xD8BFD8, - Tomato, // = 0xFF6347, - Turquoise, // = 0x40E0D0, - Violet, // = 0xEE82EE, - Wheat, // = 0xF5DEB3, - White, // = 0xFFFFFF, - WhiteSmoke, // = 0xF5F5F5, - Yellow, // = 0xFFFF00, - YellowGreen, // = 0x9ACD32, - Other(u32), -} - -impl TryFrom<&str> for Color { - type Error = &'static str; - - fn try_from(string: &str) -> Result { - match string { - "aliceblue" => Ok(Color::AliceBlue), - "antiquewhite" => Ok(Color::AntiqueWhite), - "aqua" => Ok(Color::Aqua), - "aquamarine" => Ok(Color::Aquamarine), - "azure" => Ok(Color::Azure), - "beige" => Ok(Color::Beige), - "bisque" => Ok(Color::Bisque), - "black" => Ok(Color::Black), - "blanchedalmond" => Ok(Color::BlanchedAlmond), - "blue" => Ok(Color::Blue), - "blueviolet" => Ok(Color::BlueViolet), - "brown" => Ok(Color::Brown), - "burlywood" => Ok(Color::BurlyWood), - "cadetblue" => Ok(Color::CadetBlue), - "chartreuse" => Ok(Color::Chartreuse), - "chocolate" => Ok(Color::Chocolate), - "coral" => Ok(Color::Coral), - "cornflowerblue" => Ok(Color::CornflowerBlue), - "cornsilk" => Ok(Color::Cornsilk), - "crimson" => Ok(Color::Crimson), - "cyan" => Ok(Color::Cyan), - "darkblue" => Ok(Color::DarkBlue), - "darkcyan" => Ok(Color::DarkCyan), - "darkgoldenrod" => Ok(Color::DarkGoldenRod), - "darkgray" => Ok(Color::DarkGray), - "darkgrey" => Ok(Color::DarkGrey), - "darkgreen" => Ok(Color::DarkGreen), - "darkkhaki" => Ok(Color::DarkKhaki), - "darkmagenta" => Ok(Color::DarkMagenta), - "darkolivegreen" => Ok(Color::DarkOliveGreen), - "darkorange" => Ok(Color::DarkOrange), - "darkorchid" => Ok(Color::DarkOrchid), - "darkred" => Ok(Color::DarkRed), - "darksalmon" => Ok(Color::DarkSalmon), - "darkseagreen" => Ok(Color::DarkSeaGreen), - "darkslateblue" => Ok(Color::DarkSlateBlue), - "darkslategray" => Ok(Color::DarkSlateGray), - "darkslategrey" => Ok(Color::DarkSlateGrey), - "darkturquoise" => Ok(Color::DarkTurquoise), - "darkviolet" => Ok(Color::DarkViolet), - "deeppink" => Ok(Color::DeepPink), - "deepskyblue" => Ok(Color::DeepSkyBlue), - "dimgray" => Ok(Color::DimGray), - "dimgrey" => Ok(Color::DimGrey), - "dodgerblue" => Ok(Color::DodgerBlue), - "firebrick" => Ok(Color::FireBrick), - "floralwhite" => Ok(Color::FloralWhite), - "forestgreen" => Ok(Color::ForestGreen), - "fuchsia" => Ok(Color::Fuchsia), - "gainsboro" => Ok(Color::Gainsboro), - "ghostwhite" => Ok(Color::GhostWhite), - "gold" => Ok(Color::Gold), - "goldenrod" => Ok(Color::GoldenRod), - "gray" => Ok(Color::Gray), - "grey" => Ok(Color::Grey), - "green" => Ok(Color::Green), - "greenyellow" => Ok(Color::GreenYellow), - "honeydew" => Ok(Color::HoneyDew), - "hotpink" => Ok(Color::HotPink), - "indianred" => Ok(Color::IndianRed), - "indigo" => Ok(Color::Indigo), - "ivory" => Ok(Color::Ivory), - "khaki" => Ok(Color::Khaki), - "lavender" => Ok(Color::Lavender), - "lavenderblush" => Ok(Color::LavenderBlush), - "lawngreen" => Ok(Color::LawnGreen), - "lemonchiffon" => Ok(Color::LemonChiffon), - "lightblue" => Ok(Color::LightBlue), - "lightcoral" => Ok(Color::LightCoral), - "lightcyan" => Ok(Color::LightCyan), - "lightgoldenrodyellow" => Ok(Color::LightGoldenRodYellow), - "lightgray" => Ok(Color::LightGray), - "lightgrey" => Ok(Color::LightGrey), - "lightgreen" => Ok(Color::LightGreen), - "lightpink" => Ok(Color::LightPink), - "lightsalmon" => Ok(Color::LightSalmon), - "lightseagreen" => Ok(Color::LightSeaGreen), - "lightskyblue" => Ok(Color::LightSkyBlue), - "lightslategray" => Ok(Color::LightSlateGray), - "lightslategrey" => Ok(Color::LightSlateGrey), - "lightsteelblue" => Ok(Color::LightSteelBlue), - "lightyellow" => Ok(Color::LightYellow), - "lime" => Ok(Color::Lime), - "limegreen" => Ok(Color::LimeGreen), - "linen" => Ok(Color::Linen), - "magenta" => Ok(Color::Magenta), - "maroon" => Ok(Color::Maroon), - "mediumaquamarine" => Ok(Color::MediumAquaMarine), - "mediumblue" => Ok(Color::MediumBlue), - "mediumorchid" => Ok(Color::MediumOrchid), - "mediumpurple" => Ok(Color::MediumPurple), - "mediumseagreen" => Ok(Color::MediumSeaGreen), - "mediumslateblue" => Ok(Color::MediumSlateBlue), - "mediumspringgreen" => Ok(Color::MediumSpringGreen), - "mediumturquoise" => Ok(Color::MediumTurquoise), - "mediumvioletred" => Ok(Color::MediumVioletRed), - "midnightblue" => Ok(Color::MidnightBlue), - "mintcream" => Ok(Color::MintCream), - "mistyrose" => Ok(Color::MistyRose), - "moccasin" => Ok(Color::Moccasin), - "navajowhite" => Ok(Color::NavajoWhite), - "navy" => Ok(Color::Navy), - "oldlace" => Ok(Color::OldLace), - "olive" => Ok(Color::Olive), - "olivedrab" => Ok(Color::OliveDrab), - "orange" => Ok(Color::Orange), - "orangered" => Ok(Color::OrangeRed), - "orchid" => Ok(Color::Orchid), - "palegoldenrod" => Ok(Color::PaleGoldenRod), - "palegreen" => Ok(Color::PaleGreen), - "paleturquoise" => Ok(Color::PaleTurquoise), - "palevioletred" => Ok(Color::PaleVioletRed), - "papayawhip" => Ok(Color::PapayaWhip), - "peachpuff" => Ok(Color::PeachPuff), - "peru" => Ok(Color::Peru), - "pink" => Ok(Color::Pink), - "plum" => Ok(Color::Plum), - "powderblue" => Ok(Color::PowderBlue), - "purple" => Ok(Color::Purple), - "rebeccapurple" => Ok(Color::RebeccaPurple), - "red" => Ok(Color::Red), - "rosybrown" => Ok(Color::RosyBrown), - "royalblue" => Ok(Color::RoyalBlue), - "saddlebrown" => Ok(Color::SaddleBrown), - "salmon" => Ok(Color::Salmon), - "sandybrown" => Ok(Color::SandyBrown), - "seagreen" => Ok(Color::SeaGreen), - "seashell" => Ok(Color::SeaShell), - "sienna" => Ok(Color::Sienna), - "silver" => Ok(Color::Silver), - "skyblue" => Ok(Color::SkyBlue), - "slateblue" => Ok(Color::SlateBlue), - "slategray" => Ok(Color::SlateGray), - "slategrey" => Ok(Color::SlateGrey), - "snow" => Ok(Color::Snow), - "springgreen" => Ok(Color::SpringGreen), - "steelblue" => Ok(Color::SteelBlue), - "tan" => Ok(Color::Tan), - "teal" => Ok(Color::Teal), - "thistle" => Ok(Color::Thistle), - "tomato" => Ok(Color::Tomato), - "turquoise" => Ok(Color::Turquoise), - "violet" => Ok(Color::Violet), - "wheat" => Ok(Color::Wheat), - "white" => Ok(Color::White), - "whitesmoke" => Ok(Color::WhiteSmoke), - "yellow" => Ok(Color::Yellow), - "yellowgreen" => Ok(Color::YellowGreen), - _ => Err("invalid color"), - } - } -} - #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Pos { line: u32, diff --git a/src/main.rs b/src/main.rs index 805442c..4ef6a7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,7 +74,6 @@ pub enum TokenKind { Attribute(Attribute), Style(Vec), Op(Op), - // todo! preserve multi-line comments MultilineComment(String), }