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
selectedis always <filtered.len()(or 0 when empty).- Results are sorted by descending score with stable tie-breaking.
- Query changes trigger incremental re-scoring (not full rescan) when the query extends the previous one.
Implementations§
Source§impl CommandPalette
impl CommandPalette
Sourcepub fn with_style(self, style: PaletteStyle) -> Self
pub fn with_style(self, style: PaletteStyle) -> Self
Set the visual style (builder).
Sourcepub fn set_style(&mut self, style: PaletteStyle)
pub fn set_style(&mut self, style: PaletteStyle)
Set the visual style.
Sourcepub fn with_max_visible(self, n: usize) -> Self
pub fn with_max_visible(self, n: usize) -> Self
Set max visible results (builder).
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Set a custom title for the palette border (builder).
Defaults to " Command Palette ". The title is rendered centered in the
top border. Surrounding spaces are the caller’s responsibility.
Sourcepub fn set_title(&mut self, title: impl Into<String>)
pub fn set_title(&mut self, title: impl Into<String>)
Set a custom title for the palette border.
Sourcepub fn with_fill_area(self, fill: bool) -> Self
pub fn with_fill_area(self, fill: bool) -> Self
Use the full area passed to render() instead of computing a centered
sub-area (builder).
When true, the palette fills the entire Rect handed to
Widget::render, letting the caller control position and size
externally. When false (the default), the palette computes its own
dimensions (~60 % width, centered, 1/6 from top).
Sourcepub fn set_fill_area(&mut self, fill: bool)
pub fn set_fill_area(&mut self, fill: bool)
Set whether the palette should fill the entire render area.
Sourcepub fn enable_evidence_tracking(&mut self, enabled: bool)
pub fn enable_evidence_tracking(&mut self, enabled: bool)
Enable or disable evidence tracking for match results.
Sourcepub fn register(
&mut self,
title: impl Into<String>,
description: Option<&str>,
tags: &[&str],
) -> &mut Self
pub fn register( &mut self, title: impl Into<String>, description: Option<&str>, tags: &[&str], ) -> &mut Self
Register a new action.
Sourcepub fn register_action(&mut self, action: ActionItem) -> &mut Self
pub fn register_action(&mut self, action: ActionItem) -> &mut Self
Register an action item directly.
Sourcepub fn replace_actions(&mut self, actions: Vec<ActionItem>)
pub fn replace_actions(&mut self, actions: Vec<ActionItem>)
Replace all actions with a new list.
This resets caches and refreshes the filtered results.
Sourcepub fn clear_actions(&mut self)
pub fn clear_actions(&mut self)
Clear all registered actions.
Sourcepub fn action_count(&self) -> usize
pub fn action_count(&self) -> usize
Number of registered actions.
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Whether the palette is currently visible.
Sourcepub fn set_query(&mut self, query: impl Into<String>)
pub fn set_query(&mut self, query: impl Into<String>)
Replace the query string and re-run filtering.
Sourcepub fn result_count(&self) -> usize
pub fn result_count(&self) -> usize
Number of filtered results.
Sourcepub fn selected_index(&self) -> usize
pub fn selected_index(&self) -> usize
Currently selected index.
Sourcepub fn selected_action(&self) -> Option<&ActionItem>
pub fn selected_action(&self) -> Option<&ActionItem>
Get the currently selected action, if any.
Sourcepub fn selected_match(&self) -> Option<PaletteMatch<'_>>
pub fn selected_match(&self) -> Option<PaletteMatch<'_>>
Read-only access to the selected match (action + result).
Sourcepub fn results(&self) -> impl Iterator<Item = PaletteMatch<'_>>
pub fn results(&self) -> impl Iterator<Item = PaletteMatch<'_>>
Iterate over the current filtered results.
Sourcepub fn set_match_filter(&mut self, filter: MatchFilter)
pub fn set_match_filter(&mut self, filter: MatchFilter)
Set a match-type filter and refresh results.
Sourcepub fn scorer_stats(&self) -> &IncrementalStats
pub fn scorer_stats(&self) -> &IncrementalStats
Get scorer statistics for diagnostics.
Sourcepub fn handle_event(&mut self, event: &Event) -> Option<PaletteAction>
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.