antsee

Crates.ioantsee
lib.rsantsee
version1.0.1
sourcesrc
created_at2024-08-20 07:43:51.285032
updated_at2024-08-20 08:01:37.189605
descriptionA simple, dependency free, and versatile crate for terminal colors and properties
homepage
repositoryhttps://github.com/emmalexandria/antsee
max_upload_size
id1344986
size20,148
Emma Alexandria (emmalexandria)

documentation

README

antsee

antsee is a lightweight and dependency free ANSI library with the primary goal of allowing for flexibility in styling. This is achieved primarily through the way it models colours. A Color in antsee represents two colors. One is for use on dark terminal backgrounds, and the other is for use on light terminal backgrounds. Further, each colour can contain three colour values for terminals that support ANSI16, ANSI256, and RGB. If given the appropriate information, Color will choose the appropriate color for the environment the application is running in.

This crate does not aim to do the work of detecting the color support of the current terminal, nor whether the background is dark or light.

Planned features

  • Windows support (automatically enabling ANSI support when on windows)
  • Strings that contain multiple styles for each block of text that remain easily editable
  • Support for non-standard properties (e.g. hyperlinks)

Example usage

let styled_str = "Hi there"
        .to_styled_string()
        .with_foreground(RGB::rgb(134, 100, 50))
        .with_background(ANSI16::BrightBlack)
        .with_property(Property::Underline);
let style = Style::default()
        .with_foreground(Color::from(ANSI16::Red))
        .with_background(Color::from(ANSI16::Black))
        .with_property(Property::Bold)
        .with_property(Property::Underline);

let output = style.paint("Hello");
Commit count: 0

cargo fmt