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§
source§impl 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§
source§impl Clone for StyleSheet
impl Clone for StyleSheet
source§fn clone(&self) -> StyleSheet
fn clone(&self) -> StyleSheet
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StyleSheet
impl Debug for StyleSheet
source§impl Default for StyleSheet
impl Default for StyleSheet
source§fn default() -> StyleSheet
fn default() -> StyleSheet
A stylesheet with no colors and no attributes.
source§impl PartialEq<StyleSheet> for StyleSheet
impl PartialEq<StyleSheet> for StyleSheet
source§fn 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 ==
.