feat(strider): add vim keys (#180)

* feat(strider): add vim keys

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2021-02-11 14:51:46 +01:00 committed by GitHub
parent a5b30c52e6
commit ed22071381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@ -41,20 +41,22 @@ impl ZellijTile for State {
fn handle_key(&mut self, key: Key) {
match key {
Key::Up => {
Key::Up | Key::Char('k') => {
*self.selected_mut() = self.selected().saturating_sub(1);
}
Key::Down => {
Key::Down | Key::Char('j') => {
let next = self.selected().saturating_add(1);
*self.selected_mut() = min(self.files.len() - 1, next);
}
Key::Right | Key::Char('\n') => match self.files[self.selected()].clone() {
FsEntry::Dir(p, _) => {
self.path = p;
refresh_directory(self);
Key::Right | Key::Char('\n') | Key::Char('l') => {
match self.files[self.selected()].clone() {
FsEntry::Dir(p, _) => {
self.path = p;
refresh_directory(self);
}
FsEntry::File(p, _) => open_file(&p),
}
FsEntry::File(p, _) => open_file(&p),
},
}
Key::Left => {
self.path.pop();
refresh_directory(self);