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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
//!
//! This crate is the simplest yet ergonomic way to add color to your terminal.
//!
//! ```toml
//! ```
//!
//! All this crate contains is a few dozen `const`ants corresponding to particular ANSI escape codes.
//!
//! # Usage
//!
//! ```rust
//! use simply_colored::*;
//!
//! println!("{BLUE}{BOLD}Simply colored!")
//! ```
//!
//! ## Foreground
//!
//! | Color | Type | To get |
//! | ----- | ------------------ | ------- |
//! |  | `{GREEN}Simply colored!` |  |
//! |  | `{YELLOW}Simply colored!` |  |
//! |  | `{RED}Simply colored!` |  |
//! |  | `{MAGENTA}Simply colored!` |  |
//! |  | `{BLUE}Simply colored!` |  |
//! |  | `{CYAN}Simply colored!` |  |
//! |  | `{WHITE}Simply colored!` |  |
//! |  | `{BLACK}Simply colored!` |  |
//! |  | `{DIM_GREEN}Simply colored!` |  |
//! |  | `{DIM_YELLOW}Simply colored!` |  |
//! |  | `{DIM_RED}Simply colored!` |  |
//! |  | `{DIM_MAGENTA}Simply colored!` |  |
//! |  | `{DIM_BLUE}Simply colored!` |  |
//! |  | `{DIM_CYAN}Simply colored!` |  |
//! |  | `{DIM_WHITE}Simply colored!` |  |
//! |  | `{DIM_BLACK}Simply colored!` |  |
//!
//! ## Background
//!
//! | Color | Type | To get |
//! | ----- | ------------------ | ------- |
//! |  | `{BG_GREEN}Simply colored!` |  |
//! |  | `{BG_YELLOW}Simply colored!` |  |
//! |  | `{BG_RED}Simply colored!` |  |
//! |  | `{BG_MAGENTA}Simply colored!` |  |
//! |  | `{BG_BLUE}Simply colored!` |  |
//! |  | `{BG_CYAN}Simply colored!` |  |
//! |  | `{BG_WHITE}Simply colored!` |  |
//! |  | `{BG_BLACK}Simply colored!` |  |
//! |  | `{BG_DIM_GREEN}Simply colored!` |  |
//! |  | `{BG_DIM_YELLOW}Simply colored!` |  |
//! |  | `{BG_DIM_RED}Simply colored!` |  |
//! |  | `{BG_DIM_MAGENTA}Simply colored!` |  |
//! |  | `{BG_DIM_BLUE}Simply colored!` |  |
//! |  | `{BG_DIM_CYAN}Simply colored!` |  |
//! |  | `{BG_DIM_WHITE}Simply colored!` |  |
//! |  | `{BG_DIM_BLACK}Simply colored!` |  |
//!
//! ## Effects
//!
//! | Effect | Type |
//! | ------ | ----- |
//! | *Italic* | `{ITALIC}Simply colored!` |
//! | **Bold** | `{BOLD}Simply colored!` |
//! | <u>Underline</u> | `{UNDERLINE}Simply colored!` |
//! | Blink | `{BLINK}Simply colored!` |
//! | Reverse | `{REVERSE}Simply colored!` |
//! | <del>Strikethrough</del> | `{STRIKETHROUGH}Simply colored!` |
//! | Dim | `{DIM}Simply colored!` |
//! | Hide | `{HIDE}Simply colored!` |
//! | Reset all styles | `{RESET}Simply colored!` |
//!
//! All effects can be prefixed with `NO_` to disable e.g. `NO_BOLD`.
//!
//! # Remove colors when they are not supported
//!
//! You can use the `anstream` crate to remove colors when they aren't supported:
//!
//! ```rust
//! # extern crate anstream;
//! use anstream::println;
//! use simply_colored::*;
//!
//! println!("My number is {GREEN}10{RESET}!");
//! println!("My number is not {RED}4{RESET}!");
//! ```
//!
//! # Links
//!
//! If you want links in the terminal, all you need is:
//!
//! ```rust
//! fn hyperlink(link: impl core::fmt::Display, text: impl core::fmt::Display) -> String {
//! format!("\x1b]8;;{link}\x1b\\{text}\x1b]8;;\x1b\\")
//! }
//! ```
//!
//! Example usage:
//!
//! ```rust
//! # fn hyperlink(link: impl core::fmt::Display, text: impl core::fmt::Display) -> String {
//! # format!("\x1b]8;;{link}\x1b\\{text}\x1b]8;;\x1b\\")
//! # }
//! println!(
//! "Check out simply_colored on {}!",
//! hyperlink(
//! "https://github.com/nik-rev/simply-colored",
//! "GitHub"
//! )
//! );
//! ```
/// Reset styling
pub const RESET: &str = "\x1b[0m";
/// Following text will be bold
pub const BOLD: &str = "\x1b[1m";
/// Following text will NOT be bold
pub const NO_BOLD: &str = "\x1b[22m";
/// Following text will be dim
pub const DIM: &str = "\x1b[2m";
/// Following text will NOT be dim
pub const NO_DIM: &str = "\x1b[22m";
/// Following text will be italic
pub const ITALIC: &str = "\x1b[3m";
/// Following text will NOT be italic
pub const NO_ITALIC: &str = "\x1b[23m";
/// Following text will be underlined
pub const UNDERLINE: &str = "\x1b[4m";
/// Following text will NOT be underlined
pub const NO_UNDERLINE: &str = "\x1b[24m";
/// Following text will be blinking
pub const BLINK: &str = "\x1b[5m";
/// Following text will NOT be blinking
pub const NO_BLINK: &str = "\x1b[25m";
/// Foreground and background for the following text will be reversed
pub const REVERSE: &str = "\x1b[7m";
/// Foreground and background for the following text will NOT be reversed
pub const NO_REVERSE: &str = "\x1b[27m";
/// Following text will be invisible
pub const HIDE: &str = "\x1b[8m";
/// Following text will be visible
pub const NO_HIDE: &str = "\x1b[28m";
/// Following text will be crossed out
pub const STRIKETHROUGH: &str = "\x1b[9m";
/// Following text will NOT be crossed out
pub const NO_STRIKETHROUGH: &str = "\x1b[29m";
/// Set color of text to black
pub const BLACK: &str = "\x1b[90m";
/// Set background of text to black
pub const BG_BLACK: &str = "\x1b[100m";
/// Set color of text to dim black
pub const DIM_BLACK: &str = "\x1b[30m";
/// Set background of text to dim black
pub const BG_DIM_BLACK: &str = "\x1b[40m";
/// Set color of text to red
pub const RED: &str = "\x1b[91m";
/// Set background of text to red
pub const BG_RED: &str = "\x1b[101m";
/// Set color of text to dim red
pub const DIM_RED: &str = "\x1b[31m";
/// Set background of text to dim red
pub const BG_DIM_RED: &str = "\x1b[41m";
/// Set color of text to green
pub const GREEN: &str = "\x1b[92m";
/// Set background of text to green
pub const BG_GREEN: &str = "\x1b[102m";
/// Set color of text to dim green
pub const DIM_GREEN: &str = "\x1b[32m";
/// Set background of text to dim green
pub const BG_DIM_GREEN: &str = "\x1b[42m";
/// Set color of text to yellow
pub const YELLOW: &str = "\x1b[93m";
/// Set background of text to yellow
pub const BG_YELLOW: &str = "\x1b[103m";
/// Set color of text to dim yellow
pub const DIM_YELLOW: &str = "\x1b[33m";
/// Set background of text to dim yellow
pub const BG_DIM_YELLOW: &str = "\x1b[43m";
/// Set color of text to blue
pub const BLUE: &str = "\x1b[94m";
/// Set background of text to blue
pub const BG_BLUE: &str = "\x1b[104m";
/// Set color of text to dim blue
pub const DIM_BLUE: &str = "\x1b[34m";
/// Set background of text to dim blue
pub const BG_DIM_BLUE: &str = "\x1b[44m";
/// Set color of text to magenta
pub const MAGENTA: &str = "\x1b[95m";
/// Set background of text to magenta
pub const BG_MAGENTA: &str = "\x1b[105m";
/// Set color of text to dim magenta
pub const DIM_MAGENTA: &str = "\x1b[35m";
/// Set background of text to dim magenta
pub const BG_DIM_MAGENTA: &str = "\x1b[45m";
/// Set color of text to cyan
pub const CYAN: &str = "\x1b[96m";
/// Set background of text to cyan
pub const BG_CYAN: &str = "\x1b[106m";
/// Set color of text to dim cyan
pub const DIM_CYAN: &str = "\x1b[36m";
/// Set background of text to dim cyan
pub const BG_DIM_CYAN: &str = "\x1b[46m";
/// Set color of text to white
pub const WHITE: &str = "\x1b[97m";
/// Set background of text to white
pub const BG_WHITE: &str = "\x1b[107m";
/// Set color of text to dim white
pub const DIM_WHITE: &str = "\x1b[37m";
/// Set background of text to dim white
pub const BG_DIM_WHITE: &str = "\x1b[47m";
/// Set color of text to default
pub const DEFAULT: &str = "\x1b[99m";
/// Set background of text to default
pub const BG_DEFAULT: &str = "\x1b[109m";
/// Set color of text to default
pub const DIM_DEFAULT: &str = "\x1b[39m";
/// Set background of text to default
pub const BG_DIM_DEFAULT: &str = "\x1b[49m";