diff options
author | 2023-09-14 14:18:49 +0200 | |
---|---|---|
committer | 2023-09-14 14:18:49 +0200 | |
commit | b24b94d82778733ddae1b824d0d7690afcec3056 (patch) | |
tree | 727f2197fee64e377758cfa9e5d5b16b692b8858 /core/src/text | |
parent | e6c2db8a9312e3fe37f30f049d1fa497892f1a86 (diff) | |
download | iced-b24b94d82778733ddae1b824d0d7690afcec3056.tar.gz iced-b24b94d82778733ddae1b824d0d7690afcec3056.tar.bz2 iced-b24b94d82778733ddae1b824d0d7690afcec3056.zip |
Handle motions when a selection is present in `text::Editor`
Diffstat (limited to 'core/src/text')
-rw-r--r-- | core/src/text/editor.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/src/text/editor.rs b/core/src/text/editor.rs index f87e18f3..3adfc61a 100644 --- a/core/src/text/editor.rs +++ b/core/src/text/editor.rs @@ -78,6 +78,29 @@ impl Motion { _ => self, } } + + pub fn direction(&self) -> Direction { + match self { + Self::Left + | Self::Up + | Self::WordLeft + | Self::Home + | Self::PageUp + | Self::DocumentStart => Direction::Left, + Self::Right + | Self::Down + | Self::WordRight + | Self::End + | Self::PageDown + | Self::DocumentEnd => Direction::Right, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Direction { + Left, + Right, } /// The cursor of an [`Editor`]. |