Struct inquire::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 with_fg(self, fg: Color) -> Self
pub fn with_fg(self, fg: Color) -> Self
Copies the StyleSheet to a new one set with the defined foreground Color.
sourcepub fn with_bg(self, bg: Color) -> Self
pub fn with_bg(self, bg: Color) -> Self
Copies the StyleSheet to a new one set with the defined background Color.
sourcepub fn with_attr(self, attributes: Attributes) -> Self
pub fn with_attr(self, attributes: Attributes) -> Self
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§impl From<StyleSheet> for Style
Available on crate feature console
only.
impl From<StyleSheet> for Style
Available on crate feature
console
only.source§fn from(from: StyleSheet) -> Self
fn from(from: StyleSheet) -> Self
Converts to this type from the input type.
source§impl Hash for StyleSheet
impl Hash for StyleSheet
source§impl PartialEq for StyleSheet
impl PartialEq 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 ==
.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