|
3 | 3 | [](https://github.com/SkuldNorniern/inksac-rs/actions/workflows/rust-clippy.yml)
|
4 | 4 | [](https://github.com/SkuldNorniern/inksac-rs/actions/workflows/rust-audit.yml)
|
5 | 5 |
|
6 |
| -Inksac is a Rust library that amplifies terminal outputs by offering a seamless integration with ANSI color support. It is devised to be uncomplicated, flexible, and delightful to utilize, adding a splash of color to your terminal applications. |
| 6 | +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. |
7 | 7 |
|
8 | 8 | ## Features
|
9 | 9 |
|
10 |
| -1. **Check ANSI Color Support**: Before painting your terminal with vibrant colors, ascertain if the current terminal supports ANSI colors using Inksac's built-in function. |
| 10 | +1. **ANSI Color Support Detection**: Automatically detect terminal color support levels including True Color support. |
11 | 11 |
|
12 |
| -2. **Customizable Styles**: Inksac allows the creation of distinct text styles with customizable foreground and background colors, giving a personal touch to your terminal display. |
| 12 | +2. **Rich Text Styling**: |
| 13 | + - Foreground and background colors |
| 14 | + - Basic colors (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White) |
| 15 | + - RGB and HEX color support |
| 16 | + - Text formatting: Bold, Dim, Italic, Underline |
13 | 17 |
|
14 |
| -3. **Vivid Text Outputs**: Enrich your terminal applications with colorful text outputs using the `ColoredString` structure. |
| 18 | +3. **Color Manipulation**: |
| 19 | + - Color lightening and darkening |
| 20 | + - RGB color interpolation |
| 21 | + - Gradient effects |
15 | 22 |
|
16 |
| -4. **True Color Support**: Experience the diversity of colors with Inksac supporting true color by RGB and HEX values. |
| 23 | +4. **Flexible API**: |
| 24 | + - Builder pattern for style creation |
| 25 | + - Trait-based styling with `Styleable` |
| 26 | + - Error handling with proper Result types |
17 | 27 |
|
18 |
| -5. **Text Format Options**: Beautify your text with bold, dim, italic, underline formats. Stay tuned for more format options in future releases. |
19 |
| - |
20 |
| -## Usage |
21 |
| - |
22 |
| -Here is a basic example demonstrating how to utilize the Inksac crate: |
| 28 | +## Examples |
23 | 29 |
|
| 30 | +### Basic Usage |
24 | 31 | ```rust
|
25 |
| -use inksac::is_color_available; |
26 |
| -use inksac::types::{Color, ColoredString, Style}; |
27 |
| - |
28 |
| -fn main() { |
29 |
| - // Check if the terminal supports ANSI colors |
30 |
| - match is_color_available() { |
31 |
| - Ok(_) => println!("Terminal supports ANSI colors"), |
32 |
| - Err(err) => println!("{}", err), |
33 |
| - } |
34 |
| - |
35 |
| - // Create a style using the new builder pattern |
36 |
| - let title_style = Style::builder() |
37 |
| - .foreground(Some(Color::Green)) |
38 |
| - .background(Some(Color::Red)) |
| 32 | +use inksac::{Color, Style, Styleable}; |
| 33 | + |
| 34 | +fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 35 | + let style = Style::builder() |
| 36 | + .foreground(Color::Green) |
39 | 37 | .bold()
|
40 | 38 | .build();
|
41 | 39 |
|
42 |
| - // Create a ColoredString with the predefined style |
43 |
| - let title_text = ColoredString::new("Hello World", title_style); |
44 |
| - |
45 |
| - // Print the ColoredString |
46 |
| - println!("{}", title_text); |
| 40 | + println!("{}", "Hello, Colorful World!".style(style)); |
| 41 | + Ok(()) |
47 | 42 | }
|
48 | 43 | ```
|
49 | 44 |
|
| 45 | +### Styled Error Messages |
| 46 | +```rust |
| 47 | +use inksac::{Color, Style, Styleable}; |
| 48 | + |
| 49 | +let error_style = Style::builder() |
| 50 | + .foreground(Color::Red) |
| 51 | + .bold() |
| 52 | + .build(); |
| 53 | + |
| 54 | +println!("{}: {}", "ERROR".style(error_style), "Operation failed"); |
| 55 | +``` |
| 56 | + |
50 | 57 | ## Installation
|
51 | 58 |
|
52 |
| -To add Inksac as a dependency to your project, run the following command: |
| 59 | +Add Inksac to your project: |
53 | 60 |
|
54 | 61 | ```sh
|
55 | 62 | cargo add inksac
|
56 | 63 | ```
|
57 | 64 |
|
58 |
| -## Disclaimer |
| 65 | +## Examples |
| 66 | + |
| 67 | +Check out the [examples directory](./examples) for more detailed examples including: |
| 68 | +- Error message styling |
| 69 | +- Rainbow text effects |
| 70 | +- Progress bars with gradients |
| 71 | +- Formatted tables |
| 72 | +- Color support detection |
| 73 | + |
| 74 | +## Platform Support |
59 | 75 |
|
60 |
| -Please note that the actual color representation may vary based on the terminal's capabilities and might not function as anticipated on all platforms. |
| 76 | +Inksac automatically detects terminal capabilities and adjusts its output accordingly. The actual color representation may vary based on: |
| 77 | +- Terminal emulator capabilities |
| 78 | +- Operating system |
| 79 | +- Color support level (Basic, 256 colors, True Color) |
61 | 80 |
|
62 | 81 | ---
|
63 | 82 | Happy Coding!
|
|
0 commit comments