<div align="center">
<img src="./assets/banner-cli.gif" alt="banner">
<p>Run <code>cargo run --example banner -r</code> to print the Banner!</p>
</div>
# Colored Next (CNXT)
[](https://crates.io/crates/cnxt)
A fork of [colored](https://github.com/colored-rs/colored) which introduces better functionalities.
Why CNXT?
1. **Enhanced Performance**: Uses `Cow` to minimize allocations [(Inspired by this PR)](https://github.com/colored-rs/colored/pull/135)
2. **Streamlined Codebase**: Removed outdated and redundant code
3. **Superior Terminal Support**: Improved detection and handling of terminal capabilities
## Usage
Coloring your terminal made simple. You already know how to do it.

Small tips
1. For **Windows targets**, add this to enable colors in **Windows CMD**:
```rust
#[cfg(windows)]
cnxt::control::set_virtual_terminal(true);
```
Comparison of colors with virtual terminal disabled vs enabled.

2. CNXT automatically detects **terminal color support** across **3 levels**:
- `Ansi16`
- `Ansi256`
- `TrueColor`
When using colors beyond your terminal's capabilities, CNXT automatically downgrades them to the maximum supported level.
```rust
use cnxt::control::{set_should_colorize, ShouldColorize};
ShouldColorize::from_env()
set_should_colorize(ShouldColorize::YesWithTrueColor); set_should_colorize(ShouldColorize::YesWithAnsi256);
set_should_colorize(ShouldColorize::No); set_should_colorize(ShouldColorize::Yes);
set_should_colorize(ShouldColorize::from_env());
```
And for manual color fallback control:
```rust
use cnxt::Color;
let color = Color::TrueColor {
r: 166,
g: 227,
b: 161,
};
let ansi16_color = color.fallback_to_ansi16();
# or
let ansi256_color = color.fallback_to_ansi256();
```
## License
As a fork of [colored](https://github.com/colored-rs/colored), CNXT maintains the same [MPL-2.0](https://github.com/colored-rs/colored?tab=readme-ov-file#license) license as the original repository.