sty 🌈
Style terminal outputs in a minimal, macro-based, and dead simple way.
Highlights
- Macro-based: Increases compile-time efficiency and boosts safety.
- Innovative Styling: Compose styles in an array-like format such as
[red, bold, underline]. - Extensive Type Support: All types implementing
std::fmt::Displaytrait are supported, offering wide-ranging adaptability. - Full Color and Style support: Modifiers / Foreground colors / Background colors / Bright foreground colors / Bright background colors.
- Zero dependencies: Cleaner code-base with no third-party interference.
Documentation
Installation
This crate works with Cargo. Add the following to your Cargo.toml dependencies section:
[]
= "0.1"
Basic usage
use ;
// or
// use sty::{ sty, red, underline };
println!;
// multiple styles
println!;
Note: According to the ASCII escape rules, the color at the front has the highest priority. For example:
sty!; // red
sty!; // reset
Supported types
For any type that has implemented the std::fmt::Display trait, like:
&strStringnumbers(usize,i8,i16,i32,i64,i128,u8,u16,u32,u64,u128,f32,f64)bool- ...
Supported styles
use ;
// or
// use sty::{ red, underline };
- Modifiers
- reset
- bold
- dim
- italic
- underline
- overline
- inverse
- hidden
- strikethrough
- Foreground colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- gray
- Background colors
- bg_black
- bg_red
- bg_green
- bg_yellow
- bg_blue
- bg_magenta
- bg_cyan
- bg_white
- bg_gray
- Bright foreground colors
- red_bright
- green_bright
- yellow_bright
- blue_bright
- magenta_bright
- cyan_bright
- white_bright
- Bright background colors
- bg_red_bright
- bg_green_bright
- bg_yellow_bright
- bg_blue_bright
- bg_magenta_bright
- bg_cyan_bright
- bg_white_bright