Skip to main content

monospace_editing/
lib.rs

1//! What a caller means to do to a diagram, and what holds one while it is being changed.
2//!
3//! [`docs/editing-model.md`](../../../docs/editing-model.md) is the design this crate implements,
4//! and [`docs/diagram-model.md`](../../../docs/diagram-model.md) is the layer below it, which this
5//! one changes nothing about.
6//!
7//! **The diagram is a value and this is a value too.** A diagram is constructed, drawn, copied and
8//! dropped, and every one of its operations hands back a new diagram rather than changing the one it
9//! was given — there is no history in it and nothing to give back. A [`Session`] is the layer that
10//! holds one: it records what each change was before it was made and hands those back on request,
11//! and **every one of its methods is asked over `&self` and hands a new session back**, which is
12//! what a session asks of a diagram and what a caller should be able to assume of both.
13//!
14//! **A command is a meaning and not one of the diagram's seven operations.** The diagram's
15//! operations are complete and coarse at once — `replace` serves a figure displaced, a figure
16//! resized, a figure restyled and a figure changed into another kind — and a caller who drags a
17//! figure and a caller who drags its border did different work and say so differently. So a
18//! command carries its own fields and the operation it becomes is decided here, which is the
19//! mapping a caller would otherwise write and get subtly wrong. **The way in is the session and
20//! not the command**: a command is handed to `Session::perform` and that is the only public door,
21//! because recording, discarding what was ahead and adopting the state at the position are three
22//! things only a session can do.
23//!
24//! **Nothing here reads a file, draws a screen or knows what is selected.** Those are layers beside
25//! this one, and the crate's `Cargo.toml` is where a reader looks to find that: it names two
26//! dependencies, and neither is one of them.
27
28mod command;
29mod session;
30mod step;
31mod utilities;
32
33pub use command::Command;
34pub use monospace_diagram::{Direction, End, Terminal};
35pub use session::Session;
36pub(crate) use step::Step;