Skip to content

Rust crate that will have tools to construct ansi commands.

License

Notifications You must be signed in to change notification settings

ParagonPawns/ansi-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

Rust crate that will have tools to construct ansi commands.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages