Struct rat_widget::input::core::InputCore
source · pub struct InputCore { /* private fields */ }Expand description
Text editing core.
Implementations§
source§impl InputCore
impl InputCore
pub fn new() -> Self
sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Change the offset
sourcepub fn set_cursor(&mut self, cursor: usize, extend_selection: bool) -> bool
pub fn set_cursor(&mut self, cursor: usize, extend_selection: bool) -> bool
Cursor position as grapheme-idx. Moves the cursor to the new position, but can leave the current cursor position as anchor of the selection.
sourcepub fn set_value<S: Into<String>>(&mut self, s: S)
pub fn set_value<S: Into<String>>(&mut self, s: S)
Set the value. Resets cursor and anchor to 0.
sourcepub fn value_graphemes(&self) -> Graphemes<'_>
pub fn value_graphemes(&self) -> Graphemes<'_>
Value as grapheme iterator.
sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Anchor is active
sourcepub fn byte_pos(&self, byte_pos: usize) -> Option<usize>
pub fn byte_pos(&self, byte_pos: usize) -> Option<usize>
Convert the byte-position to a grapheme position.
sourcepub fn byte_at(&self, pos: usize) -> Option<(usize, usize)>
pub fn byte_at(&self, pos: usize) -> Option<(usize, usize)>
Grapheme position to byte position. Returns the byte-range for the grapheme at pos.
sourcepub fn char_at(&self, pos: usize) -> Option<usize>
pub fn char_at(&self, pos: usize) -> Option<usize>
Grapheme position to char position. Returns the first char position for the grapheme at pos.
sourcepub fn next_word_boundary(&self, pos: usize) -> Option<usize>
pub fn next_word_boundary(&self, pos: usize) -> Option<usize>
Find next word.
sourcepub fn prev_word_boundary(&self, pos: usize) -> Option<usize>
pub fn prev_word_boundary(&self, pos: usize) -> Option<usize>
Find previous word.
sourcepub fn insert_char(&mut self, new: char) -> bool
pub fn insert_char(&mut self, new: char) -> bool
Insert a char, replacing the selection.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InputCore
impl RefUnwindSafe for InputCore
impl Send for InputCore
impl Sync for InputCore
impl Unpin for InputCore
impl UnwindSafe for InputCore
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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>
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 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>
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