antsi

Crates.ioantsi
lib.rsantsi
version0.0.0-reserved
sourcesrc
created_at2023-02-08 20:41:47.085032
updated_at2023-02-08 20:41:47.085032
descriptionA no-std mini-crate that provides support ANSI escape sequences
homepage
repositoryhttps://github.com/hashintel/hash/tree/main/libs/antsi
max_upload_size
id780237
size16,440
antsi (github:hashintel:antsi)

documentation

https://docs.rs/antsi

README

antsi

antsi is a no-std mini-crate that provides support for SGR1 codes (better known as ANSI escape sequences)

The name is a play on words and encapsulates the three goals of the crate:

  • ant: small, productive and extremely useful (🐜)
  • ansi: implementation of ANSI escape sequences
  • antsy: restless as in fast, with near to no overhead (🏎️💨)

The crate tries to be as correct as possible, acting both as a library and as an up-to-date reference guide regarding terminal support and related specifications (correct as of the time of publication).

⚠️ Disclaimer ⚠️

This crate does not ship with any functionality and is only a name reservation to stop potential name squatting. In the future the actual crate will be published under this name, for the current (incomplete) implementation of the crate please visit the linked repository.

Example

use antsi::{BasicColor, Style, Font, FontWeight};
// effortless const support
const PANIC_STYLE: Style = Style::new().with_foreground(BasicColor::Red.bright().into());
const BOLD_STYLE: Style = Style::new().with_font(Font::new().with_weight(FontWeight::Bold));
fn knows_user() -> bool {
    true
}
fn main() {
    // dynamic style support
    let mut style = Style::new();
    if knows_user() {
        style = style.font_mut().set_strikethrough();
    }
    eprintln!("O no! {}", PANIC_STYLE.apply(format_args!("mainframe breach {} has been {}", style.apply("(from an unknown user)"), BOLD_STYLE.apply("detected"))))
}
O no! mainframe breach (from an unknown user) has been detected

Contributors

antsi was created by Bilal Mahmoud for use in error-stack. It is being developed in conjunction with HASH as an open-source project. We gratefully accept external contributions and have published a contributing guide that outlines the process. If you have questions, please reach out to us on our Discord server. You can also report bugs directly on the GitHub repo.

License

antsi is available under a number of different open-source licenses. Please see the LICENSE file to review your options.

Footnotes

  1. SGR stands for Select Graphic Rendition

Commit count: 0

cargo fmt