Struct rat_widget::textarea::core::InputCore
source · pub struct InputCore { /* private fields */ }Expand description
Core for text editing.
Implementations§
source§impl InputCore
impl InputCore
pub fn new() -> Self
sourcepub fn set_move_col(&mut self, col: Option<usize>)
pub fn set_move_col(&mut self, col: Option<usize>)
Extra column information for cursor movement. The cursor position is capped to the current line length, so if you move up one row, you might end at a position left of the current column. If you move up once more you want to return to the original position. That’s what is stored here.
sourcepub fn set_cursor(
&mut self,
cursor: (usize, usize),
extend_selection: bool,
) -> bool
pub fn set_cursor( &mut self, cursor: (usize, usize), extend_selection: bool, ) -> bool
Set the cursor position. The value is capped to the number of text lines and the line-width. Returns true, if the cursor actually changed.
sourcepub fn set_value<S: AsRef<str>>(&mut self, s: S)
pub fn set_value<S: AsRef<str>>(&mut self, s: S)
Set the text. Resets the selection and any styles.
sourcepub fn set_value_rope(&mut self, s: Rope)
pub fn set_value_rope(&mut self, s: Rope)
Set the text value as a Rope. Resets all internal state.
sourcepub fn value_range(&self, range: TextRange) -> Option<RopeSlice<'_>>
pub fn value_range(&self, range: TextRange) -> Option<RopeSlice<'_>>
A range of the text as RopeSlice.
sourcepub fn value_as_bytes(&self) -> Bytes<'_>
pub fn value_as_bytes(&self) -> Bytes<'_>
Value as Bytes iterator.
sourcepub fn value_as_chars(&self) -> Chars<'_>
pub fn value_as_chars(&self) -> Chars<'_>
Value as Chars iterator.
sourcepub fn clear_styles(&mut self)
pub fn clear_styles(&mut self)
Clear styles.
sourcepub fn add_style(&mut self, range: TextRange, style: usize)
pub fn add_style(&mut self, range: TextRange, style: usize)
Add a style for the given range.
What is given here is the index into the Vec with the actual Styles. Those are set at the widget.
sourcepub fn styles_at(&self, pos: (usize, usize), result: &mut Vec<usize>)
pub fn styles_at(&self, pos: (usize, usize), result: &mut Vec<usize>)
Finds all styles for the given position.
Returns the indexes into the style vec.
sourcepub fn line(&self, n: usize) -> Option<RopeGraphemes<'_>>
pub fn line(&self, n: usize) -> Option<RopeGraphemes<'_>>
Returns a line as an iterator over the graphemes for the line. This contains the \n at the end.
sourcepub fn line_idx(&self, n: usize) -> Option<RopeGraphemesIdx<'_>>
pub fn line_idx(&self, n: usize) -> Option<RopeGraphemesIdx<'_>>
Returns a line as an iterator over the graphemes for the line. This contains the \n at the end.
sourcepub fn line_width(&self, n: usize) -> Option<usize>
pub fn line_width(&self, n: usize) -> Option<usize>
Line width as grapheme count.
sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Any text selection.
pub fn set_selection(&mut self, range: TextRange) -> bool
pub fn select_all(&mut self) -> bool
sourcepub fn iter_scrolled(&self, offset: (usize, usize)) -> ScrolledIter<'_> ⓘ
pub fn iter_scrolled(&self, offset: (usize, usize)) -> ScrolledIter<'_> ⓘ
Iterate over the text, shifted by the offset.
sourcepub fn next_word_boundary(&self, pos: (usize, usize)) -> Option<(usize, usize)>
pub fn next_word_boundary(&self, pos: (usize, usize)) -> Option<(usize, usize)>
Find next word.
sourcepub fn prev_word_boundary(&self, pos: (usize, usize)) -> Option<(usize, usize)>
pub fn prev_word_boundary(&self, pos: (usize, usize)) -> Option<(usize, usize)>
Find prev word.
sourcepub fn char_pos(&self, char_pos: usize) -> Option<(usize, usize)>
pub fn char_pos(&self, char_pos: usize) -> Option<(usize, usize)>
Char position to grapheme position.
sourcepub fn byte_pos(&self, byte: usize) -> Option<(usize, usize)>
pub fn byte_pos(&self, byte: usize) -> Option<(usize, usize)>
Byte position to grapheme position.
sourcepub fn byte_at(&self, pos: (usize, usize)) -> Option<(usize, usize)>
pub fn byte_at(&self, pos: (usize, usize)) -> Option<(usize, usize)>
Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.
sourcepub fn char_at(&self, pos: (usize, usize)) -> Option<usize>
pub fn char_at(&self, pos: (usize, usize)) -> Option<usize>
Returns the first char position for the grapheme position.
sourcepub fn insert_char(&mut self, pos: (usize, usize), c: char)
pub fn insert_char(&mut self, pos: (usize, usize), c: char)
Insert a character.
sourcepub fn insert_newline(&mut self, pos: (usize, usize))
pub fn insert_newline(&mut self, pos: (usize, usize))
Insert a line break.
pub fn remove(&mut self, range: TextRange)
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
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)
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>
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