pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub effects: Effects,
}
Expand description
A text style, a combination of a foreground color, a background color and text effects (all optional).
Fields§
§fg: Option<Color>
The foreground color (if set).
bg: Option<Color>
The background color (if set).
effects: Effects
The text effects.
Implementations§
Source§impl Style
impl Style
Sourcepub fn new(fg: Option<Color>, bg: Option<Color>, effects: Effects) -> Style
pub fn new(fg: Option<Color>, bg: Option<Color>, effects: Effects) -> Style
Creates a new style with the given foreground and background colors and effects.
Sourcepub fn and(self, style: Style) -> Style
pub fn and(self, style: Style) -> Style
Combines this style with another style.
If a color is set by both styles, the current color is overwritten.
§Example
use text_style::{AnsiColor, Effects, Style};
assert_eq!(
Style::fg(AnsiColor::Red.dark()).and(Style::bg(AnsiColor::White.dark())),
Style::new(Some(AnsiColor::Red.dark()), Some(AnsiColor::White.dark()), Effects::empty()),
);
Sourcepub fn set_italic(&mut self, italic: bool)
pub fn set_italic(&mut self, italic: bool)
Sets or unsets the italic effect for this style.
Sourcepub fn set_underline(&mut self, underline: bool)
pub fn set_underline(&mut self, underline: bool)
Sets or unsets the underline effect for this style.
Sourcepub fn strikethrough(&mut self, strikethrough: bool)
pub fn strikethrough(&mut self, strikethrough: bool)
Sets or unsets the strikethrough effect for this style.
Sourcepub fn set_effect(&mut self, effect: Effect, set: bool)
pub fn set_effect(&mut self, effect: Effect, set: bool)
Sets or unsets the given effect for this style.
Trait Implementations§
Source§impl From<Style> for ContentStyle
impl From<Style> for ContentStyle
Source§fn from(style: Style) -> ContentStyle
fn from(style: Style) -> ContentStyle
Converts to this type from the input type.
impl Copy for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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