Expand description
§simply_colored
This crate is the simplest yet ergonomic way to add color to your terminal:
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! |
Underline | {UNDERLINE}Simply colored! |
Blink | {BLINK}Simply colored! |
Reverse | {REVERSE}Simply colored! |
{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
.
§Extra
If you want links in the terminal, all you need is:
fn hyperlink(link: impl core::fmt::Display, text: impl core::fmt::Display) -> String {
format!("\x1b]8;;{link}\x1b\\{text}\x1b]8;;\x1b\\")
}
Example usage:
println!(
"Check out simply_colored on {}!",
hyperlink(
"https://github.com/nik-rev/simply-colored",
"GitHub"
)
);
Constants§
- BG_
BLACK - Set background of text to black
- BG_BLUE
- Set background of text to blue
- BG_CYAN
- Set background of text to cyan
- BG_
DEFAULT - Set background of text to default
- BG_
DIM_ BLACK - Set background of text to dim black
- BG_
DIM_ BLUE - Set background of text to dim blue
- BG_
DIM_ CYAN - Set background of text to dim cyan
- BG_
DIM_ DEFAULT - Set background of text to default
- BG_
DIM_ GREEN - Set background of text to dim green
- BG_
DIM_ MAGENTA - Set background of text to dim magenta
- BG_
DIM_ RED - Set background of text to dim red
- BG_
DIM_ WHITE - Set background of text to dim white
- BG_
DIM_ YELLOW - Set background of text to dim yellow
- BG_
GREEN - Set background of text to green
- BG_
MAGENTA - Set background of text to magenta
- BG_RED
- Set background of text to red
- BG_
WHITE - Set background of text to white
- BG_
YELLOW - Set background of text to yellow
- BLACK
- Set color of text to black
- BLINK
- Following text will be blinking
- BLUE
- Set color of text to blue
- BOLD
- Following text will be bold
- CYAN
- Set color of text to cyan
- DEFAULT
- Set color of text to default
- DIM
- Following text will be dim
- DIM_
BLACK - Set color of text to dim black
- DIM_
BLUE - Set color of text to dim blue
- DIM_
CYAN - Set color of text to dim cyan
- DIM_
DEFAULT - Set color of text to default
- DIM_
GREEN - Set color of text to dim green
- DIM_
MAGENTA - Set color of text to dim magenta
- DIM_RED
- Set color of text to dim red
- DIM_
WHITE - Set color of text to dim white
- DIM_
YELLOW - Set color of text to dim yellow
- GREEN
- Set color of text to green
- HIDE
- Following text will be invisible
- ITALIC
- Following text will be italic
- MAGENTA
- Set color of text to magenta
- NO_
BLINK - Following text will NOT be blinking
- NO_BOLD
- Following text will NOT be bold
- NO_DIM
- Following text will NOT be dim
- NO_HIDE
- Following text will be visible
- NO_
ITALIC - Following text will NOT be italic
- NO_
REVERSE - Foreground and background for the following text will NOT be reversed
- NO_
STRIKETHROUGH - Following text will NOT be crossed out
- NO_
UNDERLINE - Following text will NOT be underlined
- RED
- Set color of text to red
- RESET
- Reset styling
- REVERSE
- Foreground and background for the following text will be reversed
- STRIKETHROUGH
- Following text will be crossed out
- UNDERLINE
- Following text will be underlined
- WHITE
- Set color of text to white
- YELLOW
- Set color of text to yellow