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.

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.
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.
LineChange
One changed block: lines old were replaced by lines new (either may be empty).
Options
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
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.
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.
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.