Trait masonry::text2::Selectable
source · pub trait Selectable: Sized + TextStorage {
type Cursor<'a>: EditableTextCursor
where Self: 'a;
// Required methods
fn cursor(&self, position: usize) -> Option<Self::Cursor<'_>>;
fn slice(&self, range: Range<usize>) -> Option<Cow<'_, str>>;
fn len(&self) -> usize;
fn prev_word_offset(&self, offset: usize) -> Option<usize>;
fn next_word_offset(&self, offset: usize) -> Option<usize>;
fn prev_grapheme_offset(&self, offset: usize) -> Option<usize>;
fn next_grapheme_offset(&self, offset: usize) -> Option<usize>;
fn prev_codepoint_offset(&self, offset: usize) -> Option<usize>;
fn next_codepoint_offset(&self, offset: usize) -> Option<usize>;
fn preceding_line_break(&self, offset: usize) -> usize;
fn next_line_break(&self, offset: usize) -> usize;
fn is_empty(&self) -> bool;
}
Expand description
Text which can have internal selections
Required Associated Types§
type Cursor<'a>: EditableTextCursor where Self: 'a
Required Methods§
sourcefn cursor(&self, position: usize) -> Option<Self::Cursor<'_>>
fn cursor(&self, position: usize) -> Option<Self::Cursor<'_>>
Create a cursor with a reference to the text and a offset position.
Returns None if the position isn’t a codepoint boundary.
sourcefn prev_word_offset(&self, offset: usize) -> Option<usize>
fn prev_word_offset(&self, offset: usize) -> Option<usize>
Get the previous word offset from the given offset, if it exists.
sourcefn next_word_offset(&self, offset: usize) -> Option<usize>
fn next_word_offset(&self, offset: usize) -> Option<usize>
Get the next word offset from the given offset, if it exists.
sourcefn prev_grapheme_offset(&self, offset: usize) -> Option<usize>
fn prev_grapheme_offset(&self, offset: usize) -> Option<usize>
Get the next grapheme offset from the given offset, if it exists.
sourcefn next_grapheme_offset(&self, offset: usize) -> Option<usize>
fn next_grapheme_offset(&self, offset: usize) -> Option<usize>
Get the next grapheme offset from the given offset, if it exists.
sourcefn prev_codepoint_offset(&self, offset: usize) -> Option<usize>
fn prev_codepoint_offset(&self, offset: usize) -> Option<usize>
Get the previous codepoint offset from the given offset, if it exists.
sourcefn next_codepoint_offset(&self, offset: usize) -> Option<usize>
fn next_codepoint_offset(&self, offset: usize) -> Option<usize>
Get the next codepoint offset from the given offset, if it exists.
sourcefn preceding_line_break(&self, offset: usize) -> usize
fn preceding_line_break(&self, offset: usize) -> usize
Get the preceding line break offset from the given offset
sourcefn next_line_break(&self, offset: usize) -> usize
fn next_line_break(&self, offset: usize) -> usize
Get the next line break offset from the given offset
Object Safety§
This trait is not object safe.