Skip to content

Commit

Permalink
Parse hex colors in themes (#647)
Browse files Browse the repository at this point in the history
Just delegate to the default deserializer of crossterm which learned
dealing with hex color in version 0.27.0.
  • Loading branch information
zappolowski committed Aug 29, 2023
1 parent 9b8ed0e commit 14e0b65
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
33 changes: 21 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions src/theme/color.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<E>(self, value: u64) -> Result<Color, E>
Expand Down

0 comments on commit 14e0b65

Please sign in to comment.