pub struct Cursor {
pub block: usize,
pub part: Part,
pub offset: usize,
}Expand description
A caret: which block, which part of it, and how far into that part.
Byte offsets, like the marks — and like them, always on a character boundary.
Fields§
§block: usize§part: Part§offset: usizeImplementations§
Source§impl Cursor
impl Cursor
pub fn new(block: usize, part: Part, offset: usize) -> Self
Sourcepub fn len_in(self, doc: &Doc) -> Option<usize>
pub fn len_in(self, doc: &Doc) -> Option<usize>
How much text this position’s part holds, or None when the block has
no such part — an image and a rule have none at all.
Sourcepub fn clamp(self, doc: &Doc) -> Self
pub fn clamp(self, doc: &Doc) -> Self
Pull the caret back onto a real position: a block that exists, a part that block has, an offset inside it, and a character boundary.
Sourcepub fn left(self, doc: &Doc) -> Self
pub fn left(self, doc: &Doc) -> Self
One character left, stepping into the part or block before it.
Sourcepub fn right(self, doc: &Doc) -> Self
pub fn right(self, doc: &Doc) -> Self
One character right, stepping into the part or block after it.
Sourcepub fn up(self, doc: &Doc) -> Self
pub fn up(self, doc: &Doc) -> Self
The row above, keeping the offset where it fits.
Within a table that is the cell above in the same column; everywhere else it is the block above. A wrapped paragraph’s visual lines are not reachable from here — that needs the paint’s layout, and the editor resolves it there.
pub fn home(self) -> Self
pub fn end(self, doc: &Doc) -> Self
Sourcepub fn word_left(self, doc: &Doc) -> Self
pub fn word_left(self, doc: &Doc) -> Self
The start of the word at or before the caret — alt-left.
Whitespace first, then the run of word characters, which is the rule
every platform’s word-left follows and the one ui::TextField uses.
Sourcepub fn word_right(self, doc: &Doc) -> Self
pub fn word_right(self, doc: &Doc) -> Self
The end of the word at or after the caret — alt-right.
Trait Implementations§
impl Copy for Cursor
impl Eq for Cursor
Source§impl Ord for Cursor
impl Ord for Cursor
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Cursor
impl PartialOrd for Cursor
impl StructuralPartialEq for Cursor
Auto Trait Implementations§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnsafeUnpin for Cursor
impl UnwindSafe for Cursor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<K> MapSeekTarget<K> for Kwhere
K: Ord,
impl<K> MapSeekTarget<K> for Kwhere
K: Ord,
fn cmp_cursor(&self, cursor_location: &K) -> Ordering
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().