Struct cargo_lambda_interactive::ui::StyleSheet
source · [−]pub struct StyleSheet {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub att: Attributes,
}
Expand description
Style definitions that can be applied to the rendered content.
Example
use inquire::ui::{Attributes, Color, StyleSheet};
let style_sheet = StyleSheet::default();
assert!(style_sheet.is_empty());
let style_sheet = style_sheet
.with_bg(Color::DarkBlue)
.with_attr(Attributes::ITALIC | Attributes::BOLD);
assert!(!style_sheet.is_empty());
Fields
fg: Option<Color>
Foreground color of text.
bg: Option<Color>
Background color of text.
att: Attributes
Attributes applied to text.
Implementations
sourceimpl StyleSheet
impl StyleSheet
sourcepub fn new() -> StyleSheet
pub fn new() -> StyleSheet
Creates a style sheet with no colors and no attributes
sourcepub fn empty() -> StyleSheet
pub fn empty() -> StyleSheet
A stylesheet with no colors and no attributes.
sourcepub fn with_fg(self, fg: Color) -> StyleSheet
pub fn with_fg(self, fg: Color) -> StyleSheet
Copies the StyleSheet to a new one set with the defined foreground Color.
sourcepub fn with_bg(self, bg: Color) -> StyleSheet
pub fn with_bg(self, bg: Color) -> StyleSheet
Copies the StyleSheet to a new one set with the defined background Color.
sourcepub fn with_attr(self, attributes: Attributes) -> StyleSheet
pub fn with_attr(self, attributes: Attributes) -> StyleSheet
Copies the style sheet to a new one with the specified attributes.
Warning: this does not keep the previously applied attributes. If you want to just set a new attribute and keep the others, you need to apply the OR operation yourself.
Example
use inquire::ui::{Attributes, Color, StyleSheet};
let style_sheet = StyleSheet::default().with_attr(Attributes::BOLD);
assert_eq!(true, style_sheet.att.contains(Attributes::BOLD));
assert_eq!(false, style_sheet.att.contains(Attributes::ITALIC));
let style_sheet = style_sheet.with_attr(Attributes::ITALIC);
assert_eq!(false, style_sheet.att.contains(Attributes::BOLD));
assert_eq!(true, style_sheet.att.contains(Attributes::ITALIC));
let style_sheet = style_sheet.with_attr(style_sheet.att | Attributes::BOLD);
assert_eq!(true, style_sheet.att.contains(Attributes::BOLD));
assert_eq!(true, style_sheet.att.contains(Attributes::ITALIC));
Trait Implementations
sourceimpl Clone for StyleSheet
impl Clone for StyleSheet
sourcefn clone(&self) -> StyleSheet
fn clone(&self) -> StyleSheet
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for StyleSheet
impl Debug for StyleSheet
sourceimpl Default for StyleSheet
impl Default for StyleSheet
sourcefn default() -> StyleSheet
fn default() -> StyleSheet
A stylesheet with no colors and no attributes.
sourceimpl PartialEq<StyleSheet> for StyleSheet
impl PartialEq<StyleSheet> for StyleSheet
sourcefn eq(&self, other: &StyleSheet) -> bool
fn eq(&self, other: &StyleSheet) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &StyleSheet) -> bool
fn ne(&self, other: &StyleSheet) -> bool
This method tests for !=
.
impl Copy for StyleSheet
impl StructuralPartialEq for StyleSheet
Auto Trait Implementations
impl RefUnwindSafe for StyleSheet
impl Send for StyleSheet
impl Sync for StyleSheet
impl Unpin for StyleSheet
impl UnwindSafe for StyleSheet
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more