Text Editing Library
A simple string with utilities for editing, specifically designed to work with non-ASCII strings.
Features
- Provides a
TextLinestruct that represents an editable text line. - Supports efficient insertion, removal, and manipulation of characters, strings, and ranges.
- Handles non-ASCII characters correctly, taking into account their multi-byte nature.
- Cursor movement: forward, backward, word-skip, Home/End.
- Selection support: extend selection by character or word, select all, delete or replace selection.
- Implements
Display,FromStr, andFromconversions.
Documentation
API documentation can be found at docs.rs/text-editing.
Example
use TextLine;
let mut line = from_string;
line.insert;
assert_eq!;
let removed_char = line.remove;
assert_eq!;
assert_eq!;
Selection
use TextLine;
let mut line = from_string;
let mut cursor = 7;
let mut anchor = None;
// Select "world" with Shift+Ctrl+Right
line.select_forward_skip;
assert_eq!;
// Replace selection
line.replace_selection;
assert_eq!;