diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-06-26 19:37:45 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-06-26 19:49:32 -0400 |
commit | ea7266594a7a470f98a309bb4c0da7359b2037e2 (patch) | |
tree | f083c695f11332f336ead8cf078c9251b9314ca3 /src/color.rs | |
parent | 472c5a509d5cc9e57bad476e4cd852e4b9459a01 (diff) |
New command --show-styles
Drop old command --show-background-colors
Diffstat (limited to 'src/color.rs')
-rw-r--r-- | src/color.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/color.rs b/src/color.rs index 8caaf4c4..463bfc22 100644 --- a/src/color.rs +++ b/src/color.rs @@ -39,6 +39,21 @@ pub fn color_from_rgb_or_ansi_code_with_default( } } +pub fn color_to_string(color: Color) -> String { + match color { + Color::Fixed(n) => format!("{}", n), + Color::RGB(r, g, b) => format!("#{:02x?}{:02x?}{:02x?}", r, g, b), + Color::Black => "black".to_string(), + Color::Red => "red".to_string(), + Color::Green => "green".to_string(), + Color::Yellow => "yellow".to_string(), + Color::Blue => "blue".to_string(), + Color::Purple => "purple".to_string(), + Color::Cyan => "cyan".to_string(), + Color::White => "white".to_string(), + } +} + // See // https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit pub fn ansi_color_name_to_number(name: &str) -> Option<u8> { |