Handle motions when a selection is present in text::Editor

This commit is contained in:
Héctor Ramón Jiménez 2023-09-14 14:18:49 +02:00
parent e6c2db8a93
commit b24b94d827
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 70 additions and 23 deletions

View file

@ -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`].