1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//! `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.
//!
//! # Two tiers
//!
//! - [`CodeEditor`] — **start here.** The batteries-included tier: it owns a
//! [`scrive_core::Document`] and runs the highlighting, find, focus, and
//! language-intelligence plumbing internally, so integrating is three wires
//! ([`update`](CodeEditor::update), [`view`](CodeEditor::view),
//! [`subscription`](CodeEditor::subscription)) plus registering
//! [`required_fonts`] at startup. Highlighting is coloured at load with no
//! scroll needed; the find bar, selection, undo, and folding are on by default.
//! See `examples/minimal.rs`.
//! - [`Editor`] — the low-level *controlled* widget: it renders a `Document` and
//! emits semantic [`Action`]s the application applies by hand. Full control,
//! all the plumbing on you. See `examples/scratch.rs`.
//!
//! The minimal integration:
//!
//! ```no_run
//! use iced::{Element, Subscription, Task};
//! use scrive_iced::{CodeEditor, Event};
//!
//! struct App { editor: CodeEditor }
//!
//! #[derive(Debug, Clone)]
//! enum Message { Editor(Event) }
//!
//! impl App {
//! fn new() -> Self { Self { editor: CodeEditor::new("fn main() {}\n") } }
//! fn update(&mut self, m: Message) -> Task<Message> {
//! match m { Message::Editor(e) => self.editor.update(e).map(Message::Editor) }
//! }
//! fn view(&self) -> Element<'_, Message> { self.editor.view().map(Message::Editor) }
//! fn subscription(&self) -> Subscription<Message> {
//! self.editor.subscription().map(Message::Editor)
//! }
//! }
//! ```
pub use ;
pub use ;
pub use Metrics;
/// The bundled [Codicon](https://github.com/microsoft/vscode-codicons) 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`).
pub const CODICON_FONT: & = include_bytes!;
/// The [`iced::Font`] handle for the bundled [`CODICON_FONT`] (family `"codicon"`).
pub const CODICON: Font = with_name;
/// 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))`.
/// The bundled **Scrive Dark** syntax theme — an original, MIT-licensed dark
/// theme (the one that shipped with 0.1.0). It is the sensible default so a host
/// gets colored text from a grammar alone, without supplying a `.tmTheme`: the
/// batteries-included editor tier applies it unless the host overrides it with
/// another [`TokenTheme`](scrive_core::TokenTheme).
///
/// The theme is compiled in, so parsing it cannot fail at runtime — a malformed
/// asset is a packaging bug the crate's own tests catch, not a caller error.
/// That is why this returns the theme directly rather than a `Result`.
/// 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.