devela::_dep::crossterm::style

Trait Stylize

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 { ... }
}
Available on crate features dep_crossterm and std only.
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§

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

This type with styles applied.

Required Methods§

fn stylize(self) -> Self::Styled

Styles this type.

Provided Methods§

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

Sets the foreground color.

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

Sets the background color.

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

Sets the underline color.

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

Styles the content with the attribute.

fn reset(self) -> Self::Styled

Applies the Reset attribute to the text.

fn bold(self) -> Self::Styled

Applies the Bold attribute to the text.

fn underlined(self) -> Self::Styled

Applies the Underlined attribute to the text.

fn reverse(self) -> Self::Styled

Applies the Reverse attribute to the text.

fn dim(self) -> Self::Styled

Applies the Dim attribute to the text.

fn italic(self) -> Self::Styled

Applies the Italic attribute to the text.

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.

fn hidden(self) -> Self::Styled

Applies the Hidden attribute to the text.

fn crossed_out(self) -> Self::Styled

Applies the CrossedOut attribute to the text.

fn black(self) -> Self::Styled

Sets the foreground color to Black.

fn on_black(self) -> Self::Styled

Sets the background color to Black.

fn underline_black(self) -> Self::Styled

Sets the underline color to Black.

fn dark_grey(self) -> Self::Styled

Sets the foreground color to DarkGrey.

fn on_dark_grey(self) -> Self::Styled

Sets the background color to DarkGrey.

fn underline_dark_grey(self) -> Self::Styled

Sets the underline color to DarkGrey.

fn red(self) -> Self::Styled

Sets the foreground color to Red.

fn on_red(self) -> Self::Styled

Sets the background color to Red.

fn underline_red(self) -> Self::Styled

Sets the underline color to Red.

fn dark_red(self) -> Self::Styled

Sets the foreground color to DarkRed.

fn on_dark_red(self) -> Self::Styled

Sets the background color to DarkRed.

fn underline_dark_red(self) -> Self::Styled

Sets the underline color to DarkRed.

fn green(self) -> Self::Styled

Sets the foreground color to Green.

fn on_green(self) -> Self::Styled

Sets the background color to Green.

fn underline_green(self) -> Self::Styled

Sets the underline color to Green.

fn dark_green(self) -> Self::Styled

Sets the foreground color to DarkGreen.

fn on_dark_green(self) -> Self::Styled

Sets the background color to DarkGreen.

fn underline_dark_green(self) -> Self::Styled

Sets the underline color to DarkGreen.

fn yellow(self) -> Self::Styled

Sets the foreground color to Yellow.

fn on_yellow(self) -> Self::Styled

Sets the background color to Yellow.

fn underline_yellow(self) -> Self::Styled

Sets the underline color to Yellow.

fn dark_yellow(self) -> Self::Styled

Sets the foreground color to DarkYellow.

fn on_dark_yellow(self) -> Self::Styled

Sets the background color to DarkYellow.

fn underline_dark_yellow(self) -> Self::Styled

Sets the underline color to DarkYellow.

fn blue(self) -> Self::Styled

Sets the foreground color to Blue.

fn on_blue(self) -> Self::Styled

Sets the background color to Blue.

fn underline_blue(self) -> Self::Styled

Sets the underline color to Blue.

fn dark_blue(self) -> Self::Styled

Sets the foreground color to DarkBlue.

fn on_dark_blue(self) -> Self::Styled

Sets the background color to DarkBlue.

fn underline_dark_blue(self) -> Self::Styled

Sets the underline color to DarkBlue.

fn magenta(self) -> Self::Styled

Sets the foreground color to Magenta.

fn on_magenta(self) -> Self::Styled

Sets the background color to Magenta.

fn underline_magenta(self) -> Self::Styled

Sets the underline color to Magenta.

fn dark_magenta(self) -> Self::Styled

Sets the foreground color to DarkMagenta.

fn on_dark_magenta(self) -> Self::Styled

Sets the background color to DarkMagenta.

fn underline_dark_magenta(self) -> Self::Styled

Sets the underline color to DarkMagenta.

fn cyan(self) -> Self::Styled

Sets the foreground color to Cyan.

fn on_cyan(self) -> Self::Styled

Sets the background color to Cyan.

fn underline_cyan(self) -> Self::Styled

Sets the underline color to Cyan.

fn dark_cyan(self) -> Self::Styled

Sets the foreground color to DarkCyan.

fn on_dark_cyan(self) -> Self::Styled

Sets the background color to DarkCyan.

fn underline_dark_cyan(self) -> Self::Styled

Sets the underline color to DarkCyan.

fn white(self) -> Self::Styled

Sets the foreground color to White.

fn on_white(self) -> Self::Styled

Sets the background color to White.

fn underline_white(self) -> Self::Styled

Sets the underline color to White.

fn grey(self) -> Self::Styled

Sets the foreground color to Grey.

fn on_grey(self) -> Self::Styled

Sets the background color to Grey.

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§

§

impl Stylize for &str

§

impl Stylize for char

Implementors§