ansi-hex-color

Crates.ioansi-hex-color
lib.rsansi-hex-color
version0.1.1
sourcesrc
created_at2021-04-29 19:42:26.863358
updated_at2021-04-30 05:33:52.273702
descriptionColor the text on the terminal with ANSI and hex-code
homepage
repositoryhttps://github.com/hideckies/ansi-hex-color
max_upload_size
id391234
size18,162
hdks (hideckies)

documentation

https://docs.rs/ansi-hex-color

README

ansi-hex-color

anti-hex-color is a Rust library which color (ANSI 256-color) the given text in terminal.
Since you can specify the color with hex code, you can easily color it like CSS.

Install

in Cargo.toml

[dependencies]
ansi-hex-color = "0.1.1"

Usage

use ansi_hex_color;

fn main () {
	let foreground = "#FF0000";
	let background = "#004082";
	let txt = "Hello world";
	
	let colored_txt = ansi_hex_color::colored(
		foreground, background, txt);
	
	println!("{}", colored_txt);
}

Default style

If you put "" or a string other than hex code in the first and second arguments, the text will be default style(white text, no background).

let colored_txt = ansi_hex_color::colored("", "", "This is a default style.");
Commit count: 10

cargo fmt