Struct color_ansi::AnsiStyle

source ·
pub struct AnsiStyle {
    pub fg_color: Option<AnsiColor>,
    pub bg_color: Option<AnsiColor>,
    pub bold: bool,
    pub intense: bool,
    pub underline: bool,
    pub dimmed: bool,
    pub italic: bool,
    pub reset: bool,
    pub strikethrough: bool,
}
Expand description

The definition of the ANSI styles.

Fields§

§fg_color: Option<AnsiColor>

The foreground color.

§bg_color: Option<AnsiColor>

The background color.

§bold: bool

Get whether this is bold or not.

§intense: bool

Get whether this is intense or not.

On Unix-like systems, this will output the ANSI escape sequence that will print a high-intensity version of the color specified.

On Windows systems, this will output the ANSI escape sequence that will print a brighter version of the color specified.

§underline: bool

Get whether this is underlined or not.

§dimmed: bool

Get whether this is dimmed or not.

Note that the dimmed setting has no effect in a Windows console.

§italic: bool

Get whether this is italic or not.

Note that the italic setting has no effect in a Windows console.

§reset: bool

Get whether reset is enabled or not.

reset is enabled by default. When disabled and using ANSI escape sequences, a “reset” code will be emitted every time a ColorSpec’s settings are applied.

Note that the reset setting has no effect in a Windows console.

§strikethrough: bool

Get whether this is strikethrough or not.

Note that the strikethrough setting has no effect in a Windows console.

Implementations§

source§

impl AnsiStyle

source

pub fn new(foreground: AnsiColor) -> Self

Create a new ColorSpec with the foreground color specified.

source

pub fn rgb(r: u8, g: u8, b: u8) -> Self

Create a new ColorSpec with the foreground color specified.

source

pub fn with_fg_color(self, color: AnsiColor) -> Self

Create a new ColorSpec with the foreground color specified.

source

pub fn with_bg_color(self, color: AnsiColor) -> Self

Create a new ColorSpec with the background color specified.

source

pub fn with_underline(self) -> Self

Create a new AnsiStyle with underline enabled.

source

pub fn with_bold(self) -> Self

Create a new AnsiStyle with dimmed enabled.

source

pub fn with_italic(self) -> Self

Create a new AnsiStyle with dimmed enabled.

Trait Implementations§

source§

impl Clone for AnsiStyle

source§

fn clone(&self) -> AnsiStyle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AnsiStyle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AnsiStyle

source§

fn default() -> AnsiStyle

Returns the “default value” for a type. Read more
source§

impl PartialEq<AnsiStyle> for AnsiStyle

source§

fn eq(&self, other: &AnsiStyle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for AnsiStyle

source§

impl Eq for AnsiStyle

source§

impl StructuralEq for AnsiStyle

source§

impl StructuralPartialEq for AnsiStyle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.