CommandPanelState

Struct CommandPanelState 

Source
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

Source

pub fn new() -> Self

Source

pub fn new_with_config(history_config: &HistoryConfig) -> Self

Source

pub fn update_panel_width(&mut self, width: u16)

Update cached panel width for text wrapping calculations

Source

pub fn reflow_command_cursor_after_width_change(&mut self)

Reflow command-mode cursor after width changes to keep it within valid bounds

Source

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

Source

pub fn cleanup_file_completion_cache(&mut self)

Clean up file completion cache if unused for too long

Source

pub fn enter_command_mode(&mut self, panel_width: u16)

Enter command mode from current mode, saving cursor state

Source

pub fn exit_command_mode(&mut self)

Exit command mode and return to previous mode, restoring cursor state

Source

pub fn get_total_lines(&self) -> usize

Get total number of lines in unified view (for command mode navigation)

Source

pub fn get_command_mode_lines(&self) -> Vec<String>

Get all lines for command mode (unified view)

Source

pub fn get_command_mode_wrapped_lines( &self, available_width: u16, ) -> Vec<String>

Get wrapped lines for command mode navigation (considering text wrapping)

Source

pub fn move_command_cursor_up(&mut self)

Move command cursor up

Source

pub fn move_command_cursor_down(&mut self)

Move command cursor down

Source

pub fn move_command_cursor_left(&mut self)

Move command cursor left (supports line wrapping and Unicode)

Source

pub fn move_command_cursor_right(&mut self)

Move command cursor right (supports line wrapping and Unicode)

Source

pub fn history_previous(&mut self)

Navigate to previous command in history (Ctrl+p)

Source

pub fn history_next(&mut self)

Navigate to next command in history (Ctrl+n)

Source

pub fn move_command_half_page_up(&mut self)

Move command cursor up by half a page (fast scroll)

Source

pub fn move_command_half_page_down(&mut self)

Move command cursor down by half a page (fast scroll)

Source

pub fn update_auto_suggestion(&mut self)

Update auto suggestion based on current input

Source

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

Start history search mode

Update history search query and find matches

Source

pub fn next_history_match(&mut self)

Move to next history search match

Exit history search mode

Source

pub fn exit_history_search_with_selection(&mut self, selected_command: &str)

Exit history search mode and set the selected command as new input

Source

pub fn add_command_to_history(&mut self, command: &str)

Add command to history when executed

Source

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

Check if currently in history search mode

Source

pub fn get_history_search_query(&self) -> &str

Get current history search query

Source

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)

Source

pub fn get_suggestion_text(&self) -> Option<&str>

Get auto suggestion text for rendering

Source

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

Source

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

Source§

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

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

impl Default for CommandPanelState

Source§

fn default() -> Self

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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