string_cmd
A Rust library for building powerful string editing components with support for Emacs and Vi-style keybindings. Perfect for terminal applications that need sophisticated text input handling with more flexibility than readline provides.
string_cmd provides default keybindings for Emacs and Vi modes, or you can forego the default keybindings and implement your own.
Installation
# If you want to use the crossterm events integration:
Basic Usage
use StringEditor;
// Create a new empty editor
let mut editor = new;
// Or initialize with existing text
let mut editor = with_string;
// Get the current text
println!;
// Get cursor position
println!;
See the StringEditor documentation for more details.
Crossterm Integration
The library provides seamless integration with crossterm for terminal applications. Here's a complete example:
use Duration;
use ;
use ;
Supported Keybindings (with crossterm feature)
Navigation
Ctrl+BorLeft Arrow: Move cursor leftCtrl+ForRight Arrow: Move cursor rightCtrl+AorHome: Move to start of lineCtrl+EorEnd: Move to end of line
Editing
Ctrl+HorBackspace: Delete character before cursorCtrl+DorDelete: Delete character at cursorCtrl+K: Delete from cursor to end of lineCtrl+U: Delete from start of line to cursorCtrl+W: Delete word leading to cursor
Usage
use StringEditor;
let mut editor = new;
// how you get the event is up to you;
// most commonly, you'll use `crossterm::event::poll()` and `crossterm::event::read()`
let event = get_crossterm_event;
if let Some = event_to_command
License
This project is licensed under the MIT License.