Skip to main content

InputEditor

Struct InputEditor 

Source
pub struct InputEditor { /* private fields */ }
Expand description

Input text editor with cursor management and history

Implementations§

Source§

impl InputEditor

Source

pub fn new() -> Self

Create a new empty editor

Source

pub fn with_history(history_path: &PathBuf) -> Result<Self, String>

Create editor with history loaded from file

Source

pub fn text(&self) -> String

Get the current text (for submission) Returns full pasted content + any typed text after it

Source

pub fn display_text(&self) -> &str

Get text for display in UI Returns placeholder for pasted content (use display_text_combined() for full display)

Source

pub fn display_text_combined(&self) -> Cow<'_, str>

Get display text with appended typed text Shows: “{text before} {placeholder} {text after}” depending on context

Source

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

Source

pub fn cursor(&self) -> usize

Get cursor position For pasted content, returns display_cursor position

Source

pub fn set_cursor(&mut self, pos: usize)

Set cursor position (clamped to valid range)

Source

pub fn is_empty(&self) -> bool

Check if text is empty

Source

pub fn has_pasted_content(&self) -> bool

Check if we have large pasted content (displayed as placeholder)

Source

pub fn is_cursor_at_start(&self) -> bool

Check if cursor is at start

Source

pub fn is_cursor_at_end(&self) -> bool

Check if cursor is at end

Source

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

Source

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

Source

pub fn insert_paste(&mut self, text: &str) -> bool

Insert paste with size limit Returns true if truncated

Source

pub fn delete_char_before(&mut self) -> bool

Delete character before cursor (backspace)

Source

pub fn delete_char_at(&mut self) -> bool

Delete character at cursor (delete key)

Source

pub fn move_left(&mut self)

Move cursor left one character For pasted content, navigates through display text zones

Source

pub fn move_right(&mut self)

Move cursor right one character For pasted content, navigates through display text zones

Source

pub fn move_to_start(&mut self)

Move cursor to start

Source

pub fn move_to_end(&mut self)

Move cursor to end

Source

pub fn clear(&mut self)

Clear all text

Source

pub fn take_trimmed(&mut self) -> String

Get trimmed text and clear

Source

pub fn replace_range(&mut self, start: usize, end: usize, replacement: &str)

Replace text in a range (used for autocomplete)

Source

pub fn delete_range_to_cursor(&mut self, start: usize)

Delete from start to cursor

Source

pub fn text_before_cursor(&self) -> &str

Get text before cursor

Source

pub fn text_after_cursor(&self) -> &str

Get text after cursor

Source

pub fn char_at_cursor(&self) -> Option<char>

Get character at cursor (if any)

Source

pub fn char_before_cursor(&self) -> Option<char>

Get character before cursor (if any)

Source

pub fn navigate_history_up(&mut self) -> bool

Navigate to previous (older) history entry Returns true if navigation happened

Source

pub fn navigate_history_down(&mut self) -> bool

Navigate to next (newer) history entry Returns true if navigation happened (false if at newest)

Source

pub fn is_navigating_history(&self) -> bool

Check if currently navigating history

Source

pub fn take_and_add_to_history(&mut self) -> String

Add current text to history and clear

Source

pub fn save_history(&self, path: &PathBuf) -> Result<(), String>

Save history to file

Source

pub fn history(&self) -> &InputHistory

Get reference to history (for debugging)

Source

pub fn history_mut(&mut self) -> &mut InputHistory

Get mutable reference to history (for testing)

Trait Implementations§

Source§

impl Default for InputEditor

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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