crossterm::style

Trait Stylize

Source
pub trait Stylize: Sized {
    type Styled: AsRef<ContentStyle> + AsMut<ContentStyle>;

Show 64 methods // Required method fn stylize(self) -> Self::Styled; // Provided methods fn with(self, color: Color) -> Self::Styled { ... } fn on(self, color: Color) -> Self::Styled { ... } fn underline(self, color: Color) -> Self::Styled { ... } fn attribute(self, attr: Attribute) -> Self::Styled { ... } fn reset(self) -> Self::Styled { ... } fn bold(self) -> Self::Styled { ... } fn underlined(self) -> Self::Styled { ... } fn reverse(self) -> Self::Styled { ... } fn dim(self) -> Self::Styled { ... } fn italic(self) -> Self::Styled { ... } fn negative(self) -> Self::Styled { ... } fn slow_blink(self) -> Self::Styled { ... } fn rapid_blink(self) -> Self::Styled { ... } fn hidden(self) -> Self::Styled { ... } fn crossed_out(self) -> Self::Styled { ... } fn black(self) -> Self::Styled { ... } fn on_black(self) -> Self::Styled { ... } fn underline_black(self) -> Self::Styled { ... } fn dark_grey(self) -> Self::Styled { ... } fn on_dark_grey(self) -> Self::Styled { ... } fn underline_dark_grey(self) -> Self::Styled { ... } fn red(self) -> Self::Styled { ... } fn on_red(self) -> Self::Styled { ... } fn underline_red(self) -> Self::Styled { ... } fn dark_red(self) -> Self::Styled { ... } fn on_dark_red(self) -> Self::Styled { ... } fn underline_dark_red(self) -> Self::Styled { ... } fn green(self) -> Self::Styled { ... } fn on_green(self) -> Self::Styled { ... } fn underline_green(self) -> Self::Styled { ... } fn dark_green(self) -> Self::Styled { ... } fn on_dark_green(self) -> Self::Styled { ... } fn underline_dark_green(self) -> Self::Styled { ... } fn yellow(self) -> Self::Styled { ... } fn on_yellow(self) -> Self::Styled { ... } fn underline_yellow(self) -> Self::Styled { ... } fn dark_yellow(self) -> Self::Styled { ... } fn on_dark_yellow(self) -> Self::Styled { ... } fn underline_dark_yellow(self) -> Self::Styled { ... } fn blue(self) -> Self::Styled { ... } fn on_blue(self) -> Self::Styled { ... } fn underline_blue(self) -> Self::Styled { ... } fn dark_blue(self) -> Self::Styled { ... } fn on_dark_blue(self) -> Self::Styled { ... } fn underline_dark_blue(self) -> Self::Styled { ... } fn magenta(self) -> Self::Styled { ... } fn on_magenta(self) -> Self::Styled { ... } fn underline_magenta(self) -> Self::Styled { ... } fn dark_magenta(self) -> Self::Styled { ... } fn on_dark_magenta(self) -> Self::Styled { ... } fn underline_dark_magenta(self) -> Self::Styled { ... } fn cyan(self) -> Self::Styled { ... } fn on_cyan(self) -> Self::Styled { ... } fn underline_cyan(self) -> Self::Styled { ... } fn dark_cyan(self) -> Self::Styled { ... } fn on_dark_cyan(self) -> Self::Styled { ... } fn underline_dark_cyan(self) -> Self::Styled { ... } fn white(self) -> Self::Styled { ... } fn on_white(self) -> Self::Styled { ... } fn underline_white(self) -> Self::Styled { ... } fn grey(self) -> Self::Styled { ... } fn on_grey(self) -> Self::Styled { ... } fn underline_grey(self) -> Self::Styled { ... }
}
Expand description

Provides a set of methods to set attributes and colors.

§Examples

use crossterm::style::Stylize;

println!("{}", "Bold text".bold());
println!("{}", "Underlined text".underlined());
println!("{}", "Negative text".negative());
println!("{}", "Red on blue".red().on_blue());

Required Associated Types§

Source

type Styled: AsRef<ContentStyle> + AsMut<ContentStyle>

This type with styles applied.

Required Methods§

Source

fn stylize(self) -> Self::Styled

Styles this type.

Provided Methods§

Source

fn with(self, color: Color) -> Self::Styled

Sets the foreground color.

Source

fn on(self, color: Color) -> Self::Styled

Sets the background color.

Source

fn underline(self, color: Color) -> Self::Styled

Sets the underline color.

Source

fn attribute(self, attr: Attribute) -> Self::Styled

Styles the content with the attribute.

Source

fn reset(self) -> Self::Styled

Applies the Reset attribute to the text.

Source

fn bold(self) -> Self::Styled

Applies the Bold attribute to the text.

Source

fn underlined(self) -> Self::Styled

Applies the Underlined attribute to the text.

Source

fn reverse(self) -> Self::Styled

Applies the Reverse attribute to the text.

Source

fn dim(self) -> Self::Styled

Applies the Dim attribute to the text.

Source

fn italic(self) -> Self::Styled

Applies the Italic attribute to the text.

Source

fn negative(self) -> Self::Styled

Applies the Reverse attribute to the text.

Applies the SlowBlink attribute to the text.

Applies the RapidBlink attribute to the text.

Source

fn hidden(self) -> Self::Styled

Applies the Hidden attribute to the text.

Source

fn crossed_out(self) -> Self::Styled

Applies the CrossedOut attribute to the text.

Source

fn black(self) -> Self::Styled

Sets the foreground color to Black.

Source

fn on_black(self) -> Self::Styled

Sets the background color to Black.

Source

fn underline_black(self) -> Self::Styled

Sets the underline color to Black.

Source

fn dark_grey(self) -> Self::Styled

Sets the foreground color to DarkGrey.

Source

fn on_dark_grey(self) -> Self::Styled

Sets the background color to DarkGrey.

Source

fn underline_dark_grey(self) -> Self::Styled

Sets the underline color to DarkGrey.

Source

fn red(self) -> Self::Styled

Sets the foreground color to Red.

Source

fn on_red(self) -> Self::Styled

Sets the background color to Red.

Source

fn underline_red(self) -> Self::Styled

Sets the underline color to Red.

Source

fn dark_red(self) -> Self::Styled

Sets the foreground color to DarkRed.

Source

fn on_dark_red(self) -> Self::Styled

Sets the background color to DarkRed.

Source

fn underline_dark_red(self) -> Self::Styled

Sets the underline color to DarkRed.

Source

fn green(self) -> Self::Styled

Sets the foreground color to Green.

Source

fn on_green(self) -> Self::Styled

Sets the background color to Green.

Source

fn underline_green(self) -> Self::Styled

Sets the underline color to Green.

Source

fn dark_green(self) -> Self::Styled

Sets the foreground color to DarkGreen.

Source

fn on_dark_green(self) -> Self::Styled

Sets the background color to DarkGreen.

Source

fn underline_dark_green(self) -> Self::Styled

Sets the underline color to DarkGreen.

Source

fn yellow(self) -> Self::Styled

Sets the foreground color to Yellow.

Source

fn on_yellow(self) -> Self::Styled

Sets the background color to Yellow.

Source

fn underline_yellow(self) -> Self::Styled

Sets the underline color to Yellow.

Source

fn dark_yellow(self) -> Self::Styled

Sets the foreground color to DarkYellow.

Source

fn on_dark_yellow(self) -> Self::Styled

Sets the background color to DarkYellow.

Source

fn underline_dark_yellow(self) -> Self::Styled

Sets the underline color to DarkYellow.

Source

fn blue(self) -> Self::Styled

Sets the foreground color to Blue.

Source

fn on_blue(self) -> Self::Styled

Sets the background color to Blue.

Source

fn underline_blue(self) -> Self::Styled

Sets the underline color to Blue.

Source

fn dark_blue(self) -> Self::Styled

Sets the foreground color to DarkBlue.

Source

fn on_dark_blue(self) -> Self::Styled

Sets the background color to DarkBlue.

Source

fn underline_dark_blue(self) -> Self::Styled

Sets the underline color to DarkBlue.

Source

fn magenta(self) -> Self::Styled

Sets the foreground color to Magenta.

Source

fn on_magenta(self) -> Self::Styled

Sets the background color to Magenta.

Source

fn underline_magenta(self) -> Self::Styled

Sets the underline color to Magenta.

Source

fn dark_magenta(self) -> Self::Styled

Sets the foreground color to DarkMagenta.

Source

fn on_dark_magenta(self) -> Self::Styled

Sets the background color to DarkMagenta.

Source

fn underline_dark_magenta(self) -> Self::Styled

Sets the underline color to DarkMagenta.

Source

fn cyan(self) -> Self::Styled

Sets the foreground color to Cyan.

Source

fn on_cyan(self) -> Self::Styled

Sets the background color to Cyan.

Source

fn underline_cyan(self) -> Self::Styled

Sets the underline color to Cyan.

Source

fn dark_cyan(self) -> Self::Styled

Sets the foreground color to DarkCyan.

Source

fn on_dark_cyan(self) -> Self::Styled

Sets the background color to DarkCyan.

Source

fn underline_dark_cyan(self) -> Self::Styled

Sets the underline color to DarkCyan.

Source

fn white(self) -> Self::Styled

Sets the foreground color to White.

Source

fn on_white(self) -> Self::Styled

Sets the background color to White.

Source

fn underline_white(self) -> Self::Styled

Sets the underline color to White.

Source

fn grey(self) -> Self::Styled

Sets the foreground color to Grey.

Source

fn on_grey(self) -> Self::Styled

Sets the background color to Grey.

Source

fn underline_grey(self) -> Self::Styled

Sets the underline color to Grey.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Stylize for &str

Source§

impl Stylize for char

Source§

impl Stylize for String

Implementors§