stylic 0.3.1

A simple, fast library for styling text with ANSI escape codes
Documentation
![Crates.io Version](https://img.shields.io/crates/v/stylic)
![Crates.io License](https://img.shields.io/crates/l/stylic)

<!-- cargo-rdme start -->

A simple, fast library for styling text with ANSI escape codes.

# Features

- Simple, intuitive API
- Fast, no allocations
- No dependencies
- `#![no_std]` out of the box
- Hyperlink support

# Basic Usage

Import the [`Styleable`](https://docs.rs/stylic/latest/stylic/trait.Styleable.html) trait for an easy way to create
styled values. Then use the methods from [`Styled`](https://docs.rs/stylic/latest/stylic/struct.Styled.html) to style the value.

```rust
use stylic::Styleable;

println!("{}", "Hello, World!".styled().green().italic());
```

You can also create a style and apply it later. [`Style`](struct@crate::Style) has the same
styling options as [`Styled`](https://docs.rs/stylic/latest/stylic/struct.Styled.html). Styling methods (on both types) are `const`,
so you can create constant styles.

```rust
use stylic::{Style, Styleable};

const EMPHASIS: Style = Style::new().bold().italic();
println!("To be or not to be, {} is the question.", "that".styled_with(EMPHASIS));
```

# Styling

Both [`Style`](struct@crate::Style) and [`Styled`](https://docs.rs/stylic/latest/stylic/struct.Styled.html) have methods for setting
the foreground color, background color, underline color, and attributes of the text
(such as bold, italic, etc).

Available attributes are:

- `bold`
- `dim`
- `italic`
- `underlined`
- `blink`
- `inverted`
- `hidden`
- `strikethrough`

Available colors include basic ANSI colors, the extended 256-color palette, and RGB colors.

The ANSI colors are:

- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`

Plus bright variants.

There are methods for setting the foreground color, background color and underline color
to basic ANSI colors:

```rust
use stylic::Styleable;

println!("{}", "Hello, World!".styled().black().on_blue());
```

There are also [`fg`](fn@crate::Style::fg), [`bg`](fn@crate::Style::bg)
and [`underline_colored`](fn@crate::Style::underline_colored) methods that take a `Color`,
allowing the use of colors from the extended 256-color palette and RGB colors:

```rust
use stylic::{Styleable, BasicColor, Color};

// Setting the foreground color to red.
println!("{}", "Hello, World!".styled().fg(Color::Basic(BasicColor::Red)));
println!("{}", "Hello, World!".styled().fg(BasicColor::Red.into()));

// Setting the background color to a color from the 256-color palette.
println!("{}", "Hello, World!".styled().bg(Color::Extended(58)));
println!("{}", "Hello, World!".styled().bg(58.into()));

// Setting the underline color to a RGB color.
println!("{}", "Hello, World!".styled().underline_colored(Color::Rgb(255, 0, 255)));
println!("{}", "Hello, World!".styled().underline_colored((255, 0, 255).into()));
```

You can also create attributes separately and apply them later:

```rust
use stylic::{Styleable, Attributes};

let my_attrs = Attributes::ITALIC | Attributes::STRIKETHROUGH;
println!("My homework was {}", "redacted".styled().attributes(my_attrs));
```

Attributes have methods for performing bitwise operations in a `const` environment:

```rust
use stylic::{Styleable, Attributes};

const MY_ATTRS: Attributes = Attributes::ITALIC.or(Attributes::BLINK);
println!("Did you hear about the {}?", "thing".styled().attributes(MY_ATTRS));
```

# Hyperlinks

You can add a hyperlink to a styled value using the [`Styled::link`](fn@crate::Styled::link) method:

```rust
use stylic::Styleable;

println!("{}", "Example!".styled().link("https://example.com"));
```

<!-- cargo-rdme end -->