[][src]Struct xi_core_lib::selection::Selection

pub struct Selection { /* fields omitted */ }

A set of zero or more selection regions, representing a selection state.

Methods

impl Selection[src]

pub fn new() -> Selection[src]

Creates a new empty selection.

pub fn new_simple(region: SelRegion) -> Selection[src]

Creates a selection with a single region.

pub fn clear(&mut self)[src]

Clear the selection.

pub fn collapse(&mut self)[src]

Collapse all selections into a single caret.

pub fn search(&self, offset: usize) -> usize[src]

pub fn add_region(&mut self, region: SelRegion)[src]

Add a region to the selection. This method implements merging logic.

Two non-caret regions merge if their interiors intersect; merely touching at the edges does not cause a merge. A caret merges with a non-caret if it is in the interior or on either edge. Two carets merge if they are the same offset.

Performance note: should be O(1) if the new region strictly comes after all the others in the selection, otherwise O(n).

pub fn regions_in_range(&self, start: usize, end: usize) -> &[SelRegion][src]

Gets a slice of regions that intersect the given range. Regions that merely touch the range at the edges are also included, so it is the caller's responsibility to further trim them, in particular to only display one caret in the upstream/downstream cases.

Performance note: O(log n).

pub fn delete_range(&mut self, start: usize, end: usize, delete_adjacent: bool)[src]

Deletes all the regions that intersect or (if delete_adjacent = true) touch the given range.

pub fn add_range_distinct(&mut self, region: SelRegion) -> (usize, usize)[src]

Add a region to the selection. This method does not merge regions and does not allow ambiguous regions (regions that overlap).

On ambiguous regions, the region with the lower start position wins. That is, in such a case, the new region is either not added at all, because there is an ambiguous region with a lower start position, or existing regions that intersect with the new region but do not start before the new region, are deleted.

pub fn apply_delta(
    &self,
    delta: &RopeDelta,
    after: bool,
    drift: InsertDrift
) -> Selection
[src]

Computes a new selection based on applying a delta to the old selection.

When new text is inserted at a caret, the new caret can be either before or after the inserted text, depending on the after parameter.

Whether or not the preceding selections are restored depends on the keep_selections value (only set to true on transpose).

Trait Implementations

impl ToAnnotation for Selection[src]

Implementing the ToAnnotation trait allows to convert selections to annotations.

impl Default for Selection[src]

impl From<SelRegion> for Selection[src]

impl Clone for Selection[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Deref for Selection[src]

Implementing the Deref trait allows callers to easily test is_empty, iterate through all ranges, etc.

type Target = [SelRegion]

The resulting type after dereferencing.

impl Debug for Selection[src]

impl Display for Selection[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]