pub struct Style { /* private fields */ }
Expand description
Implementations§
source§impl Style
impl Style
sourcepub const fn fg_color(self, fg: Option<Color>) -> Self
pub const fn fg_color(self, fg: Option<Color>) -> Self
Set foreground color
Examples
let style = anstyle::Style::new().fg_color(Some(anstyle::AnsiColor::Red.into()));
sourcepub const fn bg_color(self, bg: Option<Color>) -> Self
pub const fn bg_color(self, bg: Option<Color>) -> Self
Set background color
Examples
let style = anstyle::Style::new().bg_color(Some(anstyle::AnsiColor::Red.into()));
sourcepub const fn underline_color(self, underline: Option<Color>) -> Self
pub const fn underline_color(self, underline: Option<Color>) -> Self
Set underline color
Examples
let style = anstyle::Style::new().underline_color(Some(anstyle::AnsiColor::Red.into()));
sourcepub const fn effects(self, effects: Effects) -> Self
pub const fn effects(self, effects: Effects) -> Self
Set text effects
Examples
let style = anstyle::Style::new().effects(anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE);
sourcepub fn render_reset(self) -> impl Display
pub fn render_reset(self) -> impl Display
Renders the relevant Reset
code
Unlike Reset::render
, this will elide the code if there is nothing to reset.
sourcepub fn write_reset_to(self, write: &mut dyn Write) -> Result<()>
pub fn write_reset_to(self, write: &mut dyn Write) -> Result<()>
Write the relevant Reset
code
Unlike Reset::render
, this will elide the code if there is nothing to reset.
source§impl Style
impl Style
source§impl Style
impl Style
pub const fn get_fg_color(self) -> Option<Color>
pub const fn get_bg_color(self) -> Option<Color>
pub const fn get_underline_color(self) -> Option<Color>
pub const fn get_effects(self) -> Effects
Trait Implementations§
source§impl BitOr<Effects> for Style
impl BitOr<Effects> for Style
Examples
let style = anstyle::Style::new() | anstyle::Effects::BOLD.into();
source§impl BitOrAssign<Effects> for Style
impl BitOrAssign<Effects> for Style
Examples
let mut style = anstyle::Style::new();
style |= anstyle::Effects::BOLD.into();
source§fn bitor_assign(&mut self, other: Effects)
fn bitor_assign(&mut self, other: Effects)
Performs the
|=
operation. Read moresource§impl From<Effects> for Style
impl From<Effects> for Style
Examples
let style: anstyle::Style = anstyle::Effects::BOLD.into();
source§impl Ord for Style
impl Ord for Style
source§impl PartialEq<Effects> for Style
impl PartialEq<Effects> for Style
Examples
let effects = anstyle::Effects::BOLD;
assert_eq!(anstyle::Style::new().effects(effects), effects);
assert_ne!(anstyle::Effects::UNDERLINE | effects, effects);
assert_ne!(anstyle::RgbColor(0, 0, 0).on_default() | effects, effects);
source§impl PartialEq<Style> for Style
impl PartialEq<Style> for Style
source§impl PartialOrd<Style> for Style
impl PartialOrd<Style> for Style
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Sub<Effects> for Style
impl Sub<Effects> for Style
Examples
let style = anstyle::Style::new().bold().underline() - anstyle::Effects::BOLD.into();
source§impl SubAssign<Effects> for Style
impl SubAssign<Effects> for Style
Examples
let mut style = anstyle::Style::new().bold().underline();
style -= anstyle::Effects::BOLD.into();
source§fn sub_assign(&mut self, other: Effects)
fn sub_assign(&mut self, other: Effects)
Performs the
-=
operation. Read more