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 → [`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;
36pub mod coords;
37pub mod decorations;
38pub mod display_map;
39pub mod document;
40pub mod find;
41pub mod fold_map;
42pub mod highlight;
43pub mod history;
44pub mod intel;
45pub mod movement;
46mod offset_set; // delta-gap SumTree of offsets (folds/decorations backing)
47pub mod patch;
48mod perf; // op-count work meter behind the complexity gate (crate-internal)
49mod rope; // the text rope (SumTree<Chunk>) backing Buffer
50#[cfg(test)]
51mod perf_gate; // scale-matrix test that fails the build if a shared primitive scales worse than linearly (tests only)
52pub mod row_layout;
53pub mod selection;
54mod sum_tree; // the one augmented balanced tree every position-tracked structure descends; crate-internal for now
55pub mod transaction;
56pub mod verbs;
57
58pub use bracket::{Bracket, BracketConfig, Brackets};
59pub use buffer::{Buffer, DocId, EolFlavor, LoadError, Revision, Snapshot};
60pub use coords::{Bias, Point};
61pub use decorations::{
62    DecorationId, DecorationKind, DecorationStore, Diagnostic, DiagnosticsOutcome, EmptyPolicy,
63    Severity, Stickiness, TrackedRange,
64};
65pub use display_map::{
66    default_tab_size, BufferRow, DisplayChunk, DisplayChunks, DisplayEdit, DisplayPoint,
67    DisplayRow, TabMap,
68};
69pub use document::{Document, RevealMode};
70pub use find::{default_find_debounce, FindQuery, FindState, FIND_MATCH_CAP};
71pub use fold_map::{FoldMap, FoldSet, InlineFold, VisibleRow};
72pub use highlight::{
73    HIGHLIGHT_CHECKPOINT_STRIDE, HIGHLIGHT_MAX_LINES_PER_CALL, HIGHLIGHT_MAX_WINDOW_ROWS,
74    HIGHLIGHT_WINDOW_SLACK,
75};
76pub use highlight::{
77    padded_highlight_window, tokenize_segment, HighlightCache, HighlightEngine, HighlightSpan,
78    Highlighter, Rgba, SegmentBoundary, SegmentStart, SegmentTokens, SpanStyle, SyntaxDef,
79    TokenTheme,
80};
81pub use history::{GroupingHint, OpClass};
82pub use intel::completion::{CompletionController, CompletionState, PopupList};
83pub use intel::hover::{Hover, HoverCx, HoverInfo, HOVER_IDLE_DELAY_MS};
84pub use intel::signature::{SignatureCx, SignatureHelp, SignatureInfo};
85pub use intel::snippet::{CaretOutcome, Snippet, SnippetError, SnippetSession, TabOutcome, TabStop};
86pub use intel::providers::{
87    is_completion_word_char, CompletionCx, CompletionItem, CompletionKind, CompletionTrigger,
88    Completions, InsertText, LOOKBACK_LINES,
89};
90pub use movement::{move_selections, ColumnDir, Granularity, Motion};
91pub use patch::{Edit, Patch};
92pub use row_layout::{
93    tail_start_col, virtual_cell, CaretCell, Chip, DisplayPosition, HeaderHit, HeaderLayout,
94    RowLayout, TailGlyph, FOLD_PLACEHOLDER_CELLS, INLINE_CHIP_CELLS,
95};
96pub use selection::{Selection, SelectionId, SelectionSet};
97pub use transaction::{Committed, EditOp, TransactionError};
98pub use verbs::default_indent_size;