pub struct Cursors { /* private fields */ }Expand description
The editor’s cursor state — the single typed home for “where the caret(s) are”.
Phase 1 (today): holds exactly one primary Position. The
mutation surface (primary / set_primary / map_primary) is the same
shape a single bare Position had, so callers route through it without
behavioral change — but now there is ONE typed place that owns cursor
state instead of a loose Position field beside an unused multi-caret
Selection. That removes the dual-source-of-truth that would desync
the moment multi-cursor lands.
Phase 2 (later): the inner representation grows to
{ primary: Position, secondaries: Vec<Position> } (or wraps
Selection directly). Because every caller already goes through this
newtype’s surface, that growth is a localized change here — not a
fleet-wide rewrite of self.cursor.line reads.
Implementations§
Source§impl Cursors
impl Cursors
Sourcepub const fn primary(&self) -> Position
pub const fn primary(&self) -> Position
The primary caret position — the single read accessor every renderer and motion path uses.
Sourcepub const fn set_primary(&mut self, p: Position)
pub const fn set_primary(&mut self, p: Position)
Move the primary caret to p. The single write path — set_cursor
in the runtime routes here, keeping clamp + viewport-follow as the
only way the cursor changes.
Sourcepub fn map_primary(&mut self, f: impl FnOnce(Position) -> Position)
pub fn map_primary(&mut self, f: impl FnOnce(Position) -> Position)
Transform the primary caret in place.
Trait Implementations§
impl Copy for Cursors
Source§impl<'de> Deserialize<'de> for Cursors
impl<'de> Deserialize<'de> for Cursors
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Cursors
Source§impl JsonSchema for Cursors
impl JsonSchema for Cursors
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read more