#editing #line #insertion #cursor #character #range #display

text-editing

A simple string with utilities for editing

4 releases

Uses new Rust 2024

new 0.2.2 Mar 9, 2025
0.2.1 Sep 18, 2024
0.1.3 Jun 16, 2022
0.1.0 Apr 12, 2021

#373 in Text processing

Download history 3/week @ 2024-11-19 2/week @ 2024-12-03 19/week @ 2024-12-10 4/week @ 2025-02-04 20/week @ 2025-02-11 46/week @ 2025-03-04

67 downloads per month
Used in 3 crates

MIT/Apache

20KB
261 lines

Text Editing Library

A simple string with utilities for editing, specifically designed to work with non-ASCII strings.

Features

  • Provides a TextLine struct that represents an editable text line.
  • Supports efficient insertion, removal, and manipulation of characters and ranges.
  • Handles non-ASCII characters correctly, taking into account their multi-byte nature.
  • Offers convenient methods for moving the text cursor forward, backward, and skipping over words.
  • Implements the Display trait for easy conversion to a string.

Documentation

API documentation can be found at docs.rs/text-editing.

Example

use text_editing::TextLine;

let mut line = TextLine::from_string("Hello, 🌍!".into());
line.insert(7, 'w');
assert_eq!(line.as_str(), "Hello, w🌍!");

let removed_char = line.remove(7);
assert_eq!(removed_char, 'w');
assert_eq!(line.as_str(), "Hello, 🌍!");

lib.rs:

Utilities to simplify text editing when implementing text editors. *

No runtime deps