From c3c3d4096fd7c891c72d27843ae4e087a45e2ac2 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Fri, 18 Dec 2020 15:38:56 -0800 Subject: [PATCH] Add ColorStyle::{front, back} functions --- cursive-core/src/theme/color_style.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cursive-core/src/theme/color_style.rs b/cursive-core/src/theme/color_style.rs index f9715ef..a5e96de 100644 --- a/cursive-core/src/theme/color_style.rs +++ b/cursive-core/src/theme/color_style.rs @@ -26,6 +26,22 @@ impl ColorStyle { Self { front, back } } + /// Uses the given color as front, inherits the parent background color. + pub fn front(front: F) -> Self + where + F: Into, + { + Self::new(front, ColorType::InheritParent) + } + + /// Uses the given color as background, inherits the parent front color. + pub fn back(back: B) -> Self + where + B: Into, + { + Self::new(ColorType::InheritParent, back) + } + /// Style set by terminal before entering a Cursive program. pub fn terminal_default() -> Self { Self::new(Color::TerminalDefault, Color::TerminalDefault)