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

Creates a style sheet with no colors and no attributes

A stylesheet with no colors and no attributes.

Check if the stylesheet contains no colors and no attributes.

Copies the StyleSheet to a new one set with the defined foreground Color.

Copies the StyleSheet to a new one set with the defined background Color.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

A stylesheet with no colors and no attributes.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.