pub struct CommandPalette { /* private fields */ }Expand description
A floating, theme-aware command palette overlay. Opened by Ctrl-K /
Ctrl-Shift-P (or CommandPalette::open), it paints a scrim + a centered
search box + a fuzzy-filtered, keyboard-navigable command list above
everything (Order::Foreground). Pure data between frames; draw it once per
frame after your deck so it lands on top.
Implementations§
Source§impl CommandPalette
impl CommandPalette
Sourcepub fn move_cursor(&mut self, delta: i32, len: usize)
pub fn move_cursor(&mut self, delta: i32, len: usize)
Move the selection by delta, wrapping within len rows. No-op when
len == 0. Up at the top wraps to the bottom; down at the bottom wraps to
the top. Split out so headless tests can drive nav without drawing.
Sourcepub fn invoke(&mut self, id: &'static str) -> &'static str
pub fn invoke(&mut self, id: &'static str) -> &'static str
Headless: fire a command by id without drawing (CLI / test parity). Sets
invoked, closes the palette, and echoes the id back.
Sourcepub fn state_json(&self, commands: &[Command]) -> Value
pub fn state_json(&self, commands: &[Command]) -> Value
Observable state for the introspection dump.
Sourcepub fn handle_hotkeys(&mut self, ctx: &Context)
pub fn handle_hotkeys(&mut self, ctx: &Context)
Read the open/close hotkeys for this frame (Ctrl-K / Ctrl-Shift-P open,
Esc closes). Call from a host that wants the palette toggled even on a
frame it doesn’t draw; ui calls this itself.
Sourcepub fn ui(
&mut self,
ctx: &Context,
commands: &[Command],
) -> Option<&'static str>
pub fn ui( &mut self, ctx: &Context, commands: &[Command], ) -> Option<&'static str>
Draw the overlay (scrim + search box + fuzzy-filtered list) above
everything, handling Ctrl-K to open, arrows (wrapping) to navigate, Enter
to pick, Esc to close. Returns the chosen command id, if any. No-op (and
returns None) while closed.