Update terminal-colorsaurus to 0.4.0

Excerpt from the [changelog](https://github.com/bash/terminal-colorsaurus/blob/0.4.0/changelog.md):

> *  Renamed «color scheme» to «color palette».
> *  Removed `is_dark_on_light` and `is_light_on_dark` functions. Use `color_scheme` instead.
> * Add new convenience function `color_scheme` which returns a nice `Dark / Light` enum.
> * Add support for urxvt's `rgba:` color format.
> * Further refined the documentation (more organized terminal list, new terminals tested).
> * Improved handling of ambigous color palettes (e.g. when background color is the same as foreground).
> * Queries are now terminated with `ST` (the standard string terminator) instead of `BEL` (which is an xterm extension).
pull/2896/head
Tau Gärtli 4 weeks ago
parent 173c5d2bd6
commit 8bbaf1f4a3
No known key found for this signature in database

4
Cargo.lock generated

@ -1323,9 +1323,9 @@ dependencies = [
[[package]]
name = "terminal-colorsaurus"
version = "0.3.3"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a11d4fd698c3b697b6f712fa75f62f7b15119f41b0bb660741dd02297f534d78"
checksum = "fc3b74af7c844e628c5dafa421ec59283e9f0bed5cb49956439316ec6d8728f1"
dependencies = [
"libc",
"memchr",

@ -68,7 +68,7 @@ bytesize = { version = "1.3.0" }
encoding_rs = "0.8.33"
os_str_bytes = { version = "~7.0", optional = true }
run_script = { version = "^0.10.1", optional = true}
terminal-colorsaurus = { version = "0.3.3" }
terminal-colorsaurus = { version = "0.4.0" }
[dependencies.git2]
version = "0.18"

@ -92,6 +92,15 @@ pub enum ColorScheme {
Light,
}
impl From<terminal_colorsaurus::ColorScheme> for ColorScheme {
fn from(scheme: terminal_colorsaurus::ColorScheme) -> Self {
match scheme {
terminal_colorsaurus::ColorScheme::Dark => ColorScheme::Dark,
terminal_colorsaurus::ColorScheme::Light => ColorScheme::Light,
}
}
}
fn theme_from_detector(options: ThemeOptions, detector: &dyn ColorSchemeDetector) -> String {
// Implementation note: This function is mostly pure (i.e. it has no side effects) for the sake of testing.
// All the side effects (e.g. querying the terminal for its colors) are performed in the detector.
@ -145,12 +154,9 @@ impl ColorSchemeDetector for TerminalColorSchemeDetector {
fn detect(&self) -> Option<ColorScheme> {
use terminal_colorsaurus::{color_scheme, QueryOptions};
let colors = color_scheme(QueryOptions::default()).ok()?;
if colors.is_light_on_dark() {
Some(ColorScheme::Dark)
} else {
Some(ColorScheme::Light)
}
color_scheme(QueryOptions::default())
.map(ColorScheme::from)
.ok()
}
}

Loading…
Cancel
Save