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.
Trait Implementations§
Source§impl Clone for MenuAction
impl Clone for MenuAction
Source§fn clone(&self) -> MenuAction
fn clone(&self) -> MenuAction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MenuAction
impl Debug for MenuAction
Source§impl PartialEq for MenuAction
impl PartialEq for MenuAction
impl StructuralPartialEq for MenuAction
Auto Trait Implementations§
impl Freeze for MenuAction
impl RefUnwindSafe for MenuAction
impl Send for MenuAction
impl Sync for MenuAction
impl Unpin for MenuAction
impl UnsafeUnpin for MenuAction
impl UnwindSafe for MenuAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.