#ansi #builder #control #sequences #construct #build #color

ansi-builder

Rust crate that will have tools to construct ansi control sequences

7 releases

0.1.6 Jun 6, 2021
0.1.5 Jun 5, 2021
0.1.4 May 27, 2021

#21 in #construct

Download history 13/week @ 2024-03-24 27/week @ 2024-03-31 9/week @ 2024-04-07 2/week @ 2024-04-14 11/week @ 2024-04-21 4/week @ 2024-04-28 3/week @ 2024-05-05 11/week @ 2024-05-12 9/week @ 2024-05-19 3/week @ 2024-05-26 8/week @ 2024-06-02 5/week @ 2024-06-09 8/week @ 2024-06-16 7/week @ 2024-06-23 1/week @ 2024-06-30 88/week @ 2024-07-07

104 downloads per month
Used in 2 crates

MIT license

11KB
236 lines

ANSI Builder

ANSI builder is a library that allows you to build and execute ansi control sequences. This repository is currently a work in progress and might have frequent changes to design (will try to keep design changes to a minimum).

Platform Support

  • Linux
  • OSX
  • Windows (tested on Windows 10)

Example

More details on using the library can be found in the examples/ directory. Also https://github.com/ParagonPawns/term-inquiry is on of our projects that use this.

Change color example

use ansi_builder::AnsiBuilder;

AnsiBuilder::new()
    .color().fg().red()
    .text("This text will be red")
    .print() // prints out what we currently have to the terminal.
    .reset_attributes()
    .text("this text will be default)
    .println(); // prints out what we have to the terminal and goes to next line.

Cursor example

use ansi_builder::AnsiBuilder;

AnsiBuilder::new()
    .cursor().save() // saves current cursor positon
    .text("just writing stuff")
    .println()
    .text("more stuff")
    .println()
    .cursor().restore() // brings cursor where we saved
    .erase_display(EraseMode::Everything)
    .print();

Dependencies

~0–31MB
~525K SLoC