console-codes

Crates.ioconsole-codes
lib.rsconsole-codes
version0.1.2
sourcesrc
created_at2021-03-08 14:10:15.136527
updated_at2021-03-08 16:40:23.261173
descriptionEnums for rendering console codes
homepagehttps://github.com/j0057/console-codes-rs
repositoryhttps://github.com/j0057/console-codes-rs
max_upload_size
id365699
size17,453
Joost Molenaar (j0057)

documentation

https://docs.rs/console-codes

README

console-codes-rs

Some enums for rendering escape sequences as documented in console_codes(4). The main enum CSI implements Display so that it can easily be converted to a String.

Example

Use the Erase Display code to clear the screen, the CUrsor Position code to move the cursor to the top left corner, then a Set Graphics Rendition sequence with three attributes to set the colors to blinking blue text on deep sky blue background and print Hello, world!:

use console_codes::{CSI, SGR};

fn main() {
    print!("{}", CSI::ED(2));
    print!("{}", CSI::CUP(1, 1));
    print!("{}", CSI::SGR(&[SGR::Blink, SGR::FG24(0, 0, 255), SGR::BG24(0, 191, 255)]));
    print!("{}", "Hello, world!");
    print!("{}", CSI::SGR(&[SGR::Reset]));
    println!();
}
Commit count: 9

cargo fmt