Skip to main content

Module motion

Module motion 

Source
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 } where col is 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 use buffer::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:

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 Motion to a given cursor position.
apply_motion_n
Apply a motion count times (Vim-style numeric prefix).