Skip to main content

CommandPalette

Struct CommandPalette 

Source
pub struct CommandPalette { /* private fields */ }
Expand description

Command palette widget for instant action search.

Provides a fuzzy-search overlay with keyboard navigation, match highlighting, and incremental scoring for responsive keystroke handling.

§Invariants

  1. selected is always < filtered.len() (or 0 when empty).
  2. Results are sorted by descending score with stable tie-breaking.
  3. Query changes trigger incremental re-scoring (not full rescan) when the query extends the previous one.

Implementations§

Source§

impl CommandPalette

Source

pub fn new() -> Self

Create a new empty command palette.

Source

pub fn with_style(self, style: PaletteStyle) -> Self

Set the visual style (builder).

Source

pub fn with_max_visible(self, n: usize) -> Self

Set max visible results (builder).

Source

pub fn enable_evidence_tracking(&mut self, enabled: bool)

Enable or disable evidence tracking for match results.

Source

pub fn register( &mut self, title: impl Into<String>, description: Option<&str>, tags: &[&str], ) -> &mut Self

Register a new action.

Source

pub fn register_action(&mut self, action: ActionItem) -> &mut Self

Register an action item directly.

Source

pub fn replace_actions(&mut self, actions: Vec<ActionItem>)

Replace all actions with a new list.

This resets caches and refreshes the filtered results.

Source

pub fn clear_actions(&mut self)

Clear all registered actions.

Source

pub fn action_count(&self) -> usize

Number of registered actions.

Source

pub fn open(&mut self)

Open the palette (show it and focus the query input).

Source

pub fn close(&mut self)

Close the palette.

Source

pub fn toggle(&mut self)

Toggle visibility.

Source

pub fn is_visible(&self) -> bool

Whether the palette is currently visible.

Source

pub fn query(&self) -> &str

Current query string.

Source

pub fn set_query(&mut self, query: impl Into<String>)

Replace the query string and re-run filtering.

Source

pub fn result_count(&self) -> usize

Number of filtered results.

Source

pub fn selected_index(&self) -> usize

Currently selected index.

Source

pub fn selected_action(&self) -> Option<&ActionItem>

Get the currently selected action, if any.

Source

pub fn selected_match(&self) -> Option<PaletteMatch<'_>>

Read-only access to the selected match (action + result).

Source

pub fn results(&self) -> impl Iterator<Item = PaletteMatch<'_>>

Iterate over the current filtered results.

Source

pub fn set_match_filter(&mut self, filter: MatchFilter)

Set a match-type filter and refresh results.

Source

pub fn scorer_stats(&self) -> &IncrementalStats

Get scorer statistics for diagnostics.

Source

pub fn handle_event(&mut self, event: &Event) -> Option<PaletteAction>

Handle an input event. Returns a PaletteAction if the user executed or dismissed the palette.

Returns None if the event was consumed but no action was triggered, or if the palette is not visible.

Trait Implementations§

Source§

impl Debug for CommandPalette

Source§

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

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

impl Default for CommandPalette

Source§

fn default() -> Self

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

impl Widget for CommandPalette

Source§

fn render(&self, area: Rect, frame: &mut Frame<'_>)

Render the widget into the frame at the given area. Read more
Source§

fn is_essential(&self) -> bool

Whether this widget is essential and should always render. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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