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 duplicate 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 for StyleSheet
impl PartialEq for StyleSheet
impl Copy for StyleSheet
impl Eq for StyleSheet
impl StructuralPartialEq for StyleSheet
Auto Trait Implementations§
impl Freeze for StyleSheet
impl RefUnwindSafe for StyleSheet
impl Send for StyleSheet
impl Sync for StyleSheet
impl Unpin for StyleSheet
impl UnwindSafe for StyleSheet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more