pub enum CursorAffinity {
Downstream,
Upstream,
}Expand description
Disambiguates the two visual placements a single character position
can have at a soft-wrap boundary. A long paragraph that wraps across
lines K and K+1 has one character position N that sits at both the
END of line K and the START of line K+1; affinity picks which one
the caret renders at and which line Home/End-style navigation
considers “current”.
Affinity is a display concern: it makes no sense without a layout
engine and a wrap width. It is never persisted with the text model
(cf. Cocoa NSSelectionAffinity on NSTextView, not on
NSTextStorage; Chromium PositionWithAffinity at the editing
layer, not on Position; same in Qt and CodeMirror).
At positions that are NOT wrap boundaries — the interior of a line, the start of the first wrap-line, the end of the last wrap-line of a paragraph — affinity is a no-op and the rendering is identical.
Variants§
Downstream
Place the caret at the END of the previous wrap line. This is the visual “trailing” placement and the default for any position not produced by an upstream-side interaction.
Upstream
Place the caret at the START of the next wrap line.
Trait Implementations§
Source§impl Clone for CursorAffinity
impl Clone for CursorAffinity
Source§fn clone(&self) -> CursorAffinity
fn clone(&self) -> CursorAffinity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CursorAffinity
impl Debug for CursorAffinity
Source§impl Default for CursorAffinity
impl Default for CursorAffinity
Source§fn default() -> CursorAffinity
fn default() -> CursorAffinity
Source§impl PartialEq for CursorAffinity
impl PartialEq for CursorAffinity
Source§fn eq(&self, other: &CursorAffinity) -> bool
fn eq(&self, other: &CursorAffinity) -> bool
self and other values to be equal, and is used by ==.