Expand description
High-level editor navigation logic (motions).
This module is intentionally UI-agnostic and depends only on core editor
types like TextBuffer and Pos. It provides a stable API to build
Vim-like behavior on top of (e.g. w, gg, G, 0, $, etc.).
Design goals:
- Keep motions deterministic and side-effect-free.
- Keep indexing consistent with
redox-core:Pos { line, col }wherecolis in char units (Ropey model). - Centralize motion semantics here so frontends (TUI/GUI) only project the resulting document cursor into their own viewport/cell coordinate systems.
Notes:
- Word motions here currently use
TextBuffer’s existing word helpers (word_start_before,word_end_after), which in turn usebuffer::util::is_word_char. - Many Vim details (e.g. inclusive/exclusive, operator-pending behavior,
iskeyword, sentence/paragraph motions) can be layered later without changing the frontend.
This file defines:
Motionenum: the set of supported navigation intents.apply_motion/apply_motion_n: apply motions to a cursor position.
Modules§
- helpers
- Convenience helpers for motions that take a count.
Enums§
- Motion
- A navigation intent (motion) that transforms a document cursor.
Functions§
- apply_
motion - Apply a single
Motionto a given cursor position. - apply_
motion_ n - Apply a motion
counttimes (Vim-style numeric prefix).