Expand description
| Quick Links | OwoColorize | Style | StyledList | github |
|---|
This crate provides OwoColorize, an extension trait for colorizing a
given type.
§Example
use owo_colors::OwoColorize;
// 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::*;
// Generically color
println!("My number might be {}!", 4.fg::<Black>().bg::<Yellow>());§Stylize
use owo_colors::OwoColorize;
println!("{}", "strikethrough".strikethrough());§Only Style on Supported Terminals
use owo_colors::{OwoColorize, Stream::Stdout};
println!(
"{}",
"colored blue if a supported terminal"
.if_supports_color(Stdout, |text| text.bright_blue())
);Supports NO_COLOR/FORCE_COLOR environment variables, checks if it’s a tty, checks
if it’s running in CI (and thus likely supports color), and checks which terminal is being
used. (Note: requires supports-colors feature)
§Style Objects
owo-colors also features the ability to create a Style object and use it to
apply the same set of colors/effects to any number of things to display.
use owo_colors::{OwoColorize, Style};
let my_style = Style::new()
.red()
.on_white()
.strikethrough();
let text = "red text, white background, struck through";
println!("{}", text.style(my_style));Modules§
- colored
- Module for drop-in
coloredsupport to aid in porting code fromcoloredto owo-colors. - colors
- Color types for used for being generic over the color
- styles
- Different display styles (strikethrough, bold, etc.)
Structs§
- BgColor
Display - 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. - BgDyn
Color Display - 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.
- Combo
Color Display - A wrapper type which applies both a foreground and background color
- Combo
DynColor Display - Wrapper around a type which implements all the formatters the wrapped type does, with the addition of changing the foreground and background color.
- FgColor
Display - 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. - FgDyn
Color Display - 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.
- Parse
Color Error - An error for when the color can not be parsed from a string at runtime
- Rgb
- Available RGB colors for use with
OwoColorize::colororOwoColorize::on_color - Style
- A pre-computed style that can be applied to a struct using
OwoColorize::style. - Style
Prefix Formatter - Formatter for the prefix of a
Style. - Style
Suffix Formatter - Formatter for the suffix of a
Style. - Styled
- A wrapper type which applies a
Stylewhen displaying the inner type - Styled
List - A collection of
Styleditems that are displayed in such a way as to minimize the amount of characters that are written when displayed.
Enums§
- Ansi
Colors - Available standard ANSI colors for use with
OwoColorize::colororOwoColorize::on_color - CssColors
- Available CSS colors for use with
OwoColorize::colororOwoColorize::on_color - DynColors
- An enum describing runtime-configurable colors
- Effect
- A runtime-configurable text effect for use with
Style - Xterm
Colors - Available Xterm colors for use with
OwoColorize::colororOwoColorize::on_color
Traits§
- Color
- A trait for describing a type which can be used with
FgColorDisplayorBgColorDisplay - DynColor
- A trait describing a runtime-configurable color which can displayed using
FgDynColorDisplayorBgDynColorDisplay. 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.)