From 1e2256224ebd136a8a4ff4d76ded43b60c9c3cfa Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Mon, 11 Oct 2021 20:20:49 +0200 Subject: [PATCH] Add `Style::set_dimmed` to support dimmed text --- Cargo.toml | 2 +- src/fmt/writer/termcolor/extern_impl.rs | 27 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 29c77b3..ad2b27f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ members = [ [dependencies] log = { version = "0.4.8", features = ["std"] } regex = { version = "1.0.3", optional = true, default-features=false, features=["std", "perf"] } -termcolor = { version = "1.0.2", optional = true } +termcolor = { version = "1.1.1", optional = true } humantime = { version = "2.0.0", optional = true } atty = { version = "0.2.5", optional = true } diff --git a/src/fmt/writer/termcolor/extern_impl.rs b/src/fmt/writer/termcolor/extern_impl.rs index 11012fb..5068ce8 100644 --- a/src/fmt/writer/termcolor/extern_impl.rs +++ b/src/fmt/writer/termcolor/extern_impl.rs @@ -339,6 +339,33 @@ impl Style { self } + /// Set whether the text is dimmed. + /// + /// If `yes` is true then text will be written in a dimmer color. + /// If `yes` is false then text will be written in the default color. + /// + /// # Examples + /// + /// Create a style with dimmed text: + /// + /// ``` + /// use std::io::Write; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut style = buf.style(); + /// + /// style.set_dimmed(true); + /// + /// writeln!(buf, "{}", style.value(record.args())) + /// }); + /// ``` + pub fn set_dimmed(&mut self, yes: bool) -> &mut Style { + self.spec.set_dimmed(yes); + self + } + /// Set the background color. /// /// # Examples