5 releases (2 stable)

2.0.0 Nov 5, 2022
2.0.0-beta.1 Oct 22, 2022
1.0.0 Jul 31, 2022

#415 in Text editors


Used in tty-form

MIT license

24KB
487 lines

TTY Text

Crate Rust CI Rust CD

Provides agnostic text editing state management. Uses TTY Interface for rendering and TTY Form for forms.


lib.rs:

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

Dependencies

~355KB

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy