diff --git a/Cargo.lock b/Cargo.lock index 614a7222d..7ae7586b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,6 +60,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] + [[package]] name = "bstr" version = "0.2.17" @@ -121,7 +130,7 @@ version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "is-terminal", @@ -174,11 +183,11 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.24.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9f7409c70a38a56216480fba371ee460207dd8926ccf5b4160591759559170" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.4.0", "crossterm_winapi", "libc", "mio", @@ -191,9 +200,9 @@ dependencies = [ [[package]] name = "crossterm_winapi" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] @@ -304,7 +313,7 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "libgit2-sys", "log", @@ -336,7 +345,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "ignore", "walkdir", ] @@ -794,7 +803,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -846,7 +855,7 @@ version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -931,9 +940,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.14" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", diff --git a/Cargo.toml b/Cargo.toml index 30fa89291..11b598684 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ clap_complete = "4.1" version_check = "0.9.*" [dependencies] -crossterm = { version = "0.24.0", features = ["serde"] } +crossterm = { version = "0.27.0", features = ["serde"] } dirs = "3.0.*" libc = "0.2.*" human-sort = "0.2.2" diff --git a/src/theme/color.rs b/src/theme/color.rs index 35b871215..337477ebf 100644 --- a/src/theme/color.rs +++ b/src/theme/color.rs @@ -1,7 +1,7 @@ ///! This module provides methods to create theme from files and operations related to ///! this. use crossterm::style::Color; -use serde::Deserialize; +use serde::{de::IntoDeserializer, Deserialize}; use std::fmt; // Custom color deserialize @@ -23,8 +23,7 @@ where where E: serde::de::Error, { - Color::try_from(value) - .map_err(|_| E::invalid_value(serde::de::Unexpected::Str(value), &self)) + Color::deserialize(value.into_deserializer()) } fn visit_u64(self, value: u64) -> Result @@ -470,6 +469,21 @@ tree-edge: 245 assert_eq!(empty_theme, theme); } + #[test] + fn test_hexadecimal_colors() { + // Must contain one field at least + // ref https://github.com/dtolnay/serde-yaml/issues/86 + let empty_theme: ColorTheme = Theme::with_yaml("user: \"#ff007f\"").unwrap(); + assert_eq!( + empty_theme.user, + crossterm::style::Color::Rgb { + r: 255, + g: 0, + b: 127 + } + ); + } + #[test] fn test_second_level_theme_return_default_but_changed() { // Must contain one field at least