Handle motions when a selection is present in text::Editor
This commit is contained in:
parent
e6c2db8a93
commit
b24b94d827
2 changed files with 70 additions and 23 deletions
|
|
@ -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`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue