diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-03-03 10:27:20 -0600 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-03-03 11:04:34 -0600 |
commit | 1837aa8eaad50d716fa6f25b66c103fc97c28d05 (patch) | |
tree | db7c4306972e0ec01ffdd16c2b9c06d23447cef6 /src/paint.rs | |
parent | 5293dba7560be300530838c117559746d2b4a4e7 (diff) |
Support specifying color by ANSI 256 color palette index
Diffstat (limited to 'src/paint.rs')
-rw-r--r-- | src/paint.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/paint.rs b/src/paint.rs index 6102505d..b83c3862 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -259,13 +259,13 @@ pub fn ansi_color_name_to_number(name: &str) -> Option<u8> { } pub fn color_from_ansi_name(name: &str) -> Option<Color> { - ansi_color_name_to_number(name).and_then(|n| Some(color_from_ansi_number(n))) + ansi_color_name_to_number(name).and_then(color_from_ansi_number) } /// Convert 8-bit ANSI code to #RGBA string with ANSI code in red channel and 0 in alpha channel. // See https://github.com/sharkdp/bat/pull/543 -pub fn color_from_ansi_number(n: u8) -> Color { - Color::from_str(&format!("#{:02x}000000", n)).unwrap() +pub fn color_from_ansi_number(n: u8) -> Option<Color> { + Color::from_str(&format!("#{:02x}000000", n)).ok() } mod superimpose_style_sections { |