diff --git a/spotify_player/src/command.rs b/spotify_player/src/command.rs index f0426dd8..16aa5bc4 100644 --- a/spotify_player/src/command.rs +++ b/spotify_player/src/command.rs @@ -317,21 +317,11 @@ impl Command { #[cfg(feature = "streaming")] Self::RestartIntegratedClient => "restart the integrated client", Self::SelectNextOrScrollDown => "select the next item in a list/table or scroll down (supports vim-style count: 5j)", - Self::SelectPreviousOrScrollUp => { - "select the previous item in a list/table or scroll up (supports vim-style count: 10k)" - } - Self::PageSelectNextOrScrollDown => { - "select the next page item in a list/table or scroll a page down (supports vim-style count: 3C-f)" - } - Self::PageSelectPreviousOrScrollUp => { - "select the previous page item in a list/table or scroll a page up (supports vim-style count: 2C-b)" - } - Self::SelectFirstOrScrollToTop => { - "select the first item in a list/table or scroll to the top" - } - Self::SelectLastOrScrollToBottom => { - "select the last item in a list/table or scroll to the bottom" - } + Self::SelectPreviousOrScrollUp => "select the previous item in a list/table or scroll up (supports vim-style count: 10k)", + Self::PageSelectNextOrScrollDown => "select the next page item in a list/table or scroll a page down (supports vim-style count: 3C-f)", + Self::PageSelectPreviousOrScrollUp => "select the previous page item in a list/table or scroll a page up (supports vim-style count: 2C-b)", + Self::SelectFirstOrScrollToTop => "select the first item in a list/table or scroll to the top", + Self::SelectLastOrScrollToBottom => "select the last item in a list/table or scroll to the bottom", Self::ChooseSelected => "choose the selected item and act on it", Self::JumpToCurrentTrackInContext => "jump to the current track in the context", Self::RefreshPlayback => "manually refresh the current playback", @@ -367,9 +357,7 @@ impl Command { Self::SortTrackByAddedDate => "sort the track table (if any) by track's added date", Self::ReverseTrackOrder => "reverse the order of the track table (if any)", Self::SortLibraryAlphabetically => "sort the library alphabetically", - Self::SortLibraryByRecent => { - "sort the library (playlists and albums) by recently added items" - } + Self::SortLibraryByRecent => "sort the library (playlists and albums) by recently added items", Self::MovePlaylistItemUp => "move playlist item up one position", Self::MovePlaylistItemDown => "move playlist item down one position", Self::CreatePlaylist => "create a new playlist", diff --git a/spotify_player/src/config/keymap.rs b/spotify_player/src/config/keymap.rs index d023f3fc..8220fa04 100644 --- a/spotify_player/src/config/keymap.rs +++ b/spotify_player/src/config/keymap.rs @@ -244,6 +244,10 @@ impl Default for KeymapConfig { key_sequence: "down".into(), command: Command::SelectNextOrScrollDown, }, + Keymap { + key_sequence: "C-down".into(), + command: Command::PageSelectNextOrScrollDown, + }, Keymap { key_sequence: "k".into(), command: Command::SelectPreviousOrScrollUp, @@ -256,6 +260,10 @@ impl Default for KeymapConfig { key_sequence: "up".into(), command: Command::SelectPreviousOrScrollUp, }, + Keymap { + key_sequence: "C-up".into(), + command: Command::PageSelectPreviousOrScrollUp, + }, Keymap { key_sequence: "page_up".into(), command: Command::PageSelectPreviousOrScrollUp, diff --git a/spotify_player/src/event/page.rs b/spotify_player/src/event/page.rs index a7f38550..2baf3678 100644 --- a/spotify_player/src/event/page.rs +++ b/spotify_player/src/event/page.rs @@ -569,12 +569,22 @@ pub fn handle_navigation_command( match command { Command::SelectNextOrScrollDown => { let offset = count.unwrap_or(1); - page.select(std::cmp::min(id + offset, len - 1)); + let temp = id + offset; + if temp > len - 1 { + page.select(0 + temp - len); + } else { + page.select(id + offset); + } true } Command::SelectPreviousOrScrollUp => { let offset = count.unwrap_or(1); - page.select(id.saturating_sub(offset)); + let temp = id as isize - offset as isize; + if temp < 0 { + page.select((len as isize + temp) as usize); + } else { + page.select(temp as usize); + } true } Command::PageSelectNextOrScrollDown => {