mirror of
https://github.com/msfjarvis/text-editor.git
synced 2024-06-03 04:18:57 +05:30
feat(editor): support PageUp
, PageDown
, Home
and End
This commit is contained in:
parent
aff2d24d33
commit
a7d8164200
|
@ -47,7 +47,14 @@ impl Editor {
|
|||
let pressed_key = Terminal::read_key()?;
|
||||
match pressed_key {
|
||||
Key::Ctrl('q') => self.should_quit = true,
|
||||
Key::Up | Key::Left | Key::Right | Key::Down => self.move_cursor(pressed_key),
|
||||
Key::Up
|
||||
| Key::Left
|
||||
| Key::Right
|
||||
| Key::Down
|
||||
| Key::PageUp
|
||||
| Key::PageDown
|
||||
| Key::Home
|
||||
| Key::End => self.move_cursor(pressed_key),
|
||||
_ => (),
|
||||
};
|
||||
Ok(())
|
||||
|
@ -108,6 +115,10 @@ impl Editor {
|
|||
x = x.saturating_add(1);
|
||||
}
|
||||
}
|
||||
Key::PageUp => y = 0,
|
||||
Key::PageDown => y = height,
|
||||
Key::Home => x = 0,
|
||||
Key::End => x = width,
|
||||
_ => (),
|
||||
}
|
||||
self.cursor_position = Position { x, y }
|
||||
|
|
Loading…
Reference in New Issue
Block a user