2 releases

new 0.2.3 Apr 28, 2024
0.2.2 Apr 21, 2024
0.2.1 Apr 21, 2024
0.2.0 Apr 21, 2024

#212 in Command-line interface

Download history 217/week @ 2024-04-16 98/week @ 2024-04-23

315 downloads per month

MIT license

17KB
300 lines

Ruterm

Tiny (~300 loc) library for working with the terminal

docs.rs GitHub License GitHub code size in bytes

Installation

cargo add ruterm # from crates.io
cargo add --git https://github.com/georgiyozhegov/terminal.git # more recent version

Usage

use ruterm::{
    error::Result,
    in_raw,
    style::{color::fore, RESET},
    io::write,
    size,
    cursor,
};

fn main() -> Result<()> {
    in_raw!({
        cursor::start()?; // clear screen
        let (w, h) = size()?;
        cursor::set(w / 2, h / 2)?; // move cursor to the center
        write(fore::GREEN.as_bytes())?; // green foreground
        write(b"Hello from raw mode!\n\r")?;
        write(RESET.as_bytes())?; // reset style
        cursor::set(0, h)?; // move cursor to the bottom
    });

    Ok(())
}

Examples

cargo run --example car

example

Dependencies

~120KB