Expand description
Text model for the Rustaco editor.
No UI and no I/O: a rope buffer, multi-cursor selections, change sets,
undo history and the editing commands. A TextModel can be shared by
several editors, each with its own Cursors; Document bundles one
model with one editor for the common case. Frontends (web and native) and
services (syntax highlighting, LSP) consume the EditEvents it emits.
Structs§
- Binding
- Change
Set - Edits sorted by position. Overlapping or touching edits are merged on construction, so every position belongs to at most one edit.
- Char
Change - Cursors
- One editor’s selections, plus the model version they are valid for.
- Decoration
- Decoration
Id - Decorations
- Diff
- Diff
Options - Document
- A model and the cursors of its only editor. Editors sharing a model use
TextModel,CursorsandEditordirectly. - Edit
- Replace chars
start..endwithtext. Offsets refer to the document before the change set. - Edit
Event - One applied edit, in every unit a consumer might need.
- Editor
- Short-lived access to a model for one editor. Creating it syncs the cursors.
- Editor
Id - Identifies an editor among those showing one model.
- History
- KeyPress
- A key with modifiers.
keyis theKeyboardEvent.keyvalue, lowercased ("a","/","arrowup","enter","f2"). - Keymap
- Language
Editing - Language-specific editing data, set by the frontend from its language catalog: comment tokens for comment toggling, bracket and quote pairs for auto-closing.
- Line
Change - One changed block: lines
oldwere replaced by linesnew(either may be empty). - Options
- Point
- Row and byte column, the coordinates tree-sitter uses.
- Position
- Line and column, both zero-based.
columncounts chars from line start. - Rope
- A utf8 text rope.
- Rope
Slice - An immutable view into part of a
Rope. - Search
Query - Searcher
- A compiled query.
- Selection
- A selection between
anchor(fixed end) andhead(the caret), in char offsets. An empty selection is a plain cursor. - Selections
- A non-empty set of selections, sorted by position, never overlapping. One of them is primary: it scrolls into view and receives single-cursor commands.
- Snippet
- A parsed snippet: its text with variables resolved and the tab stops in it.
- Snippet
Session - An active snippet: its tab stops as decorations and the stop being edited.
- Stale
- Returned when a consumer asks for changes older than the log keeps.
- TabStop
- Text
Model - Transaction
- One committed change with what is needed to revert it.
- Utf16
Position - Line and column where
charactercounts UTF-16 code units (LSP, JS).
Enums§
- Assoc
- Which side of an insertion a mapped position lands on.
- Edit
Kind - Decides whether a transaction may join the previous undo step.
- Line
Ending - Platform
- Resolved
- What a key press resolved to.
- Stickiness
- How a decoration’s edges behave when text is typed exactly at them (Monaco’s names).
Constants§
- SNIPPET_
OWNER - Snippet sessions own decorations from this owner id up (plus the editor’s id).
- SNIPPET_
STOP - Decoration kind of snippet tab stops.
Functions§
- char_
to_ point - char_
to_ position - char_
to_ utf16 - default_
keymap - The default keymap, following VS Code and Monaco.
- diff
- Diffs two texts by lines, then by chars inside changed blocks.
keep_goingis asked now and then; once it returns false the remaining work is done coarsely. - eval_
when - Evaluates a
whenclause: context keys combined with!,&&and||(&&binds tighter). Unknown keys are false. - jetbrains_
keymap - Bindings modelled on JetBrains IDEs over the default keymap (Windows and Linux keys).
- line_
end - Char offset of the end of
line, before its terminator. - line_
len - Number of chars on
line, excluding the line terminator (\n,\r\nor\r). - matching_
bracket_ text - The bracket pair at
posfound by scanning the text: when the char beforepos(or at it) is a bracket frompairs, returns the positions of it and its partner, opening first. Brackets inside strings and comments are counted too; frontends with a syntax tree use the tree’s answer instead. - next_
match - The match after (or before)
fromin a sorted list of matches, wrapping around. - position_
to_ char - Converts a position to a char offset, clamping line and column into the document.
- utf16_
to_ char - Converts a UTF-16 position to a char offset, clamping into the document.
A
characterthat falls inside a surrogate pair resolves to the char containing it. - word_at
- The run of same-class chars around
pos, preferring a word on either side. Used by double-click.