Skip to content

Commit

Permalink
Add Style::set_dimmed to support dimmed text
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Oct 11, 2021
1 parent d27278d commit a08e022
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
27 changes: 27 additions & 0 deletions src/fmt/writer/termcolor/extern_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a08e022

Please sign in to comment.