Skip to main content

CommandPalette

Struct CommandPalette 

Source
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

Source

pub fn open(&mut self)

Open the palette, clearing the query and selection.

Source

pub fn close(&mut self)

Close the palette (does not clear invoked).

Source

pub fn is_open(&self) -> bool

Is the overlay currently showing?

Source

pub fn invoked(&self) -> Option<&'static str>

The last command fired (by pick or invoke).

Source

pub fn query(&self) -> &str

Current query text (observable for tests).

Source

pub fn cursor(&self) -> usize

Current highlighted-row index, into rank’s result for the query.

Source

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.

Source

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.

Source

pub fn state_json(&self, commands: &[Command]) -> Value

Observable state for the introspection dump.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for CommandPalette

Source§

fn default() -> CommandPalette

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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> 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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.