consclr

a rust library to make your console text colorful

Quick start

``` use consclr::{prelude::*, ColorBg, Color, ColorBold}; use consclr::{clr, cprint, pchar};

fn main() { let a = "black"; let b = "red"; let c = "green"; let d = "yellow"; let e = "blue"; let f = "purple"; let g = "grblue"; let h = "gray"; let i = "white";

println!("{}", a.black());
println!("{}", b.red());
println!("{}", c.green());
println!("{}", d.yellow());
println!("{}", e.blue());
println!("{}", f.purple());
println!("{}", g.grblue());
println!("{}", h.gray());
println!("{}", i.white());

pchar!("~", 60, &Bold::GREEN.s());

println!("{}", a.blackb());
println!("{}", b.redb());
println!("{}", c.greenb());
println!("{}", d.yellowb());
println!("{}", e.blueb());
println!("{}", f.purpleb());
println!("{}", g.grblueb());
println!("{}", h.grayb());
println!("{}", i.whiteb());

pchar!("~", 60, &Bold::GREEN.s());

println!("{}", a.bgblack());
println!("{}", b.bgred());
println!("{}", c.bggreen());
println!("{}", d.bgyellow());
println!("{}", e.bgblue());
println!("{}", f.bgpurple());
println!("{}", g.bggrblue());
println!("{}", h.bggray());
println!("{}", i.bgwhite());

pchar!(".", 60, &Bold::GREEN.s());

let f = Regular::GRBLUE.s();
cprint!("

Programmers who are already working with low-level code can use Rust to raise their", &f);

clr!("

Programmers who are already working with low-level code can use Rust to raise their ambitions. For example, introducing parallelism in Rust is a relatively low-risk operation: the compiler will catch the classical mistakes for you. And you can tackle more aggressive optimizations in your code with the confidence that you won’t accidentally introduce crashes or vulnerabilities ", &Regular::RED.s());

pchar!("!", 100, &Background::YELLOW.s());

let long_text = "

Programmers who are already working with low-level code can use Rust to raise their ambitions. For example, introducing parallelism in Rust is a relatively low-risk operation: the compiler will catch the classical mistakes for you. And you can tackle more aggressive optimizations in your code with the confidence that you won’t accidentally introduce crashes or vulnerabilities";

//// with const generic you can manually specify buffer size
//// for example, when you need to store long text data

// println!("{}", long_text.green()); // text is too large, and program will panic
println!("{}", long_text.dgreen::<512>()); // use const generic dgreen() instead from Color trait
println!("{}", long_text.dblueb::<512>()); // use const generic dblueb() instead from ColorBold trait
println!("{}", long_text.dpurplebg::<512>()); // use const generic dpurplebg() instead from ColorBg trait

} ```