Trait masonry::text2::EditableTextCursor

source ·
pub trait EditableTextCursor {
    // Required methods
    fn set(&mut self, position: usize);
    fn pos(&self) -> usize;
    fn is_boundary(&self) -> bool;
    fn prev(&mut self) -> Option<usize>;
    fn next(&mut self) -> Option<usize>;
    fn peek_next_codepoint(&self) -> Option<char>;
    fn prev_codepoint(&mut self) -> Option<char>;
    fn next_codepoint(&mut self) -> Option<char>;
    fn at_or_next(&mut self) -> Option<usize>;
    fn at_or_prev(&mut self) -> Option<usize>;
}
Expand description

A cursor with convenience functions for moving through EditableText.

Required Methods§

source

fn set(&mut self, position: usize)

Set cursor position.

source

fn pos(&self) -> usize

Get cursor position.

source

fn is_boundary(&self) -> bool

Check if cursor position is at a codepoint boundary.

source

fn prev(&mut self) -> Option<usize>

Move cursor to previous codepoint boundary, if it exists. Returns previous codepoint as usize offset.

source

fn next(&mut self) -> Option<usize>

Move cursor to next codepoint boundary, if it exists. Returns current codepoint as usize offset.

source

fn peek_next_codepoint(&self) -> Option<char>

Get the next codepoint after the cursor position, without advancing the cursor.

source

fn prev_codepoint(&mut self) -> Option<char>

Return codepoint preceding cursor offset and move cursor backward.

source

fn next_codepoint(&mut self) -> Option<char>

Return codepoint at cursor offset and move cursor forward.

source

fn at_or_next(&mut self) -> Option<usize>

Return current offset if it’s a boundary, else next.

source

fn at_or_prev(&mut self) -> Option<usize>

Return current offset if it’s a boundary, else previous.

Implementors§