Crate owo_colors[][src]

This crate provides OwoColorize, an extension trait for colorizing a formatter.

Example

use owo_colors::OwoColorize;

fn main() {
    // Foreground colors
    println!("My number is {:#x}!", 10.green());
    // Background colors
    println!("My number is not {}!", 4.on_red());
}

Generically color

use owo_colors::OwoColorize;
use owo_colors::colors::*;

fn main() {
    // Generically color
    println!("My number might be {}!", 4.fg::<Black>().bg::<Yellow>());
}

Stylize

use owo_colors::OwoColorize;

println!("{}", "strikethrough".strikethrough());

Modules

colored

Module for drop-in colored support to aid in porting code from colored to owo-colors.

colors

Color types for used for being generic over the color

styles

Different display styles (strikethrough, bold, etc.)

Structs

BgColorDisplay

Transparent wrapper around a type which implements all the formatters the wrapped type does, with the addition of changing the background color. Recommended to be constructed using OwoColorize.

BgDynColorDisplay

Wrapper around a type which implements all the formatters the wrapped type does, with the addition of changing the background color. Is not recommended unless compile-time coloring is not an option.

FgColorDisplay

Transparent wrapper around a type which implements all the formatters the wrapped type does, with the addition of changing the foreground color. Recommended to be constructed using OwoColorize.

FgDynColorDisplay

Wrapper around a type which implements all the formatters the wrapped type does, with the addition of changing the foreground color. Is not recommended unless compile-time coloring is not an option.

ParseColorError

An error for when the color can not be parsed from a string at runtime

Rgb

Available RGB colors for use with OwoColorize::color or OwoColorize::on_color

Style

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

Styled

A struct with a Style applied to it

TtyDisplay

A display which applies a transformation based on if the given stream is a tty

Enums

AnsiColors

Available standard ANSI colors for use with OwoColorize::color or OwoColorize::on_color

CssColors

Available CSS colors for use with OwoColorize::color or OwoColorize::on_color

DynColors

An enum describing runtime-configurable colors which can be displayed using FgDynColorDisplay or BgDynColorDisplay, allowing for multiple types of colors to be used at runtime.

Effect

A runtime-configurable text effect for use with Style

XtermColors

Available Xterm colors for use with OwoColorize::color or OwoColorize::on_color

Traits

Color

A trait for describing a type which can be used with FgColorDisplay or BgCBgColorDisplay

DynColor

A trait describing a runtime-configurable color which can displayed using FgDynColorDisplay or BgDynColorDisplay. If your color will be known at compile time it is recommended you avoid this.

OwoColorize

Extension trait for colorizing a type which implements any std formatter (Display, Debug, UpperHex, etc.)

Functions

style

Helper to create Styles more ergonomically