pub struct CommandPanelState {Show 26 fields
pub input_text: String,
pub cursor_position: usize,
pub mode: InteractionMode,
pub input_state: InputState,
pub command_history: Vec<CommandHistoryItem>,
pub history_index: Option<usize>,
pub unsent_input_backup: Option<String>,
pub script_cache: Option<ScriptCache>,
pub command_cursor_line: usize,
pub command_cursor_column: usize,
pub cached_panel_width: u16,
pub file_completion_cache: Option<FileCompletionCache>,
pub saved_input_cursor: usize,
pub saved_script_cursor: Option<(usize, usize)>,
pub previous_mode: Option<InteractionMode>,
pub static_lines: Vec<StaticTextLine>,
pub scroll_offset: usize,
pub styled_buffer: Option<Vec<Line<'static>>>,
pub styled_at_history_index: Option<usize>,
pub jk_escape_state: JkEscapeState,
pub jk_timer: Option<Instant>,
pub max_history_items: usize,
pub command_history_manager: CommandHistory,
pub history_search: HistorySearchState,
pub auto_suggestion: AutoSuggestionState,
pub batch_loading: Option<BatchLoadingState>,
}Expand description
Command panel state
Fields§
§input_text: String§cursor_position: usize§mode: InteractionMode§input_state: InputState§command_history: Vec<CommandHistoryItem>§history_index: Option<usize>§unsent_input_backup: Option<String>§script_cache: Option<ScriptCache>§command_cursor_line: usize§command_cursor_column: usize§cached_panel_width: u16§file_completion_cache: Option<FileCompletionCache>§saved_input_cursor: usize§saved_script_cursor: Option<(usize, usize)>§previous_mode: Option<InteractionMode>§static_lines: Vec<StaticTextLine>§scroll_offset: usize§styled_buffer: Option<Vec<Line<'static>>>§styled_at_history_index: Option<usize>§jk_escape_state: JkEscapeState§jk_timer: Option<Instant>§max_history_items: usize§command_history_manager: CommandHistory§history_search: HistorySearchState§auto_suggestion: AutoSuggestionState§batch_loading: Option<BatchLoadingState>Implementations§
Source§impl CommandPanelState
impl CommandPanelState
pub fn new() -> Self
pub fn new_with_config(history_config: &HistoryConfig) -> Self
Sourcepub fn update_panel_width(&mut self, width: u16)
pub fn update_panel_width(&mut self, width: u16)
Update cached panel width for text wrapping calculations
Sourcepub fn reflow_command_cursor_after_width_change(&mut self)
pub fn reflow_command_cursor_after_width_change(&mut self)
Reflow command-mode cursor after width changes to keep it within valid bounds
Sourcepub fn remap_command_cursor_on_width_change(
&mut self,
old_width: u16,
new_width: u16,
)
pub fn remap_command_cursor_on_width_change( &mut self, old_width: u16, new_width: u16, )
Remap command-mode cursor from old wrapped coordinates to new width-aware coordinates
Sourcepub fn cleanup_file_completion_cache(&mut self)
pub fn cleanup_file_completion_cache(&mut self)
Clean up file completion cache if unused for too long
Sourcepub fn enter_command_mode(&mut self, panel_width: u16)
pub fn enter_command_mode(&mut self, panel_width: u16)
Enter command mode from current mode, saving cursor state
Sourcepub fn exit_command_mode(&mut self)
pub fn exit_command_mode(&mut self)
Exit command mode and return to previous mode, restoring cursor state
Sourcepub fn get_total_lines(&self) -> usize
pub fn get_total_lines(&self) -> usize
Get total number of lines in unified view (for command mode navigation)
Sourcepub fn get_command_mode_lines(&self) -> Vec<String>
pub fn get_command_mode_lines(&self) -> Vec<String>
Get all lines for command mode (unified view)
Sourcepub fn get_command_mode_wrapped_lines(
&self,
available_width: u16,
) -> Vec<String>
pub fn get_command_mode_wrapped_lines( &self, available_width: u16, ) -> Vec<String>
Get wrapped lines for command mode navigation (considering text wrapping)
Sourcepub fn move_command_cursor_up(&mut self)
pub fn move_command_cursor_up(&mut self)
Move command cursor up
Sourcepub fn move_command_cursor_down(&mut self)
pub fn move_command_cursor_down(&mut self)
Move command cursor down
Sourcepub fn move_command_cursor_left(&mut self)
pub fn move_command_cursor_left(&mut self)
Move command cursor left (supports line wrapping and Unicode)
Sourcepub fn move_command_cursor_right(&mut self)
pub fn move_command_cursor_right(&mut self)
Move command cursor right (supports line wrapping and Unicode)
Sourcepub fn history_previous(&mut self)
pub fn history_previous(&mut self)
Navigate to previous command in history (Ctrl+p)
Sourcepub fn history_next(&mut self)
pub fn history_next(&mut self)
Navigate to next command in history (Ctrl+n)
Sourcepub fn move_command_half_page_up(&mut self)
pub fn move_command_half_page_up(&mut self)
Move command cursor up by half a page (fast scroll)
Sourcepub fn move_command_half_page_down(&mut self)
pub fn move_command_half_page_down(&mut self)
Move command cursor down by half a page (fast scroll)
Sourcepub fn update_auto_suggestion(&mut self)
pub fn update_auto_suggestion(&mut self)
Update auto suggestion based on current input
Sourcepub fn accept_auto_suggestion(&mut self)
pub fn accept_auto_suggestion(&mut self)
Accept the current auto suggestion This treats the suggestion as a new command entry, clearing all related state
Sourcepub fn start_history_search(&mut self)
pub fn start_history_search(&mut self)
Start history search mode
Sourcepub fn update_history_search(&mut self, query: String)
pub fn update_history_search(&mut self, query: String)
Update history search query and find matches
Sourcepub fn next_history_match(&mut self)
pub fn next_history_match(&mut self)
Move to next history search match
Sourcepub fn exit_history_search(&mut self)
pub fn exit_history_search(&mut self)
Exit history search mode
Sourcepub fn exit_history_search_with_selection(&mut self, selected_command: &str)
pub fn exit_history_search_with_selection(&mut self, selected_command: &str)
Exit history search mode and set the selected command as new input
Sourcepub fn add_command_to_history(&mut self, command: &str)
pub fn add_command_to_history(&mut self, command: &str)
Add command to history when executed
Sourcepub fn add_command_entry(&mut self, command: &str)
pub fn add_command_entry(&mut self, command: &str)
Add command entry to both history manager and command_history, then update static_lines This is the unified method for adding commands that ensures data consistency
Sourcepub fn is_in_history_search(&self) -> bool
pub fn is_in_history_search(&self) -> bool
Check if currently in history search mode
Sourcepub fn get_history_search_query(&self) -> &str
pub fn get_history_search_query(&self) -> &str
Get current history search query
Sourcepub fn add_styled_welcome_lines(
&mut self,
styled_lines: Vec<Line<'static>>,
response_type: ResponseType,
)
pub fn add_styled_welcome_lines( &mut self, styled_lines: Vec<Line<'static>>, response_type: ResponseType, )
Add styled welcome message lines directly (new simplified approach)
Sourcepub fn get_suggestion_text(&self) -> Option<&str>
pub fn get_suggestion_text(&self) -> Option<&str>
Get auto suggestion text for rendering
Sourcepub fn get_display_text(&self) -> &str
pub fn get_display_text(&self) -> &str
Get the text that should be displayed in the input line In normal mode, this is just the input text (auto-suggestions are handled separately) In history search mode, this is the matched command
Sourcepub fn get_display_cursor_position(&self) -> usize
pub fn get_display_cursor_position(&self) -> usize
Get the position where cursor should be displayed This is always based on the actual input text, not auto-suggestions
Trait Implementations§
Source§impl Debug for CommandPanelState
impl Debug for CommandPanelState
Auto Trait Implementations§
impl Freeze for CommandPanelState
impl RefUnwindSafe for CommandPanelState
impl Send for CommandPanelState
impl Sync for CommandPanelState
impl Unpin for CommandPanelState
impl UnwindSafe for CommandPanelState
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> 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 more