3 releases

0.1.2 Mar 8, 2021
0.1.1 Mar 8, 2021
0.1.0 Mar 8, 2021

#498 in Graphics APIs

49 downloads per month

MIT license

11KB
219 lines

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

No runtime deps