pub enum MenuAction {
SetClipboard {
text: String,
html: Option<String>,
},
SetClipboardSecret {
text: String,
},
Paste,
LookUp {
text: String,
at: Vec2,
},
}Expand description
What choosing an item leaves for the host to do, drained with
crate::runtime::Core::take_menu_actions the way window and audio
commands are.
The clipboard is the host’s in this library — the runner already reads and writes it for Cmd-C/X/V — and nothing here changes that. The core works out what to copy, which is the half it is uniquely able to do, and hands over a string.
Variants§
SetClipboard
Put this on the system clipboard. Both Copy and Cut produce one; Cut has already removed the text by the time it arrives.
html is the same selection with the formatting the core knows
about (bold, italic, a span’s declared colour), for a host that can
offer a second flavour. It is an addition to text, never a
replacement: a clipboard whose only flavour is HTML pastes markup
into every plain-text field on the machine.
SetClipboardSecret
Put this secret on the system clipboard the way a password manager
does: the text, marked concealed and transient —
org.nspasteboard.ConcealedType and TransientType on macOS,
excluded from monitoring, history and the cloud clipboard on
Windows, x-kde-passwordManagerHint: secret on Linux — so a
clipboard manager neither shows nor keeps it. Queued by
Core::set_clipboard_secret, never by a menu row. Plain text only:
a secret has no formatting to offer.
Paste
Read the clipboard and deliver it as InputEvent::Paste: a
focused editor takes it as typing, the way it takes Cmd-V, and a
focused key sink hears it as {kind:"text"} — which is how an
app that owns its text gets a paste it asked for with
Core::request_paste. The core cannot read a clipboard, so Paste
is the one standard item it can only ask for. The answer carries
the pasteboard’s markers (crate::input::ClipboardMarks), and an
answer that is a bare InputEvent::Commit is one that marked
nothing.
LookUp
Show the platform’s definition panel for text, anchored at
rect (logical viewport px — the word’s own box, which is what
macOS’s showDefinitionForAttributedString:atPoint: wants). Both
the Look Up row and a force click over text produce one; a host
that cannot show a panel drops it, and is never offered the row in
the first place (Core::set_lookup_available).
Fields
at: Vec2The baseline origin of the selection’s first line, logical
viewport px — the point
showDefinitionForAttributedString:atPoint: takes and draws
the term back over. Not a box’s corner: a box’s bottom puts the
term a line low, and a multi-run selection’s union puts it
under the last line while the panel shows the first.