Skip to main content

Module select

Module select 

Source
Expand description

Positions and ranges in a Doc.

A Cursor is (block, part, offset) — which block, which of its texts, and how far into it. The part is a coordinate, not a path: a block has one kind of part and never a mix, so the model stays flat while a caret can still reach inside a code block or a table cell.

Because the three fields order lexicographically, a Selection is just two cursors and min/max decides which end is which. That is what lets every delete, every paste and every keystroke be the same operation — Doc::replace over a range — rather than a special case per key.

This half is pure, so the motion is testable without a window.

Structs§

Cursor
A caret: which block, which part of it, and how far into that part.
Selection
A range in the document: where the selection started, and where it is being dragged to.