Crates.io | rusty_style |
lib.rs | rusty_style |
version | 0.1.2 |
source | src |
created_at | 2023-05-18 01:58:52.247209 |
updated_at | 2023-05-18 21:03:25.744904 |
description | Rusty Style is a library for styling text in the terminal. |
homepage | |
repository | |
max_upload_size | |
id | 867356 |
size | 13,613 |
Rusty style is built on the builder design pattern. Designing your TUI is easier than ever with Rusty Style.
For a simple demo, take a look into the examples directory.
use rusty_style::{Color, Style};
fn main() {
let underline = Style::new().underline();
println!("{}", underline.render("I am underline!"));
let bold = Style::new().bold();
println!("{}", bold.render("I am bold!"));
let my_style = Style::new()
.bold()
.italic()
.foreground(Color::new(255, 192, 203))
.set_string("I have multiple");
println!("{}", my_style.render(", Styles!")); // render will append the text to I Have multiple
}
Rusty Style supports True Color:
rusty_style::Color::new(255, 192, 203) // pink
rusty_style::Color::new(166, 200, 148) // green
rusty_style::Color::new(142, 29, 206) // purple
rusty_style::Color::convert_hex_to_rgb("#DE3163").unwrap() // cerse
rusty_style::Color::convert_hex_to_rgb("#9F2B68").unwrap() // amaranth
rusty_style::Color::convert_hex_to_rgb("#F2D2BD").unwrap() // bisque
Rusty Style supports the usual ANSI text formatting options:
let style = rusty_style::Style::new()
bold().
faint().
italic().
underline().
blink().
reverse().
invisible().
strikethrough();
When using render, you will lose ownership of your style because render is made to be used once you are done with your style. If you want to keep your style object we recommend you to clone your style.
let style = rusty_style::Style::new();
let my_copy = style.clone();
Informations