[−][src]Struct xi_core_lib::selection::Selection
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]
&self,
delta: &RopeDelta,
after: bool,
drift: InsertDrift
) -> Selection
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.
fn get_annotations(
&self,
interval: Interval,
view: &View,
text: &Rope
) -> AnnotationSlice
[src]
&self,
interval: Interval,
view: &View,
text: &Rope
) -> AnnotationSlice
impl Default for Selection
[src]
impl From<SelRegion> for Selection
[src]
impl Clone for Selection
[src]
fn clone(&self) -> 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.
fn deref(&self) -> &[SelRegion]
[src]
impl Debug for Selection
[src]
impl Display for Selection
[src]
Auto Trait Implementations
impl Send for Selection
impl Unpin for Selection
impl Sync for Selection
impl UnwindSafe for Selection
impl RefUnwindSafe for Selection
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,