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§

source

type Cursor<'a>: EditableTextCursor where Self: 'a

Required Methods§

source

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.

source

fn slice(&self, range: Range<usize>) -> Option<Cow<'_, str>>

Get slice of text at range.

source

fn len(&self) -> usize

Get length of text (in bytes).

source

fn prev_word_offset(&self, offset: usize) -> Option<usize>

Get the previous word offset from the given offset, if it exists.

source

fn next_word_offset(&self, offset: usize) -> Option<usize>

Get the next word offset from the given offset, if it exists.

source

fn prev_grapheme_offset(&self, offset: usize) -> Option<usize>

Get the next grapheme offset from the given offset, if it exists.

source

fn next_grapheme_offset(&self, offset: usize) -> Option<usize>

Get the next grapheme offset from the given offset, if it exists.

source

fn prev_codepoint_offset(&self, offset: usize) -> Option<usize>

Get the previous codepoint offset from the given offset, if it exists.

source

fn next_codepoint_offset(&self, offset: usize) -> Option<usize>

Get the next codepoint offset from the given offset, if it exists.

source

fn preceding_line_break(&self, offset: usize) -> usize

Get the preceding line break offset from the given offset

source

fn next_line_break(&self, offset: usize) -> usize

Get the next line break offset from the given offset

source

fn is_empty(&self) -> bool

Returns true if this text has 0 length.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Str: Deref<Target = str> + TextStorage> Selectable for Str

§

type Cursor<'a> = StringCursor<'a> where Self: 'a