Crates.io | colorism |
lib.rs | colorism |
version | 0.1.0 |
source | src |
created_at | 2022-07-04 20:59:47.460643 |
updated_at | 2022-07-04 20:59:47.460643 |
description | A library to use terminal ANSI colors |
homepage | https://github.com/z3oxs/colorism |
repository | https://github.com/z3oxs/colorism |
max_upload_size | |
id | 619197 |
size | 6,881 |
A library to use terminal ANSI colors
cargo add colorism
Using the foreground method:
// Import the fore method and RESET
use colorism::{foreground::Fore, util::RESET};
// Use RESET on all string ends, if you don't, the colors will escape to your terminal and will be really ugly, but not danger.
fn main() {
// Green regular text
println!("{}Hello, world!{}", Fore::color(Fore::Green), RESET);
// Green bold text
println!("{}Hello, world!{}", Fore::color(Fore::BdGreen), RESET);
}
Using the background method:
use colorism::{background::Back, util::RESET};
// Use RESET on all string ends, if you don't, the colors will escape to your terminal and will be really ugly, but not danger.
fn main() {
// Green background, white text
println!("{}Hello, world!{}", Back::color(Back::Green), RESET);
// Green background, white bold text
println!("{}Hello, world!{}", Back::color(Fore::BdGreen), RESET);
}
Using the utils:
// Import the util and (We will use Style to styling texts) RESET
use colorism::util::{Style, RESET};
// Use RESET on all string ends, if you don't, the colors will escape to your terminal and will be really ugly, but not danger.
fn main() {
// Simple bold text
println!("{}I am a text{}", Style::text(Style::Bold), RESET);
// Simple underline text
println!("{}I am a text{}", Style::text(Style::Underline), RESET);
}