From 315cc954ab66571b0c576d2ce0e01378535c2c25 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 27 Jun 2020 13:54:49 -0400 Subject: Refactor: pass foreground & background defaults as a single Style --- src/style.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/style.rs') diff --git a/src/style.rs b/src/style.rs index dbac0863..734d3b9f 100644 --- a/src/style.rs +++ b/src/style.rs @@ -39,6 +39,20 @@ impl Style { } } + pub fn from_colors( + foreground: Option, + background: Option, + ) -> Self { + Self { + ansi_term_style: ansi_term::Style { + foreground, + background, + ..ansi_term::Style::new() + }, + ..Self::new() + } + } + pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>( self, input: I, -- cgit v1.2.3