[−][src]Struct text_style::Style
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
impl Style
[src]
pub fn new(fg: Option<Color>, bg: Option<Color>, effects: Effects) -> Style
[src]
Creates a new style with the given foreground and background colors and effects.
pub fn fg(color: Color) -> Style
[src]
Creates a new style with the given foreground color.
pub fn bg(color: Color) -> Style
[src]
Creates a new style with the given background color.
pub fn effect(effect: Effect) -> Style
[src]
Creates a new style with the given text effect.
pub fn effects(effects: Effects) -> Style
[src]
Creates a new style with the given text effects.
pub fn and(self, style: Style) -> Style
[src]
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()), );
pub fn set_fg(&mut self, color: Color)
[src]
Sets the foreground color of this style.
pub fn set_bg(&mut self, color: Color)
[src]
Sets the background color of this style.
pub fn set_bold(&mut self, bold: bool)
[src]
Sets or unsets the bold effect for this style.
pub fn set_italic(&mut self, italic: bool)
[src]
Sets or unsets the italic effect for this style.
pub fn set_underline(&mut self, underline: bool)
[src]
Sets or unsets the underline effect for this style.
pub fn set_effect(&mut self, effect: Effect, set: bool)
[src]
Sets or unsets the given effect for this style.
Trait Implementations
impl Clone for Style
[src]
impl Copy for Style
[src]
impl Debug for Style
[src]
impl Default for Style
[src]
impl From<Effect> for Style
[src]
impl From<Effects> for Style
[src]
impl From<Style> for Style
[src]
impl From<Style> for ContentStyle
[src]
impl From<Style> for Style
[src]
impl From<Style> for Style
[src]
impl PartialEq<Style> for Style
[src]
impl StructuralPartialEq for Style
[src]
Auto Trait Implementations
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.