#input #back-end #ratatui #unify #diffrent

ratatui-eventInput

Unify input from diffrent ratatui backends

5 releases

0.1.4 Jan 7, 2025
0.1.3 Jan 2, 2025
0.1.2 Dec 25, 2024
0.1.1 Dec 25, 2024
0.1.0 Dec 25, 2024

#2 in #unify

Download history 285/week @ 2024-12-24 122/week @ 2024-12-31 104/week @ 2025-01-07

297 downloads per month

MIT license

19KB
399 lines

ratatui-eventInput

Unifies input handling from crossterm, termion and termwiz.

It is meant to be used by ratatui libraries to make input handling easier, or allow people using a library to specify what input to listen to.

basic usage

The different are all disabled by default, so need the features to use them:

ratatui-eventInput = { 
    version = "0.1", 
    features = [
        "crossterm", 
        "termion", 
        "termwiz"
    ] }

After that just use a function like this to handle the input:

use ratatui_eventInput::{Input, Key};

pub fn handle<I: Into<Input>>(&mut self, input: I) {
    let input: Input = input.into()
    if input.key == Key::Right {
        println!("right")
    } else if input.key == Key::Left {
        println!("left")
    }
}

Acknowledgments

This library does not support all inputs the backends give and is mostly based on the inputs that crossterm uses.

Dependencies

~2–14MB
~210K SLoC