8 releases (4 breaking)
new 0.5.0 | Jan 21, 2025 |
---|---|
0.4.0 | Nov 21, 2023 |
0.3.1 |
|
0.2.0 | Sep 14, 2023 |
0.1.2 | May 31, 2023 |
#403 in Command-line interface
93 downloads per month
Used in 2 crates
(via fluere_plugin)
63KB
1K
SLoC
Inksac
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
-
ANSI Color Support Detection: Automatically detect terminal color support levels including True Color support.
-
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
-
Color Manipulation:
- Color lightening and darkening
- RGB color interpolation
- Gradient effects
-
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!