pub struct CommandPaletteState {
pub input: String,
pub cursor: usize,
pub open: bool,
pub last_selected: Option<usize>,
/* private fields */
}Expand description
State for a command palette overlay.
Renders as a modal with a search input and filtered command list.
Fields§
§input: StringCurrent search query.
cursor: usizeCursor index within input.
open: boolWhether the palette modal is open.
last_selected: Option<usize>The last selected command index, set when the user confirms a selection.
Check this after response.changed is true.
Implementations§
Source§impl CommandPaletteState
impl CommandPaletteState
Sourcepub fn new(commands: Vec<PaletteCommand>) -> Self
pub fn new(commands: Vec<PaletteCommand>) -> Self
Create command palette state from a command list.
Sourcepub fn commands(&self) -> &[PaletteCommand]
pub fn commands(&self) -> &[PaletteCommand]
Return all available commands.
Sourcepub fn set_commands(&mut self, commands: Vec<PaletteCommand>)
pub fn set_commands(&mut self, commands: Vec<PaletteCommand>)
Replace all commands and synchronize filter and selection state.
Sourcepub fn push_command(&mut self, command: PaletteCommand)
pub fn push_command(&mut self, command: PaletteCommand)
Append a command and invalidate the filter cache.
Sourcepub fn remove_command(&mut self, index: usize) -> Option<PaletteCommand>
pub fn remove_command(&mut self, index: usize) -> Option<PaletteCommand>
Remove and return a command by data index.
Sourcepub fn clear_commands(&mut self)
pub fn clear_commands(&mut self)
Remove all commands and reset cache-coupled selection state.
Trait Implementations§
Source§impl Clone for CommandPaletteState
impl Clone for CommandPaletteState
Source§fn clone(&self) -> CommandPaletteState
fn clone(&self) -> CommandPaletteState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CommandPaletteState
impl RefUnwindSafe for CommandPaletteState
impl Send for CommandPaletteState
impl Sync for CommandPaletteState
impl Unpin for CommandPaletteState
impl UnsafeUnpin for CommandPaletteState
impl UnwindSafe for CommandPaletteState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more