8 releases (4 breaking)

new 0.5.0 Jan 21, 2025
0.4.0 Nov 21, 2023
0.3.1 Nov 20, 2023
0.2.0 Sep 14, 2023
0.1.2 May 31, 2023

#403 in Command-line interface

Download history 5/week @ 2024-10-05 2/week @ 2024-10-12 29/week @ 2024-12-07 2/week @ 2024-12-14 93/week @ 2025-01-18

93 downloads per month
Used in 2 crates (via fluere_plugin)

Apache-2.0

63KB
1K SLoC

Inksac

rust-fmt rust-clippy rust-audit

Inksac is a Rust library that amplifies terminal outputs by offering a seamless integration with ANSI color support. It is designed to be uncomplicated, flexible, and delightful to use, adding a splash of color to your terminal applications.

Features

  1. ANSI Color Support Detection: Automatically detect terminal color support levels including True Color support.

  2. Rich Text Styling:

    • Foreground and background colors
    • Basic colors (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White)
    • RGB and HEX color support
    • Text formatting: Bold, Dim, Italic, Underline
  3. Color Manipulation:

    • Color lightening and darkening
    • RGB color interpolation
    • Gradient effects
  4. Flexible API:

    • Builder pattern for style creation
    • Trait-based styling with Styleable
    • Error handling with proper Result types

Examples

Basic Usage

use inksac::{Color, Style, Styleable};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let style = Style::builder()
        .foreground(Color::Green)
        .bold()
        .build();

    println!("{}", "Hello, Colorful World!".style(style));
    Ok(())
}

Styled Error Messages

use inksac::{Color, Style, Styleable};

let error_style = Style::builder()
    .foreground(Color::Red)
    .bold()
    .build();

println!("{}: {}", "ERROR".style(error_style), "Operation failed");

Installation

Add Inksac to your project:

cargo add inksac

Examples

Check out the examples directory for more detailed examples including:

  • Error message styling
  • Rainbow text effects
  • Progress bars with gradients
  • Formatted tables
  • Color support detection

Platform Support

Inksac automatically detects terminal capabilities and adjusts its output accordingly. The actual color representation may vary based on:

  • Terminal emulator capabilities
  • Operating system
  • Color support level (Basic, 256 colors, True Color)

Happy Coding!

No runtime deps