Skip to main content

TransientItemKind

Enum TransientItemKind 

Source
pub enum TransientItemKind {
    Action {
        command: CommandId,
        args: Args,
    },
    Submenu(Arc<TransientSpec>),
    Flag {
        name: String,
        default: bool,
    },
    Argument {
        name: String,
        default: Option<String>,
        prompt: String,
        source: Option<TransientArgSource>,
    },
    Dismiss,
    Variable {
        key: String,
        value: Option<String>,
        action: CommandId,
    },
}
Expand description

The kind of a transient item — determines its interaction.

Variants§

§

Action

Fires an action via the action-handler registry and closes the transient.

args are the row’s OWN arguments, and they are how a menu whose rows differ only in a parameter is expressible at all. Every native menu today leaves them [Args::None] and lets the host project the menu’s TransientState through the command’s args_schema instead — flags and arguments the user toggled before pressing the key. That mechanism is per-MENU, so it cannot say “this row means template t, that one means n”, which is exactly the shape a plugin-contributed menu has (org’s capture menu, one row per template). Hence a per-row slot.

When both are present the row’s args win, because they were chosen when the row was built and the state was not.

Fields

§command: CommandId
§args: Args
§

Submenu(Arc<TransientSpec>)

Opens a nested transient (submenu). The parent transient is pushed onto a stack; BS/DEL returns to it.

§

Flag

A boolean flag that toggles in-place. The name is the key in TransientState.

Fields

§name: String
§default: bool
§

Argument

An argument that collects a value into TransientState under name.

By default it opens a minibuffer prompt. When source is set the value is picked from a list instead — MG.53’s rule is that naming a thing which must already exist gets a picker, and an argument is as much a naming site as a command is. A free-text prompt for an existing path is a typo waiting to happen, and git reports it long after the keystroke that caused it.

Either way the menu is parked and re-seated with the collected value (PendingTransientArgument → resume_parked_transient); the picker and the prompt are both surfaces the menu cannot stay seated underneath. prompt stays meaningful with a source set: it titles the picker.

Fields

§name: String
§default: Option<String>
§prompt: String
§source: Option<TransientArgSource>

None = free-text prompt. Some = pick from this registered picker source, whose accept supplies the value.

§

Dismiss

Dismisses the transient picker without firing any action. Used for ‘n’ / ‘q’ keys in confirmation dialogs.

§

Variable

MG.43g: a value owned by something OUTSIDE the transient — a git-config key, an editor option — shown inline and changed by firing action.

Distinct from Self::Flag and Self::Argument, which hold their value in TransientState for the duration of one menu. A variable’s value lives in the world and persists; the menu only reports and edits it.

value is None when the current value has not been read yet, which renders differently from a value that is read and unset. Collapsing the two would make the menu state a fact about the user’s configuration it has not actually checked — and reporting the current value is the row’s entire purpose.

Fields

§key: String

Display name of the underlying key, e.g. pull.rebase.

§value: Option<String>

Prefetched current value; None = not read yet.

§action: CommandId

Fired to change it. Prompts for the new value itself.

Implementations§

Source§

impl TransientItemKind

Source

pub fn action(command: CommandId) -> Self

The overwhelmingly common action row: fires command with no arguments of its own, leaving the menu’s TransientState projection to supply them. Every native menu builds rows this way; the struct form exists for the per-row case.

Source

pub fn row_args(&self) -> Option<&Args>

The row’s OWN arguments, if its kind can carry any.

None for every kind but Self::Action — including Self::Variable, which is an action leaf whose action prompts for its new value rather than receiving one. Reported as an Option rather than a &Args::None so the two are distinguishable without giving every variant a field it would never use.

Source

pub fn variable_display(value: Option<&str>) -> &'static str

How a Self::Variable’s current value reads in the menu.

Three distinct states, deliberately: unread, read-and-unset, and set. … is not unset — see the variant’s doc.

Trait Implementations§

Source§

impl Clone for TransientItemKind

Source§

fn clone(&self) -> TransientItemKind

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 TransientItemKind

Source§

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

Formats the value using the given formatter. Read more

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

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more