Skip to main content

CursorView

Struct CursorView 

Source
pub struct CursorView<'a, S: Wrap, T: Wrap> { /* private fields */ }

Implementations§

Source§

impl<'a, S: Wrap, T: Wrap> CursorView<'a, S, T>

Source

pub fn on_drop(self, f: impl FnOnce(&mut Self) + 'a) -> Self

Source§

impl<'a, S: WrapRef, T: WrapRef> CursorView<'a, S, T>

Source

pub fn new( text: T::WrapRef<'a, Text>, state: S::WrapRef<'a, CursorState>, ) -> Result<Self>

Source

pub fn text(&self) -> &Text

Source

pub fn state(&self) -> &CursorState

Source

pub fn byte_index(&self) -> usize

Source

pub fn line_index(&self) -> usize

Source

pub fn line_number(&self) -> usize

Source

pub fn column_number(&self) -> usize

Source

pub fn display_column(&self) -> usize

Source

pub fn grapheme(&self) -> RopeSlice<'_>

Source

pub fn line(&self) -> RopeSlice<'_>

Source

pub fn is_at_start(&self) -> bool

Source

pub fn is_at_end(&self) -> bool

Source

pub fn save(&self) -> CursorSnapshot

Source

pub fn assert_invariants(&self) -> Result<()>

Source§

impl<S: WrapMut, T: WrapRef> CursorView<'_, S, T>

Source

pub fn move_to(&mut self, byte_index: usize)

Source

pub fn move_left(&mut self, count: usize) -> bool

Source

pub fn move_right(&mut self, count: usize) -> bool

Source

pub fn move_up(&mut self, goal_column: GoalColumn, count: usize) -> bool

Source

pub fn move_down(&mut self, goal_column: GoalColumn, count: usize) -> bool

Source

pub fn move_to_prev_byte(&mut self, byte: u8, count: usize) -> bool

Source

pub fn move_to_next_byte(&mut self, byte: u8, count: usize) -> bool

Source

pub fn move_to_prev_blank(&mut self, count: usize) -> bool

Source

pub fn move_to_next_blank(&mut self, count: usize) -> bool

Source

pub fn move_to_start(&mut self)

Source

pub fn move_to_end(&mut self)

Source

pub fn move_to_bottom(&mut self)

Source

pub fn move_to_line_start(&mut self)

Source

pub fn move_to_line_non_blank_start(&mut self)

Source

pub fn move_to_line_end(&mut self)

Move onto the line’s end: its '\n' (or "\r\n") grapheme. Always succeeds because every line is terminated.

Source

pub fn move_until_line_end(&mut self)

Move onto the last grapheme before the line’s end. Stays on the line end grapheme when the line is empty.

Source

pub fn restore(&mut self, snapshot: &CursorSnapshot) -> bool

Source§

impl<S: WrapMut, T: WrapMut> CursorView<'_, S, T>

Source

pub fn insert_char(&mut self, char: char) -> Edit

Source

pub fn insert(&mut self, text: &str) -> Edit

Insert before the grapheme the cursor occupies. The cursor stays on its grapheme (i.e. ends up after the inserted text).

Source

pub fn delete_before(&mut self) -> Option<Edit>

Delete the grapheme before the cursor. Behavior traditionally associated with the Backspace key.

Source

pub fn delete_after(&mut self) -> Option<Edit>

Delete the grapheme the cursor occupies, unless it is the text’s final newline. Behavior traditionally associated with the Delete key.

Trait Implementations§

Source§

impl<S: Wrap, T: Wrap> Drop for CursorView<'_, S, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<R> TryFrom<(R, usize)> for CursorView<'_, WBox, WBox>
where R: Into<Text>,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from((text, byte_index): (R, usize)) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a, S, T> !RefUnwindSafe for CursorView<'a, S, T>

§

impl<'a, S, T> !Send for CursorView<'a, S, T>

§

impl<'a, S, T> !Sync for CursorView<'a, S, T>

§

impl<'a, S, T> !UnwindSafe for CursorView<'a, S, T>

§

impl<'a, S, T> Freeze for CursorView<'a, S, T>
where <S as Wrap>::Wrap<'a, CursorState>: Freeze, <T as Wrap>::Wrap<'a, Text>: Freeze, Option<Box<dyn FnOnce(&mut CursorView<'a, S, T>) + 'a>>: Freeze,

§

impl<'a, S, T> Unpin for CursorView<'a, S, T>
where <S as Wrap>::Wrap<'a, CursorState>: Unpin, <T as Wrap>::Wrap<'a, Text>: Unpin, Option<Box<dyn FnOnce(&mut CursorView<'a, S, T>) + 'a>>: Unpin,

§

impl<'a, S, T> UnsafeUnpin for CursorView<'a, S, T>
where <S as Wrap>::Wrap<'a, CursorState>: UnsafeUnpin, <T as Wrap>::Wrap<'a, Text>: UnsafeUnpin, Option<Box<dyn FnOnce(&mut CursorView<'a, S, T>) + 'a>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<I> FromItem<I> for I

Source§

fn from_item(item: I) -> I

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more