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.
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.
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
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.
Implementations§
Source§impl TransientItemKind
impl TransientItemKind
Sourcepub fn action(command: CommandId) -> Self
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.
Sourcepub fn row_args(&self) -> Option<&Args>
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.
Sourcepub fn variable_display(value: Option<&str>) -> &'static str
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
impl Clone for TransientItemKind
Source§fn clone(&self) -> TransientItemKind
fn clone(&self) -> TransientItemKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more