Pealn is a Rust library for printing coloured text to make your CLI app beautiful as a Peacock
- Fatest Pealn is fastest among other famous ones. see benchmarks
- Compile time format pealn codes during compile time i,e [red](name) converted to \x1b[38;2;255;0;0m name \x1b[0m during compile time
- Easy to use Apply modification inside string
- Pre defined Colors Common colors are already defined
- Text Styles Add Styles like , bold , italic , underline and more
- Use RGB colors Apply colors using RGB value
Traditional Rust Macro | Pealn Macro Alternative |
---|---|
print!() |
pea!() |
println!() |
pealn!() |
write!() |
pealn_write!() |
writeln!() |
pealn_writeln!() |
format!() |
pealn_format!() |
eprint!() |
pealn_eprint!() |
eprintln!() |
pealn_eprintln!() |
Add Pealn to your Cargo.toml:
[dependencies]
pealn = "0.4"
Add Pealn using Cargo CLI:
cargo add Pealn
print new line with colored and styles
[foreground,background,styles....](text)
Name | Preview | Example Code |
---|---|---|
Red | ■ | [red](text) |
Green | ■ | [green](text) |
Blue | ■ | [blue](text) |
Yellow | ■ | [yellow](text) |
Cyan | ■ | [cyan](text) |
Purple | ■ | [purple](text) |
Magenta | ■ | [magenta](text) |
Black | ■ | [black](text) |
White | ■ | [white](text) |
Note: Color preview may not render
Style | Example Code | Description |
---|---|---|
Bold | [bold](text) |
Bold text |
Dim | [dim](text) |
Dim/faint text |
Italic | [italic](text) |
Italic text |
Underline | [underline](text) |
Underlined text |
Blink | [blink](text) |
Blinking text (not always supported) |
Reverse | [reverse](text) |
Reverse video |
Hidden | [hidden](text) |
Hidden text |
Strikethrough | [strikethrough](text) |
Some styles may not be supported in all terminals.
To print text with foreground
use pealn::{pealn};
pealn!("[yellow](Hello) [green](World)!");
To print text with background
use pealn::{pealn};
pealn!("[default,yellow](Hello) [default,green](World)!");
you can use RGB color too
use pealn::{pealn};
pealn!("[(25,45,78)](Hello) [(34,67,78)](World)!");
To print text with foreground and background
use pealn::{pealn};
pealn!("[yellow,white](Hello) [green,white](World)!");
First color defined is always considers as foreground and second color as background color, even if you put style in middle it will behave same
To print text with styles
use pealn::{pealn};
pealn!("[bold,underline](Hello) [italic](World)!");
To print text with color and styles
use pealn::{pealn};
//here order of colors and styles does not matter,
//first color will be used as foreground and second as background
pealn!("[red,green,bold,underline](Hello) [yellow,italic,white](World)!");
see docs for detailed information
We welcome contributions!
Please see CONTRIBUTION.md for guidelines.
Pealn makes your CLI apps more colorful and expressive!