Expand description
The document model: a twig::Editor plus a byte-offset caret and selection.
Where bough moves a selection through the tree, leaf moves a caret through the characters — a normal text editor’s model — and expresses every mutation as one of twig’s offset-addressed ops:
- typing / delete →
edit_range(start, end, text)(P0) - re-anchoring → the returned
Change(P1) - cursor context →
node_at/ancestors_at(P3) - the toolbar →
wrap_range/toggle_inline/set_block,toggle_block_container/insert_link(P5)
twig reparses after every edit and leaves everything outside the splice byte-for-byte untouched, so the document stays a live, navigable AST while you type into it.
Structs§
- Capabilities
- Which of leaf’s authoring controls this document’s format can actually spell — one flag per toolbar button, resolved once so a frontend can build its chrome instead of discovering each refusal on a click.
- Doc
- Footnote
Def - A footnote definition and the reference that sends a reader to it — the
answer to
Doc::footnote_definition_at, and the other half of the round tripFootnoteRefstarts. - Footnote
Ref - A footnote reference and the note it names — the answer to
Doc::footnote_at. - Inline
Marks - The inline marks in force at a point in the document — what a toolbar
lights up. A
Copybitset rather than aHashSet, becauseDoc::active_inline_marksis called on every frame that draws a toolbar and a set that allocates to answer “is Bold on?” is a set that shouldn’t. - Landing
- Where a locator lands — the answer to
Doc::locate.
Enums§
- Disk
State - What the file behind a document looks like right now, against the bytes leaf
last read from it or wrote to it — the question a frontend asks before it
saves (a
Changedfile plus adirtydocument is an overwrite about to happen) or when its window regains focus. SeeDoc::disk_state. - Line
Flow - How the WYSIWYG view treats a soft break — a bare newline inside a
paragraph. An axis of its own, orthogonal to
MarkupMode(which governs inline-markup delimiters) and toView: any reveal preference pairs with either flow. The renderer consults it when it lays a block’s inline content into visual rows. - Markup
Mode - How much of the source markup the WYSIWYG view exposes — a per-editor
preference, orthogonal to
View. Named for markup rather than for Markdown because leaf is grammar-agnostic: twig hands it Djot, HTML and XML on the same terms, and every rung below is about delimiters, whatever grammar spells them. The examples are Markdown only because that is what most documents are. - View
- Which view the body shows.