Skip to main content

Crate scrive_core

Crate scrive_core 

Source
Expand description

scrive-core — the headless core of the scrive code editor.

This crate owns everything about what the editor shows and what changed, and knows nothing about pixels: no iced, no winit, no renderer. The iced integration lives in the sibling scrive-iced crate, which depends on this one — the dependency points one way, so the editing engine can be tested and reused without dragging in a GUI toolkit.

§The one load-bearing idea: one fact, one owner

Every derived position — a caret, a diagnostic squiggle, a snippet stop — moves through a single mapping function on every edit, and every change is a single atomic transaction with a mechanically-derived inverse. Almost every serious editor bug is two copies of one fact drifting apart; keeping each position in exactly one place, moved through one patch, is the structural antidote.

§Where do I…?

Re-exports§

pub use bracket::Bracket;
pub use bracket::BracketConfig;
pub use bracket::Brackets;
pub use buffer::Buffer;
pub use buffer::DocId;
pub use buffer::EolFlavor;
pub use buffer::LoadError;
pub use buffer::Revision;
pub use buffer::Snapshot;
pub use coords::Bias;
pub use coords::Point;
pub use decorations::DecorationId;
pub use decorations::DecorationKind;
pub use decorations::DecorationStore;
pub use decorations::Diagnostic;
pub use decorations::DiagnosticsOutcome;
pub use decorations::EmptyPolicy;
pub use decorations::Severity;
pub use decorations::Stickiness;
pub use decorations::TrackedRange;
pub use display_map::default_tab_size;
pub use display_map::BufferRow;
pub use display_map::DisplayChunk;
pub use display_map::DisplayChunks;
pub use display_map::DisplayEdit;
pub use display_map::DisplayPoint;
pub use display_map::DisplayRow;
pub use display_map::TabMap;
pub use document::Document;
pub use document::RevealMode;
pub use find::default_find_debounce;
pub use find::FindQuery;
pub use find::FindState;
pub use find::FIND_MATCH_CAP;
pub use fold_map::FoldMap;
pub use fold_map::FoldSet;
pub use fold_map::InlineFold;
pub use fold_map::VisibleRow;
pub use highlight::HIGHLIGHT_CHECKPOINT_STRIDE;
pub use highlight::HIGHLIGHT_MAX_LINES_PER_CALL;
pub use highlight::HIGHLIGHT_MAX_WINDOW_ROWS;
pub use highlight::HIGHLIGHT_WINDOW_SLACK;
pub use highlight::padded_highlight_window;
pub use highlight::tokenize_segment;
pub use highlight::HighlightCache;
pub use highlight::HighlightEngine;
pub use highlight::HighlightSpan;
pub use highlight::Highlighter;
pub use highlight::Rgba;
pub use highlight::SegmentBoundary;
pub use highlight::SegmentStart;
pub use highlight::SegmentTokens;
pub use highlight::SpanStyle;
pub use highlight::SyntaxDef;
pub use highlight::TokenTheme;
pub use history::GroupingHint;
pub use history::OpClass;
pub use intel::completion::CompletionController;
pub use intel::completion::CompletionState;
pub use intel::completion::PopupList;
pub use intel::hover::Hover;
pub use intel::hover::HoverCx;
pub use intel::hover::HoverInfo;
pub use intel::hover::HOVER_IDLE_DELAY_MS;
pub use intel::signature::SignatureCx;
pub use intel::signature::SignatureHelp;
pub use intel::signature::SignatureInfo;
pub use intel::snippet::CaretOutcome;
pub use intel::snippet::Snippet;
pub use intel::snippet::SnippetError;
pub use intel::snippet::SnippetSession;
pub use intel::snippet::TabOutcome;
pub use intel::snippet::TabStop;
pub use intel::providers::is_completion_word_char;
pub use intel::providers::CompletionCx;
pub use intel::providers::CompletionItem;
pub use intel::providers::CompletionKind;
pub use intel::providers::CompletionTrigger;
pub use intel::providers::Completions;
pub use intel::providers::InsertText;
pub use intel::providers::LOOKBACK_LINES;
pub use movement::move_selections;
pub use movement::ColumnDir;
pub use movement::Granularity;
pub use movement::Motion;
pub use patch::Edit;
pub use patch::Patch;
pub use row_layout::tail_start_col;
pub use row_layout::virtual_cell;
pub use row_layout::CaretCell;
pub use row_layout::Chip;
pub use row_layout::DisplayPosition;
pub use row_layout::HeaderHit;
pub use row_layout::HeaderLayout;
pub use row_layout::RowLayout;
pub use row_layout::TailGlyph;
pub use row_layout::FOLD_PLACEHOLDER_CELLS;
pub use row_layout::INLINE_CHIP_CELLS;
pub use selection::Selection;
pub use selection::SelectionId;
pub use selection::SelectionSet;
pub use transaction::Committed;
pub use transaction::EditOp;
pub use transaction::TransactionError;
pub use verbs::default_indent_size;

Modules§

bracket
Bracket matching — the shared structural pass behind bracket-pair colorization, matching-bracket highlight, indent guides, and folding. ()/[]/{} pair by a stack automaton (quotes are not nestable), yielding each bracket’s nesting depth and matched-partner offset and flagging the unmatched.
buffer
The document text store: a rope.
coords
Buffer-space coordinates and the primitives every position shares.
decorations
Tracked-range decorations: the one store, one mover for diagnostics, snippet stops, auto-close regions, and find matches.
display_map
The display map: buffer coordinates ↔ display coordinates, tab expansion only.
document
The document aggregate: the buffer plus its edit history and every derived view (selections, decorations, highlight cache, brackets, folds, find).
find
Find — the search core.
fold_map
Code folding — bracket-anchored. A fold is a collapsed bracket pair, identified by the byte offset of its opener (([{). That offset is the only thing stored; it rides each committed transaction’s Patch via Patch::map_offset, and the fold’s extent (which rows are hidden) is re-derived from the live Brackets pass every frame.
highlight
Syntax highlighting — a GUI-free public surface over a private syntect engine. Syntect is named only inside this module; nothing from it crosses the pub line, so the GUI crate never has to pin syntect’s version.
history
Undo/redo as a branching tree, the grouping mechanism, and dirty tracking.
intel
Language services — completion, signature help, hover.
movement
Caret movement — the motions and the two combinators that apply them to a SelectionSet.
patch
The change currency: Edit / Patch and the one position-mapping function every derived position flows through.
row_layout
Per-row horizontal projection — the one owner of byte-column ↔ display-cell math on rows with collapsed inline folds, and of the collapsed block header’s head … tail one-line layout.
selection
Selections and the multi-cursor set.
transaction
The atomic multi-range transaction engine.
verbs
The editing verbs: type, backspace, delete, enter, paste, and (out)dent. Each turns the current selections into one atomic multi-range transaction, then places a caret after each edit — so every verb is multi-cursor-correct for free (one op per selection).