1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! This crate provides utilities for coloring and styling strings.
//!
//! # Example
//!
//! ```rust,no_run
//! use chromaterm::prelude::*;
//!
//! // This configures the crate to automatically detect what colors are supported by
//! // the user's terminal. If the user's environment doesn't support the colors you
//! // use, it will automatically try to convert to a supported color value. Not all
//! // terminals support "true colors" (RGB), for example.
//! chromaterm::config::use_default_color_support();
//! chromaterm::config::convert_to_supported(true);
//!
//! println!("Hello, {}!", "World".green().italic().on_rgb(0, 64, 255));
//! ```
//!
//! ## Advanced usage
//!
//! ### Color support
//!
//! If you want to have more control over how color support is detected, use the
//! [`ColorSupport`] type.
//!
//! ```rust,no_run
//! use chromaterm::ColorSupport;
//!
//! // Detects support from the environment, and additionally respects the well-known
//! // NO_COLOR environment variable.
//! let support = ColorSupport::from_env().respect_no_color();
//! chromaterm::config::use_color_support(support);
//! ```
//!
//! ### Configuration
//!
//! ```rust
//! use chromaterm::prelude::*;
//! use chromaterm::ColorSupport;
//!
//! // Full color support ("true colors" are supported).
//! chromaterm::config::use_color_support(ColorSupport::True);
//! assert_eq!("styled".rgb(255, 0, 0).to_string(), "\x1B[38;2;255;0;0mstyled\x1B[0m");
//!
//! // Only the basic 16 colors are supported, and we try to convert to the closest
//! // color.
//! chromaterm::config::use_color_support(ColorSupport::Simple);
//! chromaterm::config::convert_to_supported(true);
//! assert_eq!("bright red".rgb(255, 0, 0).to_string(), "bright red".bright_red().to_string());
//!
//! // Now we refuse to convert to supported colors. If our color can't be displayed,
//! // we won't color at all! This can be useful if you feel that converting to less
//! // accurate colors can ruin the look of your output, and it's better to fall back
//! // to uncolored text.
//! chromaterm::config::convert_to_supported(false);
//! assert_eq!("not bright red".rgb(255, 0, 0).to_string(), "not bright red");
//!
//! // No colors are supported.
//! chromaterm::config::use_color_support(ColorSupport::None);
//!
//! // Because no colors are supported, the string is plain.
//! assert_eq!("not styled".rgb(255, 0, 0).to_string(), "not styled");
//! ```
pub use Color;
pub use ColorLevel;
pub use ColorSupport;
pub use Colorize;
pub use Colorizer;
pub use Colors;
pub use ;
pub use Style;
pub use Styler;
pub use Styles;
pub use Stylize;