Skip to main content

MenuAction

Enum MenuAction 

Source
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.

Fields

§text: String
§

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.

Fields

§text: String
§

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

§text: String
§at: Vec2

The 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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MenuAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MenuAction

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MenuAction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.