Krolyxon
Commit 5eafc18

rmptui5eafc18

keybind: goto top, bottom

Author
krolxon
Date
2024-04-28 16:27 +0530
Parent
b9d6169
Commit
5eafc1898bf41ce2e6d3a634724f9443546af614

+20 −2

3 files changed

  1. M README.md +3 −1
  2. M src/app.rs +0 −1
  3. M src/handler.rs +17 −0
M README.md View
@@ -20,7 +20,7 @@ A MPD client in Rust
2020 - `3` to go to playlists view
2121 - `Enter` to add song/playlist to current playlist
2222 - `a` to append the song to current playing queue
23−- `BackSpace` to delete the highlighted song from queue
23+- `Space`/`BackSpace` to delete the highlighted song from queue
2424 - `f` to go forwards
2525 - `b` to go backwards
2626 - `>` to play next song from queue
@@ -29,6 +29,8 @@ A MPD client in Rust
2929 - `r` to toggle repeat
3030 - `z` to toggle random
3131 - `/` to search
32+- `g` to go to top of list
33+- `G` to go to bottom of list
3234
3335 ### TODO
3436 - [x] fix performance issues
M src/app.rs View
@@ -160,7 +160,6 @@ impl App {
160160 browser.prev_path = browser.path.clone();
161161 browser.path = browser.prev_path.clone() + "/" + path;
162162 browser.update_directory(&mut self.conn)?;
163− // self.get_all_rsongs(conn)?;
164163 browser.prev_selected = browser.selected;
165164 browser.selected = 0;
166165 }
M src/handler.rs View
@@ -329,6 +329,23 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
329329 // Change playlist name
330330 KeyCode::Char('e') => if app.selected_tab == SelectedTab::Playlists {},
331331
332+ // go to top of list
333+ KeyCode::Char('g') => {
334+ match app.selected_tab {
335+ SelectedTab::Queue => app.queue_list.index = 0,
336+ SelectedTab::DirectoryBrowser => app.browser.selected = 0,
337+ SelectedTab::Playlists => app.pl_list.index = 0
338+ }
339+ }
340+
341+ // go to bottom of list
342+ KeyCode::Char('G') => {
343+ match app.selected_tab {
344+ SelectedTab::Queue => app.queue_list.index = app.queue_list.list.len() - 1,
345+ SelectedTab::DirectoryBrowser => app.browser.selected = app.browser.filetree.len() - 1,
346+ SelectedTab::Playlists => app.pl_list.index = app.pl_list.list.len() - 1
347+ }
348+ }
332349 _ => {}
333350 }
334351 }