Skip to main content

scrive_core/
lib.rs

1//! `scrive-core` — the headless core of the scrive code editor.
2//!
3//! This crate owns everything about *what* the editor shows and *what changed*,
4//! and knows nothing about pixels: no `iced`, no `winit`, no renderer. The iced
5//! integration lives in the sibling `scrive-iced` crate, which depends on this
6//! one — the dependency points one way, so the editing engine can be tested and
7//! reused without dragging in a GUI toolkit.
8//!
9//! # The one load-bearing idea: one fact, one owner
10//!
11//! Every derived position — a caret, a diagnostic squiggle, a snippet stop —
12//! moves through a single mapping function on every edit, and every change is a
13//! single atomic transaction with a mechanically-derived inverse. Almost every
14//! serious editor bug is two copies of one fact drifting apart; keeping each
15//! position in exactly one place, moved through one patch, is the structural
16//! antidote.
17//!
18//! # Where do I…?
19//!
20//! - store text / convert coordinates → [`buffer`], [`coords`]
21//! - apply an edit / undo / redo → [`transaction`], [`history`]
22//! - move or extend the caret → [`selection`], [`movement`]
23//! - type / paste / indent / move or copy a line → [`verbs`]
24//! - expand tabs to columns → [`display_map`]
25//! - syntax-highlight a line → [`highlight`]
26//! - attach diagnostics / snippet stops → [`decorations`]
27//! - complete / hover / signature help → [`intel::providers`]
28
29#![deny(missing_docs)]
30#![forbid(unsafe_code)]
31
32mod autoclose; // auto-close pair rules (crate-internal)
33pub mod bracket;
34mod bracket_tree; // bracket matching on the SumTree (shape monoid)
35pub mod buffer;
36mod change_log; // the opt-in incremental change log behind `Document::drain_changes` (crate-internal)
37pub mod coords;
38pub mod decorations;
39pub mod display_map;
40pub mod document;
41pub mod find;
42pub mod fold_map;
43pub mod highlight;
44pub mod history;
45pub mod intel;
46pub mod movement;
47mod offset_set; // delta-gap SumTree of offsets (folds/decorations backing)
48pub mod patch;
49mod perf; // op-count work meter behind the complexity gate (crate-internal)
50mod rope; // the text rope (SumTree<Chunk>) backing Buffer
51#[cfg(test)]
52mod perf_gate; // scale-matrix test that fails the build if a shared primitive scales worse than linearly (tests only)
53pub mod row_layout;
54pub mod selection;
55mod sum_tree; // the one augmented balanced tree every position-tracked structure descends; crate-internal for now
56pub mod transaction;
57pub mod verbs;
58
59pub use bracket::{Bracket, BracketConfig, Brackets};
60pub use buffer::{Buffer, DocId, EolFlavor, LoadError, Revision, Snapshot};
61pub use coords::{Bias, Point};
62pub use decorations::{
63    DecorationId, DecorationKind, DecorationStore, Diagnostic, DiagnosticsOutcome, EmptyPolicy,
64    Severity, Stickiness, TrackedRange,
65};
66pub use display_map::{
67    default_tab_size, BufferRow, DisplayChunk, DisplayChunks, DisplayEdit, DisplayPoint,
68    DisplayRow, TabMap,
69};
70pub use document::{Document, RevealMode};
71pub use find::{default_find_debounce, FindQuery, FindState, FIND_MATCH_CAP};
72pub use fold_map::{FoldMap, FoldSet, InlineFold, VisibleRow};
73pub use highlight::{
74    HIGHLIGHT_CHECKPOINT_STRIDE, HIGHLIGHT_MAX_LINES_PER_CALL, HIGHLIGHT_MAX_WINDOW_ROWS,
75    HIGHLIGHT_WINDOW_SLACK,
76};
77pub use highlight::{
78    padded_highlight_window, tokenize_segment, HighlightCache, HighlightEngine, HighlightSpan,
79    Highlighter, Rgba, SegmentBoundary, SegmentStart, SegmentTokens, SpanStyle, SyntaxDef,
80    TokenTheme,
81};
82pub use history::{GroupingHint, OpClass};
83pub use intel::completion::{CompletionController, CompletionState, PopupList};
84pub use intel::hover::{Hover, HoverCx, HoverInfo, HOVER_IDLE_DELAY_MS};
85pub use intel::signature::{SignatureCx, SignatureHelp, SignatureInfo};
86pub use intel::snippet::{CaretOutcome, Snippet, SnippetError, SnippetSession, TabOutcome, TabStop};
87pub use intel::providers::{
88    is_completion_word_char, CompletionCx, CompletionItem, CompletionKind, CompletionTrigger,
89    Completions, InsertText, LOOKBACK_LINES,
90};
91pub use movement::{move_selections, ColumnDir, Granularity, Motion};
92pub use patch::{Edit, Patch};
93pub use row_layout::{
94    tail_start_col, virtual_cell, CaretCell, Chip, DisplayPosition, HeaderHit, HeaderLayout,
95    RowLayout, TailGlyph, FOLD_PLACEHOLDER_CELLS, INLINE_CHIP_CELLS,
96};
97pub use selection::{Selection, SelectionId, SelectionSet};
98pub use transaction::{Committed, EditOp, TransactionError};
99pub use verbs::default_indent_size;