4 releases

new 0.2.5 May 12, 2024
0.2.4 May 12, 2024
0.2.3 Apr 28, 2024

#204 in Command-line interface

Download history 219/week @ 2024-04-17 126/week @ 2024-04-24 15/week @ 2024-05-01 261/week @ 2024-05-08

621 downloads per month

MIT license

21KB
401 lines

Ruterm

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

docs.rs GitHub License GitHub code size in bytes

Installation

From crates.io:

cargo add ruterm

From repository (more recent):

cargo add --git https://github.com/georgiyozhegov/terminal.git

Warning: Currently, supports only Linux.

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

References

Dependencies

~120KB