idet-core 0.2.0

Shared text-editing library for a Micro-like terminal editor and a gedit-like egui GUI
Documentation

idet-core

Backend-agnostic editing logic for a text editor: word autocomplete, line moves, word swaps, indentation edits and bracket-pair matching. No dependencies, no I/O — every function takes a &str and a character index and returns a new string and cursor position (or a range). Drive it from a terminal UI, an egui widget, or anything else that owns the text buffer and the keybindings.

Built for idet, a Micro-like terminal editor, and its egui-based sibling gidet, sharing one editing core between two very different frontends.

Modules

  • completion — word collection and prefix/whole-word matching for autocomplete (collect_words, current_word, matches).
  • edits — insertion, indentation and newline-with-autoindent, plus line-start/line-end lookup (insert, newline_indent, indent_line, dedent_line, line_start_char, line_end_char).
  • lineops — moving the current line up or down, and translating between character offsets and line/column coordinates (move_line, line_column, cursor_at).
  • wordops — swapping the word at the cursor with an adjacent word (swap).
  • brackets — finding the matching bracket for (), [] or {} at or near the cursor (find_matching_bracket).
  • widget (behind the egui feature, off by default) — a drop-in egui::TextEdit-based multiline editor wired to the modules above: move-line, swap-word, indent/dedent, auto-indent, word autocomplete and find. Enable with idet-core = { version = "...", features = ["egui"] }. Application-specific concerns (save/undo/reload, window chrome, tabs) stay the host's responsibility — the widget only owns the text buffer it's handed each frame.

Design

Every operation is a pure function over character indices, not byte offsets — callers don't need to think about UTF-8 boundaries. Multi-cursor editing is the caller's responsibility: run the same operation once per cursor, in descending position order, shifting later cursors by the delta each edit produces.