Skip to main content

Crate rustaco_core

Crate rustaco_core 

Source
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.

Modules§

diff_view
What a diff view needs from a Diff, independent of how it draws: the ranges to mark, the filler blocks that keep two panes aligned, stepping between changes, the edit that reverts a change, and the unchanged stretches worth collapsing. Offsets are chars, lines are 0-based.

Structs§

Binding
ChangeSet
Edits sorted by position. Overlapping or touching edits are merged on construction, so every position belongs to at most one edit.
CharChange
Cursors
One editor’s selections, plus the model version they are valid for.
Decoration
DecorationId
Decorations
Diff
DiffOptions
Document
A model and the cursors of its only editor. Editors sharing a model use TextModel, Cursors and Editor directly.
Edit
Replace chars start..end with text. Offsets refer to the document before the change set.
EditEvent
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.
EditorId
Identifies an editor among those showing one model.
FuzzyMatch
A fuzzy match: higher scores rank first; matches are the char indices of word that matched, for highlighting.
History
KeyPress
A key with modifiers. key is the KeyboardEvent.key value, lowercased ("a", "/", "arrowup", "enter", "f2").
Keymap
LanguageEditing
Language-specific editing data, set by the frontend from its language catalog: comment tokens for comment toggling, bracket and quote pairs for auto-closing. More fields may come: start from LanguageEditing::default() and set the fields.
LineChange
One changed block: lines old were replaced by lines new (either may be empty).
Options
Indentation settings. More fields may come: build one from Options::default().
Point
Row and byte column, the coordinates tree-sitter uses.
Position
Line and column, both zero-based. column counts chars from line start.
Rope
A utf8 text rope.
RopeSlice
An immutable view into part of a Rope.
SearchQuery
Searcher
A compiled query.
Selection
A selection between anchor (fixed end) and head (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.
SnippetSession
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
TextModel
Transaction
One committed change with what is needed to revert it.
Utf16Position
Line and column where character counts UTF-16 code units (LSP, JS).

Enums§

Assoc
Which side of an insertion a mapped position lands on.
EditKind
Decides whether a transaction may join the previous undo step.
LineEnding
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
collect_words
The distinct words (a letter or _, then letters, digits or _) of lines, in order of first appearance, at most max.
default_keymap
The default keymap, following VS Code and Monaco.
diff
Diffs two texts by lines, then by chars inside changed blocks. keep_going is asked now and then; once it returns false the remaining work is done coarsely.
eval_when
Evaluates a when clause: context keys combined with !, && and || (&& binds tighter). Unknown keys are false.
fuzzy_score
Scores word against what was typed, the way VS Code’s completion filter does: every char of pattern in order, case-insensitively, with the first one at the start of the word or at a word boundary (after _, -, ., space, /, :, or a lower-to-upper case change). Matches at the start, consecutive chars, boundaries and the same case score higher. An empty pattern matches everything with score 0. None when it does not match.
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\n or \r).
matching_bracket_text
The bracket pair at pos found by scanning the text: when the char before pos (or at it) is a bracket from pairs, 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) from in a sorted list of matches, wrapping around.
position_to_char
Converts a position to a char offset, clamping line and column into the document.
rank_completions
Filters and ranks completion candidates. texts are the strings matched against (filter text or label), sort_texts break ties. Returns indices into texts with their matches, best first; with keep_order (snippet choices) in the given order.
utf16_to_char
Converts a UTF-16 position to a char offset, clamping into the document. A character that 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.