pub struct SelRegion {
pub start: usize,
pub end: usize,
pub horiz: Option<HorizPos>,
pub affinity: Affinity,
}
Expand description
A type representing a single contiguous region of a selection. We use the
term “caret” (sometimes also “cursor”, more loosely) to refer to a selection
region with an empty interior. A “non-caret region” is one with a non-empty
interior (i.e. start != end
).
Fields§
§start: usize
The inactive edge of a selection, as a byte offset. When equal to end, the selection range acts as a caret.
end: usize
The active edge of a selection, as a byte offset.
horiz: Option<HorizPos>
A saved horizontal position (used primarily for line up/down movement).
affinity: Affinity
The affinity of the cursor.
Implementations§
Source§impl SelRegion
impl SelRegion
Sourcepub fn with_horiz(self, horiz: Option<HorizPos>) -> Self
pub fn with_horiz(self, horiz: Option<HorizPos>) -> Self
Returns a region with the given horizontal position.
Sourcepub fn with_affinity(self, affinity: Affinity) -> Self
pub fn with_affinity(self, affinity: Affinity) -> Self
Returns a region with the given affinity.
Sourcepub fn min(self) -> usize
pub fn min(self) -> usize
Gets the earliest offset within the region, ie the minimum of both edges.
Sourcepub fn max(self) -> usize
pub fn max(self) -> usize
Gets the latest offset within the region, ie the maximum of both edges.
Sourcepub fn is_caret(self) -> bool
pub fn is_caret(self) -> bool
Determines whether the region is a caret (ie has an empty interior).
Sourcepub fn is_upstream(self) -> bool
pub fn is_upstream(self) -> bool
Determines whether the region’s affinity is upstream.