Skip to main content

Module clipboard

Module clipboard 

Source
Expand description

The clipboard family: copy, cut, and the two pastes.

The clipboard holds a value snapshot โ€” every copied entityโ€™s source id and its creation values โ€” never live references. Those source ids are what makes a cut-and-paste a move: the cut removes exactly them, so a paste that finds none of them here re-creates them under their own ids rather than building copies. Every other paste duplicates, with fresh ids and every internal reference remapped onto them.

Structsยง

Boundary ๐Ÿ”’
The boundary a paste slots pins onto: the slots the ownerโ€™s pins hold, plus the ones this gesture has handed out, and the growth that keeps the block tall enough for them โ€” the 10c policy (first_free_slot, grown_to_fit) driven by a whole group rather than one stamp. A block the document does not hold, or one whose interface is frozen, offers no slots at all.
FreshScope
The block a paste lands in that this same commit is creating: its id, and the value being created under it. Both, because the index has no row to look the second up by yet.
Insertion ๐Ÿ”’
A payload and where it lands โ€” a Paste with the document it is landing in left off, that being the move-or-duplicate question and answered before anything is inserted.
Paste
One paste gesture โ€” the payload, the session document it is landing in, and where in that document it lands. Bundled because the emitterโ€™s other three parameters are the document, the id source, and the builder.
PasteTarget
Where a paste lands: the scope its roots join, and the whole-cell delta the drop applies to them.
PinPaste
The Paste Pins gesture: copied pins, and the block whose boundary they join.
Snapshot
The copied closure as values: each entityโ€™s source id beside the init that rebuilds it, plus the artwork payloads the copies reference. Self contained โ€” blocks carry their parent links as copied, pins their slots, wires their endpoints and corners โ€” so a paste needs nothing of the document it came from.

Enumsยง

Clipboard
The clipboard payload, versioned per variant: a payload from a newer build fails to deserialize here rather than being reinterpreted, and clipboard text that is not ours at all refuses the same way โ€” which is what keeps an ordinary text paste from being read as a diagram.
Landing ๐Ÿ”’
Where one copied entity lands.
Mode ๐Ÿ”’
Which paste this is. Two questions, and a move needs both answered: the payload must be the cut this document made (Origin), and every source it names must still be gone from it โ€” a source standing again is a second paste of that cut, and duplicates.
Naming ๐Ÿ”’
How a paste names what it inserts. Keeping the ids is what makes a cut and its paste one displacement rather than a deletion and an unrelated arrival: the entity that comes back is the entity that left, so an undo of either half addresses the same thing. Minting is the copying half, and every reference inside the snapshot is remapped onto the mint.
Origin
Which gesture made a payload, and โ€” for a cut โ€” the document it was taken out of.

Functionsยง

copy
Inventory rows โ€œPasteโ€ / โ€œCut Selectionโ€โ€™s read half: the value snapshot of a selection, taken from the same closure a delete cascades over (delete::Closure) โ€” so a copied block brings its subtree, the wires landing on any of their pins with their labels, and the annotations they own.
cut
Cut: the snapshot and the cascade delete in one commit.
insert ๐Ÿ”’
One paste, both halves (Naming): every entity re-created at its landing, the roots re-pointed at the target scope and shifted by the drop.
mode ๐Ÿ”’
paste
Inventory row โ€œPasteโ€: insert a snapshot at the target scope, as a move or as a duplicate (Mode). Returns the roots โ€” what the caller selects โ€” leaving the nested structure that travelled inside them unnamed.
paste_into_fresh
Paste into a block this same commit is creating โ€” what an embedded document lands in (crate::edit::embed).
paste_pins
Paste pins: copied pins join ownerโ€™s boundary, each at the next free slot, growing the block until they fit. A frozen interface takes none of them.
pasted_icon ๐Ÿ”’
A copied icon at the paste offset; the zero icon is no artwork, so it has no box to carry.
payloads ๐Ÿ”’
The bytes behind the hashes the copies reference, each carried once โ€” a payload the document does not hold cannot travel, and its reference pastes as the โ€œno artworkโ€ zero it already is.
report_omissions ๐Ÿ”’
What a duplicate could not rebuild: a pin the target boundary had no room for, and a wire whose other endpoint the copy did not carry. Both are legitimate โ€” there is nothing to land them on โ€” but a paste that quietly delivers less than was copied is indistinguishable from one that lost it, so it says so.
shifted_artwork ๐Ÿ”’
translated ๐Ÿ”’