Skip to main content

Module clipboard

Module clipboard 

Source
Expand description

Pixel8’s clipboard data model and paste appliers, plus the native JSON clipboard codec.

The value types here are format-neutral: PICO-8 [gfx]/[sfx] blobs decode into them (see crate::pico8) and so does Pixel8’s native JSON format.

Structs§

PasteReport
The outcome of a paste, ready for the editor’s status bar.
PixelRect
A width * height block of palette-index pixels, one per cell, row-major.
SfxClip
A decoded [sfx] blob: the SFX records plus any trailing pattern footers (present when the blob came from copying a song pattern). The patterns’ channel refs hold PICO-8 source SFX slots until a paste remaps them.
Slotted
One clipboard item tagged with the PICO-8 slot it was copied from.

Enums§

ClipboardPayload
One copied item, tagged by kind. Reuses the asset structs, so Sfx::custom_wave, sprite flags, and 8-bit map tiles all survive.
Pasted
One decoded clipboard blob, by kind.

Functions§

encode
Encode a payload as a native { "app": "pixel8", … } JSON clipboard blob.
parse
Decode a clipboard string into a Pasted: a native Pixel8 JSON blob (a single { … } object), else a PICO-8 [gfx]/[sfx] blob. Any unrecognised or malformed text is an Err.
paste_pattern
Music-editor paste: append the clip’s SFX after the last used SFX slot (non-destructive), remap each footer pattern’s channel refs to where those SFX landed, then overwrite music patterns from at_pattern.
paste_sfx
SFX-editor paste: overwrite SFX slots from at with records, remapping each record’s custom-instrument note refs to the slots they land in. Records past slot 63 are dropped.
paste_sprites
Blit a pixel rectangle with its top-left at sheet pixel (x0, y0), overwriting in place. Pixels past the sheet edge are clipped. flags is one byte per covered 8x8 sprite (row-major); when Some, each byte overwrites the destination sprite’s flag byte.