pub enum AnsiStyleCodes {
Show 40 variants Reset, Bright, Dim, Italic, Underlined, Blink, BlinkRapid, Inverse, Hidden, Strikethrough, PrimaryFont, AlternateFont(u8), Fraktur, DoulbeUnderlinedOrNotBright, NotBrightNorDim, NotItalicNorFraktur, NotUnderlined, NotBlink, _ProportionalSpacing, NotInverse, NotHidden, NotStrikethrough, ForegroundColor(ForegroundColor), BackgroundColor(BackgroundColor), _NotProportionalSpacing, Framed, Circled, Overlined, NotFramedOrCircled, NotOverlined, UnderlinedColor(UnderlinedColor), _IdeogramUnderlined, _IdeogramDoubleUnderlined, _IdeogramOverlined, _IdeogramDoubleOverlined, _IdeogramStressMarking, _NotIdeogram, Superscript, Subscript, NotSuperOrSubscript,
}
Expand description

The set of all possible ANSI escape codes for setting text style.

This is also referred to as Select Graphic Rendition (SGR) parameters or Display Attributes.

Note that terminal emulators may not support all of these codes; in general, only the first 9 codes are supported (and their Not* variants that disable them).

See a list of all such parameters here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters

Variants§

§

Reset

Resets or clears all styles.

§

Bright

Bright or bold text.

§

Dim

Dim or faint text.

§

Italic

Italicized text.

§

Underlined

Underlined text.

The text will blink at slower rate, under 150 blinks per minute.

§

BlinkRapid

The text will blink rapidly at a fast rate, over 150 blinks per minute.

§

Inverse

The foreground and background colors will be swapped. The text will be displayed using the background color, while the background will be displayed using the foreground color.

§

Hidden

The text will be concealed/invisible and not displayed at all. Only the solid background color will be displayed.

§

Strikethrough

The text will be striked through, i.e., crossed out with a line through it.

§

PrimaryFont

Sets the font to the primary default font.

§

AlternateFont(u8)

Sets the font to an alternate font. There are 10 available choices, from 0 to 9, in which 0 is the same as Self::PrimaryFont.

§

Fraktur

Sets the font to be a blackletter font, which is a calligraphic/angular font in a gothic German style rather than the typical Roman/Latin style. Example: https://git.enlightenment.org/apps/terminology.git/commit/?id=02856cbdec511e08cf579b08e906499d9583f018

§

DoulbeUnderlinedOrNotBright

The text will be underlined twice, or, depending on the terminal, this will disable Bright.

Note: it is better to use NotBrightNorDim to disable Bright as that escape code is more widely supported than this one.

§

NotBrightNorDim

Normal font intensity: Disables Bright or Dim.

§

NotItalicNorFraktur

Normal font sytle: Disables Italic or Fraktur.

§

NotUnderlined

Disables Underline or DoubleUnderline.

Disables Blink or BlinkRapid.

§

_ProportionalSpacing

Proportional spacing, which sets the Teletex character set: https://en.wikipedia.org/wiki/ITU_T.61. This is a different text encoding that is not used and has no effect on terminals.

§

NotInverse

Disables Inverse: foreground colors and background colors are used as normal.

§

NotHidden

Disables Hidden``: text is displayed as normal. Sometimes called reveal.

§

NotStrikethrough

Disables Strikethrough: text is not crossed out.

§

ForegroundColor(ForegroundColor)

Set the foreground color: the color the text will be displayed in. To set it back to the default, use ForegroundColor(Color::Default).

§

BackgroundColor(BackgroundColor)

Set the background color: the color displayed behind the text. To set it back to the default, use BackgroundColor(Color::Default).

§

_NotProportionalSpacing

Disables _ProportionalSpacing.

§

Framed

The text will be displayed with a rectangular box surrounding it.

§

Circled

The text will be displayed with a circle or oval surrounding it.

§

Overlined

The text will be overlined: displayed with a line on top (like underlined).

§

NotFramedOrCircled

Disables Framed or Circled.

§

NotOverlined

Disabled Overlined.

§

UnderlinedColor(UnderlinedColor)

Sets the underline color. Without this, the underline color will be the same as the text color. To set it back to the default, use UnderlinedColor(Color::Default).

§

_IdeogramUnderlined

§

_IdeogramDoubleUnderlined

§

_IdeogramOverlined

§

_IdeogramDoubleOverlined

§

_IdeogramStressMarking

§

_NotIdeogram

Disables all Ideogram styles.

§

Superscript

§

Subscript

§

NotSuperOrSubscript

Disables Superscript or Subscript.

Implementations§

source§

impl AnsiStyleCodes

source

pub const ESCAPE_PREFIX: &'static [u8] = b"\x1B["

source

pub const ESCAPE_DELIM: &'static [u8] = b";"

source

pub const ESCAPE_SUFFIX: &'static [u8] = b"m"

source

pub fn to_escape_code(&self) -> Cow<'static, str>

Trait Implementations§

source§

impl Debug for AnsiStyleCodes

source§

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

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

impl Display for AnsiStyleCodes

source§

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

Formats the value using the given formatter. Read more

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.