Crate tty_text

Source
Expand description

§tty-text

Provides agnostic text editing state management.

§Examples

For more examples, see Text.

use tty_text::{Text, Key};

let mut text = Text::from("Hello,\nworld!", (1, 0), true);

// Move cursor from "e" to "w"
text.handle_input(Key::Down);
text.handle_input(Key::Down);
text.handle_input(Key::Left);

// Combine into single line, add " "
text.handle_input(Key::Backspace);
text.handle_input(Key::Char(' '));

// Add another "!"
text.set_cursor((13, 0));
text.handle_input(Key::Char('!'));

assert_eq!("Hello, world!!", text.value());
assert_eq!((14, 0), text.cursor());

Structs§

Text
A multi-line text editor with cursor management capabilities.

Enums§

Key