#ansi-colors #color #style

nightly ansi

ANSI colors for Rust

1 unstable release

Uses old Rust 2015

0.1.0 Nov 21, 2014

#99 in #ansi-colors

9KB
229 lines

ansi.rs

A utility library in Rust to wrap blobs in ANSI character codes, giving them color and style.

Built using Cargo.

Usage

All styles can chain into new styles, by calling a relevant method. Styles can also be added together to create new ones (Red + Strike).

#![feature(unboxed_closures)]
extern crate ansi;

fn main() {
    println!("{} {}!", ansi::Blue("Hello"), ansi::Red.bold()("World"));
}

TODO

  • Docs
  • Faster

License

MPLv2.0


lib.rs:

Ansi

Easily build up ansi styles that can be written to a Formatter.

Examples

#![feature(unboxed_closures)]
extern crate ansi;

use ansi::{Bold, Red, White};

fn main() {

    // any style can be added to others
    let error = Red + Bold;
    println!("{}", error("red and bold"));

    // or you can change methods
    let critical = White.bg_red().bold();
    println!("{}", critical("bold, white, and red bg"));
}

No runtime deps