Skip to main content

Crate scrive_iced

Crate scrive_iced 

Source
Expand description

scrive-iced — the iced 0.14 integration for the scrive code editor.

Turns scrive_core into an on-screen widget: a direct iced::advanced::Widget (deliberately not a canvas::Program, because only the low-level widget API exposes the operate() hook needed to join iced’s focus/operation protocol), with a gutter, N-caret selections, syntect highlighting, diagnostic squiggles, a completion popup, and hover.

Editor renders a scrive_core::Document and emits Actions the application applies to its document. See examples/scratch.rs for the wiring and a runnable window.

Re-exports§

pub use editor::default_autoscroll_margin;
pub use editor::Action;
pub use editor::Editor;
pub use editor::SCROLLBAR_WIDTH;
pub use metrics::Metrics;

Modules§

editor
The editor widget: a direct iced::advanced::Widget.
icon
Codicon glyph codepoints scrive draws. Names and values are from the codicon mapping.json (verified against v0.0.45); the private-use-area codepoints are only meaningful rendered in the CODICON font.
metrics
Monospace text metrics, measured once per (font, size) from the renderer’s own shaper — never a hardcoded advance.
popup
Completion-popup geometry: the pure placement, windowing, and sizing math for the completion popup. The rendering itself lives in the editor widget (it reuses the widget’s fill/text helpers); this module is the testable geometry it drives. Every function is recomputed each frame against the live caret, so the popup tracks the caret rather than freezing at the position it opened.

Constants§

CODICON
The iced::Font handle for the bundled CODICON_FONT (family "codicon").
CODICON_FONT
The bundled Codicon icon font (v0.0.45) — VS Code’s own UI glyph set. The host application must load these bytes into iced’s font system at startup (e.g. iced::application(..).font(scrive_iced::CODICON_FONT)); after that the widget’s fold-gutter chevrons and any app chrome can draw glyphs in the CODICON font. Icons © Microsoft, CC BY 4.0 (see assets/CODICON-LICENSE.md).

Functions§

required_fonts
Every font the widget needs registered in iced’s font system at startup — register them all and the fold-gutter chevrons and find-bar icons render; omit one and its glyphs fall back to per-machine tofu. One owner so an integrator can load the whole set instead of enumerating it by hand (today just CODICON_FONT): scrive_iced::required_fonts().iter().fold(app, |app, f| app.font(*f)).