keybind: goto top, bottom

This commit is contained in:
krolxon 2024-04-28 16:27:03 +05:30
parent b9d6169852
commit 5eafc1898b
3 changed files with 20 additions and 2 deletions

View File

@ -20,7 +20,7 @@ A MPD client in Rust
- `3` to go to playlists view - `3` to go to playlists view
- `Enter` to add song/playlist to current playlist - `Enter` to add song/playlist to current playlist
- `a` to append the song to current playing queue - `a` to append the song to current playing queue
- `BackSpace` to delete the highlighted song from queue - `Space`/`BackSpace` to delete the highlighted song from queue
- `f` to go forwards - `f` to go forwards
- `b` to go backwards - `b` to go backwards
- `>` to play next song from queue - `>` to play next song from queue
@ -29,6 +29,8 @@ A MPD client in Rust
- `r` to toggle repeat - `r` to toggle repeat
- `z` to toggle random - `z` to toggle random
- `/` to search - `/` to search
- `g` to go to top of list
- `G` to go to bottom of list
### TODO ### TODO
- [x] fix performance issues - [x] fix performance issues

View File

@ -160,7 +160,6 @@ impl App {
browser.prev_path = browser.path.clone(); browser.prev_path = browser.path.clone();
browser.path = browser.prev_path.clone() + "/" + path; browser.path = browser.prev_path.clone() + "/" + path;
browser.update_directory(&mut self.conn)?; browser.update_directory(&mut self.conn)?;
// self.get_all_rsongs(conn)?;
browser.prev_selected = browser.selected; browser.prev_selected = browser.selected;
browser.selected = 0; browser.selected = 0;
} }

View File

@ -329,6 +329,23 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
// Change playlist name // Change playlist name
KeyCode::Char('e') => if app.selected_tab == SelectedTab::Playlists {}, KeyCode::Char('e') => if app.selected_tab == SelectedTab::Playlists {},
// go to top of list
KeyCode::Char('g') => {
match app.selected_tab {
SelectedTab::Queue => app.queue_list.index = 0,
SelectedTab::DirectoryBrowser => app.browser.selected = 0,
SelectedTab::Playlists => app.pl_list.index = 0
}
}
// go to bottom of list
KeyCode::Char('G') => {
match app.selected_tab {
SelectedTab::Queue => app.queue_list.index = app.queue_list.list.len() - 1,
SelectedTab::DirectoryBrowser => app.browser.selected = app.browser.filetree.len() - 1,
SelectedTab::Playlists => app.pl_list.index = app.pl_list.list.len() - 1
}
}
_ => {} _ => {}
} }
} }