Skip to main content

kimun_notes/ropetext/
mod.rs

1//! A text editing model for terminal editors.
2//!
3//! `ropetext` owns text, the cursor, the selection, the edit history, motions,
4//! and soft-wrap layout. It owns nothing else, and the omissions are deliberate:
5//!
6//! - **No renderer.** Layout returns visual lines and cell coordinates in this
7//!   module's own plain geometry types. Painting belongs to the caller.
8//! - **No input handling.** Keys never reach this module. It exposes operations;
9//!   deciding which key performs which operation is the caller's business.
10//! - **No syntax, no markdown.** What a construct *means* never enters. Where a
11//!   syntax layer must be heard from — wrapping has to know which characters are
12//!   hidden and how far a row is inset — it is heard as data passed in, not as a
13//!   trait this module calls back into.
14//! - **No search, no clipboard, no registers.** It hands out the text in a
15//!   range; what a caller matches against it or stores it in is not its concern.
16//!
17//! # It knows nothing of kimün
18//!
19//! The omissions above are not incidental — they are the reason this module was
20//! written. It replaced a third-party textarea whose contract kept leaking
21//! editor policy (its own undo keybindings, its own idea of what a line is) into
22//! callers, and it earns its place only by staying narrower than what it
23//! replaced. The name carries no `kimun` prefix for the same reason: anything
24//! kimün-flavoured that tries to move in should look wrong on sight.
25//!
26//! This was a separate workspace crate, which made that a compiler rule — a
27//! crate cannot say `crate::settings::Theme`. It was folded in because
28//! kimun-notes is published to crates.io, and crates.io refuses to publish a
29//! crate that path-depends on an unpublished one: a workspace member the
30//! published crate depends on is either published forever or not a crate. This
31//! had no API worth stabilising, so it stopped being a crate.
32//!
33//! The rule outlived the crate. Nothing here may name `crate::` outside
34//! `crate::ropetext::`, checked in `.github/workflows/check.yml` now that the
35//! crate graph no longer can. That is the one property extraction depends on:
36//! going back out to a crate — for a reusable editor widget, say — is a `git mv`
37//! and a manifest, with nothing to untangle first.
38//!
39//! # Positions are checked, never approximated
40//!
41//! A [`Position`] can only be built by asking a [`Text`] for one, and it carries
42//! the [`Revision`] it was built against. A position the text cannot address has
43//! no value at all — the constructor returns `None` rather than clamping to
44//! something nearby — and a position used against a later revision is rejected
45//! rather than silently read as some other place in the buffer. The one call
46//! that approximates, [`Text::position_at_byte_snapped`], is named for it.
47
48mod buffer;
49mod change;
50mod history;
51mod layout;
52pub mod motion;
53mod position;
54mod text;
55mod width;
56
57pub use buffer::{EditBuffer, Snapshot, Txn};
58pub use change::{Change, Edit};
59pub use layout::{Cell, Layout, RowHints, Viewport, VisualLine};
60pub use position::{Column, Position, Revision, Span};
61pub use text::Text;
62pub use width::Metrics;