[−][src]Struct kas::text::SelectionHelper
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]
pub fn clone(&self) -> SelectionHelper
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SelectionHelper
[src]
impl Default for SelectionHelper
[src]
pub fn default() -> SelectionHelper
[src]
Auto Trait Implementations
impl RefUnwindSafe for SelectionHelper
impl Send for SelectionHelper
impl Sync for SelectionHelper
impl Unpin for SelectionHelper
impl UnwindSafe for SelectionHelper
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,