[][src]Struct kas::text::SelectionHelper

pub struct SelectionHelper { /* fields omitted */ }

Text-selection logic

This struct holds an "edit pos" and a "selection pos", which together form a range. There is no requirement on the order of these two positions. Each may be adjusted independently.

Implementations

impl SelectionHelper[src]

pub fn new(edit_pos: usize, sel_pos: usize) -> Self[src]

Construct from (edit, selection) positions

The anchor position is set to the selection position.

pub fn is_empty(&self) -> bool[src]

True if the edit pos equals the selection pos

pub fn set_empty(&mut self)[src]

Set the selection pos to the edit pos

pub fn set_pos(&mut self, pos: usize)[src]

Set both edit and selection positions to this value

pub fn edit_pos(&self) -> usize[src]

Get the edit pos

pub fn set_edit_pos(&mut self, pos: usize)[src]

Set the edit pos without adjusting the selection pos

pub fn sel_pos(&self) -> usize[src]

Get the selection pos

pub fn set_sel_pos(&mut self, pos: usize)[src]

Set the selection pos without adjusting the edit pos

pub fn range(&self) -> Range<usize>[src]

Construct a range from the edit pos and selection pos

The range is from the minimum of (edit pos, selection pos) to the maximum of the two.

pub fn set_anchor(&mut self)[src]

Set the anchor position from the selection position

pub fn expand<T: TextApi>(&mut self, text: &T, repeats: u32)[src]

Expand the selection from the range between edit pos and anchor pos

This moves both edit pos and sel pos. To obtain repeatable behaviour, first use SelectionHelper::set_anchor to set the anchor position, then before each time this method is called set the edit position.

If repeats <= 2, the selection is expanded by words, otherwise it is expanded by lines.

Trait Implementations

impl Clone for SelectionHelper[src]

impl Debug for SelectionHelper[src]

impl Default for SelectionHelper[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.