summaryrefslogtreecommitdiffstats
path: root/core/src/text
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-14 14:18:49 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-14 14:18:49 +0200
commitb24b94d82778733ddae1b824d0d7690afcec3056 (patch)
tree727f2197fee64e377758cfa9e5d5b16b692b8858 /core/src/text
parente6c2db8a9312e3fe37f30f049d1fa497892f1a86 (diff)
downloadiced-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.rs23
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`].