pub struct InputEditor { /* private fields */ }Expand description
Input text editor with cursor management and history
Implementations§
Source§impl InputEditor
impl InputEditor
Sourcepub fn with_history(history_path: &PathBuf) -> Result<Self, String>
pub fn with_history(history_path: &PathBuf) -> Result<Self, String>
Create editor with history loaded from file
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Get the current text (for submission) Returns full pasted content + any typed text after it
Sourcepub fn display_text(&self) -> &str
pub fn display_text(&self) -> &str
Get text for display in UI Returns placeholder for pasted content (use display_text_combined() for full display)
Sourcepub fn display_text_combined(&self) -> Cow<'_, str>
pub fn display_text_combined(&self) -> Cow<'_, str>
Get display text with appended typed text Shows: “{text before} {placeholder} {text after}” depending on context
Sourcepub fn text_mut(&mut self) -> &mut String
pub fn text_mut(&mut self) -> &mut String
Get a mutable reference to the text buffer Note: This only affects the typed text, not pasted content
Sourcepub fn cursor(&self) -> usize
pub fn cursor(&self) -> usize
Get cursor position For pasted content, returns display_cursor position
Sourcepub fn set_cursor(&mut self, pos: usize)
pub fn set_cursor(&mut self, pos: usize)
Set cursor position (clamped to valid range)
Sourcepub fn has_pasted_content(&self) -> bool
pub fn has_pasted_content(&self) -> bool
Check if we have large pasted content (displayed as placeholder)
Sourcepub fn is_cursor_at_start(&self) -> bool
pub fn is_cursor_at_start(&self) -> bool
Check if cursor is at start
Sourcepub fn is_cursor_at_end(&self) -> bool
pub fn is_cursor_at_end(&self) -> bool
Check if cursor is at end
Sourcepub fn insert_char(&mut self, c: char)
pub fn insert_char(&mut self, c: char)
Insert a character at cursor position Note: If there’s pasted content, position depends on cursor zone
Sourcepub fn insert_str(&mut self, s: &str)
pub fn insert_str(&mut self, s: &str)
Insert a string at cursor position Note: If there’s pasted content, position depends on cursor zone
Sourcepub fn insert_paste(&mut self, text: &str) -> bool
pub fn insert_paste(&mut self, text: &str) -> bool
Insert paste with size limit Returns true if truncated
Sourcepub fn delete_char_before(&mut self) -> bool
pub fn delete_char_before(&mut self) -> bool
Delete character before cursor (backspace)
Sourcepub fn delete_char_at(&mut self) -> bool
pub fn delete_char_at(&mut self) -> bool
Delete character at cursor (delete key)
Sourcepub fn move_left(&mut self)
pub fn move_left(&mut self)
Move cursor left one character For pasted content, navigates through display text zones
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor right one character For pasted content, navigates through display text zones
Sourcepub fn move_to_start(&mut self)
pub fn move_to_start(&mut self)
Move cursor to start
Sourcepub fn move_to_end(&mut self)
pub fn move_to_end(&mut self)
Move cursor to end
Sourcepub fn take_trimmed(&mut self) -> String
pub fn take_trimmed(&mut self) -> String
Get trimmed text and clear
Sourcepub fn replace_range(&mut self, start: usize, end: usize, replacement: &str)
pub fn replace_range(&mut self, start: usize, end: usize, replacement: &str)
Replace text in a range (used for autocomplete)
Sourcepub fn delete_range_to_cursor(&mut self, start: usize)
pub fn delete_range_to_cursor(&mut self, start: usize)
Delete from start to cursor
Sourcepub fn text_before_cursor(&self) -> &str
pub fn text_before_cursor(&self) -> &str
Get text before cursor
Sourcepub fn text_after_cursor(&self) -> &str
pub fn text_after_cursor(&self) -> &str
Get text after cursor
Sourcepub fn char_at_cursor(&self) -> Option<char>
pub fn char_at_cursor(&self) -> Option<char>
Get character at cursor (if any)
Sourcepub fn char_before_cursor(&self) -> Option<char>
pub fn char_before_cursor(&self) -> Option<char>
Get character before cursor (if any)
Navigate to previous (older) history entry Returns true if navigation happened
Navigate to next (newer) history entry Returns true if navigation happened (false if at newest)
Check if currently navigating history
Sourcepub fn take_and_add_to_history(&mut self) -> String
pub fn take_and_add_to_history(&mut self) -> String
Add current text to history and clear
Sourcepub fn history(&self) -> &InputHistory
pub fn history(&self) -> &InputHistory
Get reference to history (for debugging)
Sourcepub fn history_mut(&mut self) -> &mut InputHistory
pub fn history_mut(&mut self) -> &mut InputHistory
Get mutable reference to history (for testing)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InputEditor
impl RefUnwindSafe for InputEditor
impl Send for InputEditor
impl Sync for InputEditor
impl Unpin for InputEditor
impl UnsafeUnpin for InputEditor
impl UnwindSafe for InputEditor
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