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
//! # `canvist_desktop`
//!
//! The canvist rich-text editor for macOS, Windows, and Linux. A
//! [`DesktopEditor`] lays a [`canvist_headless::Doc`] out with
//! `canvist_layout` and parley, paints it with `canvist_paint` (vello on the
//! GPU, `vello_cpu` for PNGs), and takes input as [`InputEvent`]s:
//!
//! - keys, with `Mod` as Cmd on macOS and Ctrl elsewhere;
//! - input methods, with preedit text underlined in place and the candidate
//! window placed by [`DesktopEditor::ime_area`];
//! - the clipboard, writing HTML and plain text and preferring HTML on
//! paste;
//! - mouse and trackpad selection: click, double-click for a word,
//! triple-click for a block, Shift-click and drag to extend, with
//! autoscroll past the edges;
//! - scrolling and high-DPI;
//! - accessibility, as an AccessKit tree of text runs.
//!
//! The core never touches a window, so tests drive it headlessly. The
//! `winit` feature (on by default) adds [`winit::EditorWindow`], which embeds
//! the editor in any winit app: it translates winit events, renders with
//! vello on wgpu, talks to the system clipboard, and runs the AccessKit
//! platform adapter.
//!
//! # Example
//!
//! ```
//! use std::time::Duration;
//!
//! use canvist_desktop::Context;
//! use canvist_desktop::DesktopEditor;
//! use canvist_desktop::EditorOptions;
//! use canvist_desktop::FontSource;
//! use canvist_desktop::InputEvent;
//! use canvist_desktop::KeyInput;
//! use canvist_desktop::MemoryClipboard;
//! use canvist_desktop::Modifiers;
//! use canvist_headless::Engine;
//! use canvist_headless::Format;
//!
//! let options = EditorOptions::new().fonts(FontSource::Bundled);
//! let mut editor = DesktopEditor::new(Engine::starter_kit(), options)?;
//! let mut clipboard = MemoryClipboard::new();
//!
//! for key in ["#", " ", "H", "i"] {
//! let event = InputEvent::Key(KeyInput::text(key, Modifiers::NONE));
//! let mut cx = Context::new(Duration::ZERO, &mut clipboard);
//! let _ = editor.handle(&event, &mut cx)?;
//! }
//!
//! editor.frame(Duration::ZERO)?;
//! assert_eq!(editor.export(Format::Markdown), "# Hi");
//! assert!(editor.render_png()?.starts_with(b"\x89PNG"));
//! # Ok::<(), canvist_desktop::DesktopError>(())
//! ```
pub use EDITOR_ID;
pub use WINDOW_ID;
pub use accesskit;
pub use canvist_headless;
pub use canvist_layout;
pub use canvist_paint;
pub use Clipboard;
pub use ClipboardContent;
pub use MemoryClipboard;
pub use DesktopEditor;
pub use FrameInfo;
pub use Viewport;
pub use DesktopError;
pub use DesktopResult;
pub use FontSource;
pub use Fonts;
pub use Context;
pub use Ime;
pub use InputEvent;
pub use KeyInput;
pub use Modifiers;
pub use PointerButton;
pub use Response;
pub use ScrollDelta;
pub use kurbo;
pub use EditorOptions;
pub use current_platform;