1pub mod conflict;
2pub mod document;
3pub mod editor;
4pub mod language;
5pub mod layout;
6pub mod math;
7pub mod outline;
8pub mod reading;
9pub mod search;
10pub mod spelling;
11pub mod template;
12
13pub mod date;
14#[cfg(feature = "gpu")]
15pub mod gpu;
16#[cfg(feature = "interaction")]
17pub mod interaction;
18#[cfg(feature = "pdf")]
19pub mod print;
20#[cfg(feature = "gpu")]
21pub mod recording;
22#[cfg(feature = "gpu")]
23pub mod site;
24
25/// Points in the half inch rule line spacings are stored in.
26pub(crate) const HALF_INCH: f32 = 36.0;
27/// How thick rule lines draw at the least, in points.
28pub(crate) const RULE_WIDTH: f32 = 0.75;
29/// How far left of the margin origin a page's margin rule runs, in points.
30pub(crate) const MARGIN_RULE: f32 = 0.75;
31
32/// Where an object stored with `layout` lies; an unset coordinate is zero.
33pub(crate) fn origin(layout: &onestore::document::Layout) -> [f32; 2] {
34 [layout.x.unwrap_or(0.0), layout.y.unwrap_or(0.0)]
35}
36
37/// `[x0, y0, x1, y1]` moved by `[x, y]`.
38pub(crate) fn translated([x0, y0, x1, y1]: [f32; 4], [x, y]: [f32; 2]) -> [f32; 4] {
39 [x0 + x, y0 + y, x1 + x, y1 + y]
40}
41
42/// Parley's caret affinity mapped onto the page model's hidden-field affinity.
43pub fn affinity(affinity: parley::Affinity) -> onestore::page::text::Affinity {
44 match affinity {
45 parley::Affinity::Upstream => onestore::page::text::Affinity::Upstream,
46 parley::Affinity::Downstream => onestore::page::text::Affinity::Downstream,
47 }
48}