Crates.io | zen-colour |
lib.rs | zen-colour |
version | 1.1.2 |
source | src |
created_at | 2023-07-30 20:40:36.11994 |
updated_at | 2024-05-25 00:51:11.255281 |
description | The most minimal terminal colour and style crate. |
homepage | |
repository | https://github.com/codybloemhard/zen-colour |
max_upload_size | |
id | 930257 |
size | 7,106 |
The most minimal terminal colour and style crate. Contains constants with colour and style codes. Just throw them into your string and bob's your uncle.
use zen_colour::*;
println!("{}this is red{}", RED, RESET);
println!("{BLUE}blue{RESET}");
println!("{r}r{g}g{r}r{g}g{r}r{g}g", r = RED, g = GREEN);
Styles:
Text colours:
Background colours:
If you don't like the constant names.
use zen_colours::*;
const R: &str = RED;
The standard colours are chosen by the user. They want to see those colours. The non standard colours (RGB for example) are not chosen by the user. They will just clash with the standard colours and your application will not look consistent with other programs on the users system. They must never be used unless you are doing some kind of graphics, as opposed to UI. This is why this crate just does not support them. This battle is unfortunately lost in the GUI space. May the terminal stay strong.
There are many crates that do the same. With all kinds of handy functions. There are different styles of library design.
println!("red".colour(red))
print_colour("red", red);
But in the end, it all annoyed me, especially when do doing more complex colouring.
For example, if you want to colour a date string but want all the '/' to be faint.
Then have more colours in the same line for different values.
This is just a mess or mega verbose with any library design no matter how reasonable.
I just ended up throwing the colour codes right into the print!
or format!
.
And now we are here.
Nice, easy, clean, no complexity, just colours and styles.
no.