pub struct Prompt {
pub message: String,
pub input: String,
pub cursor_pos: usize,
pub prompt_type: PromptType,
pub suggestions: Vec<Suggestion>,
pub original_suggestions: Option<Vec<Suggestion>>,
pub selected_suggestion: Option<usize>,
pub selection_anchor: Option<usize>,
pub suggestions_set_for_input: Option<String>,
pub sync_input_on_navigate: bool,
}Expand description
Prompt state for the minibuffer
Fields§
§message: StringThe prompt message (e.g., “Find file: “)
input: StringUser’s current input
cursor_pos: usizeCursor position in the input
prompt_type: PromptTypeWhat to do when user confirms
suggestions: Vec<Suggestion>Autocomplete suggestions (filtered)
original_suggestions: Option<Vec<Suggestion>>Original unfiltered suggestions (for prompts that filter client-side like SwitchToTab)
selected_suggestion: Option<usize>Currently selected suggestion index
selection_anchor: Option<usize>Selection anchor position (for Shift+Arrow selection) When Some(pos), there’s a selection from anchor to cursor_pos
suggestions_set_for_input: Option<String>Tracks the input value when suggestions were last set by a plugin. Used to skip Rust-side filtering when plugin has already filtered for this input.
When true, navigating suggestions updates the input text (selected) to match. Used by plugin prompts that want picker-like behavior (e.g. compose width).
Implementations§
Source§impl Prompt
impl Prompt
Sourcepub fn new(message: String, prompt_type: PromptType) -> Self
pub fn new(message: String, prompt_type: PromptType) -> Self
Create a new prompt
Sourcepub fn with_suggestions(
message: String,
prompt_type: PromptType,
suggestions: Vec<Suggestion>,
) -> Self
pub fn with_suggestions( message: String, prompt_type: PromptType, suggestions: Vec<Suggestion>, ) -> Self
Create a new prompt with suggestions
The suggestions are stored both as the current filtered list and as the original unfiltered list (for prompts that filter client-side like SwitchToTab).
Sourcepub fn with_initial_text(
message: String,
prompt_type: PromptType,
initial_text: String,
) -> Self
pub fn with_initial_text( message: String, prompt_type: PromptType, initial_text: String, ) -> Self
Create a new prompt with initial text (selected so typing replaces it)
Sourcepub fn cursor_left(&mut self)
pub fn cursor_left(&mut self)
Move cursor left (to previous grapheme cluster boundary)
Uses grapheme cluster boundaries for proper handling of combining characters like Thai diacritics, emoji with modifiers, etc.
Sourcepub fn cursor_right(&mut self)
pub fn cursor_right(&mut self)
Move cursor right (to next grapheme cluster boundary)
Uses grapheme cluster boundaries for proper handling of combining characters like Thai diacritics, emoji with modifiers, etc.
Sourcepub fn insert_char(&mut self, ch: char)
pub fn insert_char(&mut self, ch: char)
Insert a character at the cursor position
Sourcepub fn backspace(&mut self)
pub fn backspace(&mut self)
Delete one code point before cursor (backspace)
Deletes one Unicode code point at a time, allowing layer-by-layer deletion of combining characters. For Thai text, this means you can delete just the tone mark without removing the base consonant.
Sourcepub fn delete(&mut self)
pub fn delete(&mut self)
Delete grapheme cluster at cursor (delete key)
Deletes the entire grapheme cluster, handling combining characters properly.
Sourcepub fn move_to_start(&mut self)
pub fn move_to_start(&mut self)
Move to start of input
Sourcepub fn move_to_end(&mut self)
pub fn move_to_end(&mut self)
Move to end of input
Sourcepub fn set_input(&mut self, text: String)
pub fn set_input(&mut self, text: String)
Set the input text and cursor position
Used for history navigation - replaces the entire input with a new value and moves cursor to the end.
§Example
let mut prompt = Prompt::new("Search: ".to_string(), PromptType::Search);
prompt.input = "current".to_string();
prompt.cursor_pos = 7;
prompt.set_input("from history".to_string());
assert_eq!(prompt.input, "from history");
assert_eq!(prompt.cursor_pos, 12); // At endSourcepub fn select_next_suggestion(&mut self)
pub fn select_next_suggestion(&mut self)
Select next suggestion
Sourcepub fn select_prev_suggestion(&mut self)
pub fn select_prev_suggestion(&mut self)
Select previous suggestion
Sourcepub fn selected_value(&self) -> Option<String>
pub fn selected_value(&self) -> Option<String>
Get the currently selected suggestion value
Sourcepub fn get_final_input(&self) -> String
pub fn get_final_input(&self) -> String
Get the final input (use selected suggestion if available, otherwise raw input)
Sourcepub fn filter_suggestions(&mut self, match_description: bool)
pub fn filter_suggestions(&mut self, match_description: bool)
Apply fuzzy filtering to suggestions based on current input
If match_description is true, also matches against suggestion descriptions.
Updates suggestions with filtered and sorted results.
Sourcepub fn delete_word_forward(&mut self)
pub fn delete_word_forward(&mut self)
Delete from cursor to end of word (Ctrl+Delete).
Deletes from the current cursor position to the end of the current word. If the cursor is at a non-word character, skips to the next word and deletes to its end.
§Example
let mut prompt = Prompt::new("Find: ".to_string(), PromptType::OpenFile);
prompt.input = "hello world".to_string();
prompt.cursor_pos = 0; // At start of "hello"
prompt.delete_word_forward();
assert_eq!(prompt.input, " world");
assert_eq!(prompt.cursor_pos, 0);Sourcepub fn delete_word_backward(&mut self)
pub fn delete_word_backward(&mut self)
Delete from start of word to cursor (Ctrl+Backspace).
Deletes from the start of the current word to the cursor position. If the cursor is after a non-word character, deletes the previous word.
§Example
let mut prompt = Prompt::new("Find: ".to_string(), PromptType::OpenFile);
prompt.input = "hello world".to_string();
prompt.cursor_pos = 5; // After "hello"
prompt.delete_word_backward();
assert_eq!(prompt.input, " world");
assert_eq!(prompt.cursor_pos, 0);Sourcepub fn delete_to_end(&mut self)
pub fn delete_to_end(&mut self)
Delete from cursor to end of line (Ctrl+K).
Deletes all text from the cursor position to the end of the input.
§Example
let mut prompt = Prompt::new("Find: ".to_string(), PromptType::OpenFile);
prompt.input = "hello world".to_string();
prompt.cursor_pos = 5; // After "hello"
prompt.delete_to_end();
assert_eq!(prompt.input, "hello");
assert_eq!(prompt.cursor_pos, 5);Sourcepub fn get_text(&self) -> String
pub fn get_text(&self) -> String
Get the current input text (for copy operation).
Returns a copy of the entire input. In future, this could be extended to support selection ranges for copying only selected text.
§Example
let mut prompt = Prompt::new("Search: ".to_string(), PromptType::Search);
prompt.input = "test query".to_string();
assert_eq!(prompt.get_text(), "test query");Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the input (used for cut operation).
Removes all text from the input and resets cursor to start.
§Example
let mut prompt = Prompt::new("Find: ".to_string(), PromptType::OpenFile);
prompt.input = "some text".to_string();
prompt.cursor_pos = 9;
prompt.clear();
assert_eq!(prompt.input, "");
assert_eq!(prompt.cursor_pos, 0);Sourcepub fn insert_str(&mut self, text: &str)
pub fn insert_str(&mut self, text: &str)
Insert text at cursor position (used for paste operation).
Inserts the given text at the current cursor position and moves the cursor to the end of the inserted text.
§Example
let mut prompt = Prompt::new("Command: ".to_string(), PromptType::Command);
prompt.input = "save".to_string();
prompt.cursor_pos = 4;
prompt.insert_str(" file");
assert_eq!(prompt.input, "save file");
assert_eq!(prompt.cursor_pos, 9);Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Check if there’s an active selection
Sourcepub fn selection_range(&self) -> Option<(usize, usize)>
pub fn selection_range(&self) -> Option<(usize, usize)>
Get the selection range (start, end) where start <= end
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
Get the selected text
Sourcepub fn delete_selection(&mut self) -> Option<String>
pub fn delete_selection(&mut self) -> Option<String>
Delete the current selection and return the deleted text
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear selection without deleting text
Sourcepub fn move_left_selecting(&mut self)
pub fn move_left_selecting(&mut self)
Move cursor left with selection (by grapheme cluster)
Sourcepub fn move_right_selecting(&mut self)
pub fn move_right_selecting(&mut self)
Move cursor right with selection (by grapheme cluster)
Sourcepub fn move_home_selecting(&mut self)
pub fn move_home_selecting(&mut self)
Move to start of input with selection
Sourcepub fn move_end_selecting(&mut self)
pub fn move_end_selecting(&mut self)
Move to end of input with selection
Sourcepub fn move_word_left_selecting(&mut self)
pub fn move_word_left_selecting(&mut self)
Move to start of previous word with selection Mimics Buffer’s find_word_start_left behavior
Sourcepub fn move_word_right_selecting(&mut self)
pub fn move_word_right_selecting(&mut self)
Move to end of next word with selection For selection, we want to select whole words, so move to word END, not word START
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move to start of previous word (without selection) Mimics Buffer’s find_word_start_left behavior
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move to start of next word (without selection) Mimics Buffer’s find_word_start_right behavior
Trait Implementations§
Source§impl InputHandler for Prompt
impl InputHandler for Prompt
Source§fn handle_key_event(
&mut self,
event: &KeyEvent,
ctx: &mut InputContext,
) -> InputResult
fn handle_key_event( &mut self, event: &KeyEvent, ctx: &mut InputContext, ) -> InputResult
Source§fn focused_child(&self) -> Option<&dyn InputHandler>
fn focused_child(&self) -> Option<&dyn InputHandler>
Source§fn focused_child_mut(&mut self) -> Option<&mut dyn InputHandler>
fn focused_child_mut(&mut self) -> Option<&mut dyn InputHandler>
Source§fn dispatch_input(
&mut self,
event: &KeyEvent,
ctx: &mut InputContext,
) -> InputResult
fn dispatch_input( &mut self, event: &KeyEvent, ctx: &mut InputContext, ) -> InputResult
Auto Trait Implementations§
impl Freeze for Prompt
impl RefUnwindSafe for Prompt
impl Send for Prompt
impl Sync for Prompt
impl Unpin for Prompt
impl UnsafeUnpin for Prompt
impl UnwindSafe for Prompt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more