pub struct TextInput {
pub buffer: String,
pub cursor: usize,
pub selection_start: Option<usize>,
pub selection_end: Option<usize>,
}Expand description
Text input buffer with cursor and selection
Fields§
§buffer: StringText buffer
cursor: usizeCursor position (byte offset)
selection_start: Option<usize>Selection start (byte offset, None if no selection)
selection_end: Option<usize>Selection end (byte offset)
Implementations§
Source§impl TextInput
impl TextInput
pub fn new() -> Self
pub fn from_text(text: &str) -> Self
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 insert_str(&mut self, s: &str)
pub fn insert_str(&mut self, s: &str)
Insert a string at the cursor position
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor right
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text
Sourcepub fn selected_text(&self) -> Option<&str>
pub fn selected_text(&self) -> Option<&str>
Get selected text
Sourcepub fn delete_selection(&mut self) -> bool
pub fn delete_selection(&mut self) -> bool
Delete selected text
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear selection
Sourcepub fn handle_key(
&mut self,
key_code: u32,
char_code: u32,
modifiers: u8,
) -> bool
pub fn handle_key( &mut self, key_code: u32, char_code: u32, modifiers: u8, ) -> bool
Handle a key event. Returns true if text changed.
Sourcepub fn render_parts(&self) -> (&str, &str)
pub fn render_parts(&self) -> (&str, &str)
Get the display string with cursor marker for rendering. Returns (text_before_cursor, text_after_cursor).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextInput
impl RefUnwindSafe for TextInput
impl Send for TextInput
impl Sync for TextInput
impl Unpin for TextInput
impl UnwindSafe for TextInput
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)