Skip to main content

Cursor

Trait Cursor 

Source
pub trait Cursor: Send {
    // Required methods
    fn cursor(&self) -> Pos;
    fn set_cursor(&mut self, pos: Pos);
    fn byte_offset(&self, pos: Pos) -> usize;
    fn pos_at_byte(&self, byte: usize) -> Pos;
}
Expand description

Cursor sub-trait of Buffer. Pre-0.1.0; signature follows SPEC.md §“Buffer trait surface”.

Pos here is the engine’s grapheme-indexed Pos type. Buffer implementations convert at the boundary if their internal indexing differs (e.g., the rope’s byte indexing).

Required Methods§

Source

fn cursor(&self) -> Pos

Active primary cursor position.

Source

fn set_cursor(&mut self, pos: Pos)

Move the active primary cursor.

Source

fn byte_offset(&self, pos: Pos) -> usize

Byte offset for pos. Used by regex search bridges.

Source

fn pos_at_byte(&self, byte: usize) -> Pos

Inverse of Self::byte_offset.

Implementations on Foreign Types§

Source§

impl Cursor for Buffer

Source§

fn cursor(&self) -> Pos

Source§

fn set_cursor(&mut self, pos: Pos)

Source§

fn byte_offset(&self, pos: Pos) -> usize

Source§

fn pos_at_byte(&self, byte: usize) -> Pos

Implementors§