Struct owo_colors::Style[][src]

pub struct Style { /* fields omitted */ }

A pre-computed style that can be applied to a struct using OwoColorize::style

Implementations

impl Style[src]

pub fn new() -> Self[src]

Create a new style to be applied later

pub fn style<T>(&self, target: T) -> Styled<T>[src]

Apply the style to a given struct to output

pub fn fg<C: Color>(self) -> Self[src]

Set the foreground color generically

use owo_colors::{OwoColorize, colors::*};

println!("{}", "red foreground".fg::<Red>());

pub fn bg<C: Color>(self) -> Self[src]

Set the background color generically.

use owo_colors::{OwoColorize, colors::*};

println!("{}", "black background".bg::<Black>());

pub fn black(self) -> Self[src]

Change the foreground color to black

pub fn on_black(self) -> Self[src]

Change the foreground color to black

pub fn red(self) -> Self[src]

Change the foreground color to red

pub fn on_red(self) -> Self[src]

Change the foreground color to red

pub fn green(self) -> Self[src]

Change the foreground color to green

pub fn on_green(self) -> Self[src]

Change the foreground color to green

pub fn yellow(self) -> Self[src]

Change the foreground color to yellow

pub fn on_yellow(self) -> Self[src]

Change the foreground color to yellow

pub fn blue(self) -> Self[src]

Change the foreground color to blue

pub fn on_blue(self) -> Self[src]

Change the foreground color to blue

pub fn magenta(self) -> Self[src]

Change the foreground color to magenta

pub fn on_magenta(self) -> Self[src]

Change the foreground color to magenta

pub fn purple(self) -> Self[src]

Change the foreground color to purple

pub fn on_purple(self) -> Self[src]

Change the foreground color to purple

pub fn cyan(self) -> Self[src]

Change the foreground color to cyan

pub fn on_cyan(self) -> Self[src]

Change the foreground color to cyan

pub fn white(self) -> Self[src]

Change the foreground color to white

pub fn on_white(self) -> Self[src]

Change the foreground color to white

pub fn bright_black(self) -> Self[src]

Change the foreground color to bright black

pub fn on_bright_black(self) -> Self[src]

Change the foreground color to bright black

pub fn bright_red(self) -> Self[src]

Change the foreground color to bright red

pub fn on_bright_red(self) -> Self[src]

Change the foreground color to bright red

pub fn bright_green(self) -> Self[src]

Change the foreground color to bright green

pub fn on_bright_green(self) -> Self[src]

Change the foreground color to bright green

pub fn bright_yellow(self) -> Self[src]

Change the foreground color to bright yellow

pub fn on_bright_yellow(self) -> Self[src]

Change the foreground color to bright yellow

pub fn bright_blue(self) -> Self[src]

Change the foreground color to bright blue

pub fn on_bright_blue(self) -> Self[src]

Change the foreground color to bright blue

pub fn bright_magenta(self) -> Self[src]

Change the foreground color to bright magenta

pub fn on_bright_magenta(self) -> Self[src]

Change the foreground color to bright magenta

pub fn bright_purple(self) -> Self[src]

Change the foreground color to bright purple

pub fn on_bright_purple(self) -> Self[src]

Change the foreground color to bright purple

pub fn bright_cyan(self) -> Self[src]

Change the foreground color to bright cyan

pub fn on_bright_cyan(self) -> Self[src]

Change the foreground color to bright cyan

pub fn bright_white(self) -> Self[src]

Change the foreground color to bright white

pub fn on_bright_white(self) -> Self[src]

Change the foreground color to bright white

pub fn bold(self) -> Self[src]

Make the text bold

pub fn dimmed(self) -> Self[src]

Make the text dim

pub fn italic(self) -> Self[src]

Make the text italicized

pub fn underline(self) -> Self[src]

Make the text italicized

Make the text blink

Make the text blink (but fast!)

pub fn reversed(self) -> Self[src]

Swap the foreground and background colors

pub fn hidden(self) -> Self[src]

Hide the text

pub fn strikethrough(self) -> Self[src]

Cross out the text

pub fn effect(self, effect: Effect) -> Self[src]

Apply a given effect from the style

pub fn remove_effect(self, effect: Effect) -> Self[src]

Remove a given effect from the style

pub fn effects(self, effects: &[Effect]) -> Self[src]

Apply a given set of effects to the style

pub fn remove_effects(self, effects: &[Effect]) -> Self[src]

Remove a given set of effects from the style

pub fn remove_all_effects(self) -> Self[src]

Disables all the given effects from the style

pub fn color<Color: DynColor>(self, color: Color) -> Self[src]

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green,

use owo_colors::{OwoColorize, AnsiColors};

fn main() {
    println!("{}", "green".color(AnsiColors::Green));
}

pub fn on_color<Color: DynColor>(self, color: Color) -> Self[src]

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow,

use owo_colors::{OwoColorize, AnsiColors};

fn main() {
    println!("{}", "yellow background".on_color(AnsiColors::BrightYellow));
}

pub fn fg_rgb<const R: u8, const G: u8, const B: u8>(self) -> Self[src]

Set the foreground color to a specific RGB value.

pub fn bg_rgb<const R: u8, const G: u8, const B: u8>(self) -> Self[src]

Set the background color to a specific RGB value.

pub fn truecolor(self, r: u8, g: u8, b: u8) -> Self[src]

Sets the foreground color to an RGB value.

pub fn on_truecolor(self, r: u8, g: u8, b: u8) -> Self[src]

Sets the background color to an RGB value.

Trait Implementations

impl Clone for Style[src]

impl Copy for Style[src]

impl Debug for Style[src]

impl Default for Style[src]

Auto Trait Implementations

impl Send for Style

impl Sync for Style

impl Unpin for Style

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<D> OwoColorize for D[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.