Skip to main content

Module clipboard

Module clipboard 

Source
Expand description

Plain text on the platform clipboard, written and read from application code.

Copying what the user selected is the Renderer’s own business and never comes through here. This is the other way in: a “Copy link” button whose text the application already holds. The Host asks with one command record on the batch the current call produces, and the Renderer puts the text on the clipboard through Compose. Nothing comes back: a write either lands or, where there is no clipboard to write to, is dropped quietly.

A read goes the same way and does come back: read_text numbers the request, the Renderer reads the clipboard through Compose, and one ClipboardText event with that number carries the text, or says there was none, or that there was too much. Every read gets exactly one answer.

Anything on the clipboard can be read by every other application and by clipboard history tools, so this is not the way to copy a password, a token or a private key.

Modules§

read_status
What the clipboard held when a read was answered, as the wire says it.

Structs§

Clipboard
The platform clipboard, as a value a component can hold. Compose’s LocalClipboard.

Enums§

ClipboardError
Why a clipboard write was refused before anything was sent, or a read brought no text.

Constants§

MAX_TEXT_BYTES
The longest text one call may put on or read from the clipboard, in UTF-8 bytes.

Functions§

read_text
Reads the plain text on the platform clipboard and calls on_text once with it.
read_text_async
read_text as a future, for a coroutine scope or a launched effect.
set_text
Puts text on the platform clipboard as plain text, replacing what was there.
use_clipboard
The platform clipboard. Free to call anywhere, including during composition.

Type Aliases§

ReadResult
The result of one read: the text, None when there was no plain text, or ClipboardError::TooLong when there was more than one read may carry. Over-long text is never cut short, so an application can refuse the paste instead of pasting part.