From 5527d36971b33d51453e1b5c53891aa99d1f0cb5 Mon Sep 17 00:00:00 2001 From: Jwsxs Date: Sun, 21 Sep 2025 13:49:27 -0300 Subject: [PATCH 1/3] Changes to selected music for huge playlists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pressing Ctrl + down or up will now select the 10th next music, for fast interaction between huge playlists and your time 😅. --- spotify_player/src/command.rs | 8 +++++--- spotify_player/src/config/keymap.rs | 8 ++++++++ spotify_player/src/event/page.rs | 10 ++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/spotify_player/src/command.rs b/spotify_player/src/command.rs index 5dff4f4a..739f6194 100644 --- a/spotify_player/src/command.rs +++ b/spotify_player/src/command.rs @@ -32,7 +32,9 @@ pub enum Command { ClosePopup, SelectNextOrScrollDown, + SelectNextOrScrollDown10, SelectPreviousOrScrollUp, + SelectPreviousOrScrollUp10, PageSelectNextOrScrollDown, PageSelectPreviousOrScrollUp, SelectFirstOrScrollToTop, @@ -314,9 +316,9 @@ 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::SelectNextOrScrollDown10 => "select the 10th 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::SelectPreviousOrScrollUp10 => "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)" } diff --git a/spotify_player/src/config/keymap.rs b/spotify_player/src/config/keymap.rs index d7104db1..47f47327 100644 --- a/spotify_player/src/config/keymap.rs +++ b/spotify_player/src/config/keymap.rs @@ -236,6 +236,10 @@ impl Default for KeymapConfig { key_sequence: "down".into(), command: Command::SelectNextOrScrollDown, }, + Keymap { + key_sequence: "C-down".into(), + command: Command::SelectNextOrScrollDown10, + }, Keymap { key_sequence: "k".into(), command: Command::SelectPreviousOrScrollUp, @@ -248,6 +252,10 @@ impl Default for KeymapConfig { key_sequence: "up".into(), command: Command::SelectPreviousOrScrollUp, }, + Keymap { + key_sequence: "C-up".into(), + command: Command::SelectPreviousOrScrollUp10, + }, 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 dc3a40d3..288387de 100644 --- a/spotify_player/src/event/page.rs +++ b/spotify_player/src/event/page.rs @@ -521,11 +521,21 @@ pub fn handle_navigation_command( page.select(std::cmp::min(id + offset, len - 1)); true } + Command::SelectNextOrScrollDown10 => { + let offset = count.unwrap_or(10); + page.select(std::cmp::min(id + offset, len - 1)); + true + } Command::SelectPreviousOrScrollUp => { let offset = count.unwrap_or(1); page.select(id.saturating_sub(offset)); true } + Command::SelectPreviousOrScrollUp10 => { + let offset = count.unwrap_or(10); + page.select(id.saturating_sub(offset)); + true + } Command::PageSelectNextOrScrollDown => { let page_size = configs.app_config.page_size_in_rows; let offset = count.unwrap_or(1) * page_size; From f8899d1585d44a17445df3f95fa5abe5a82f8002 Mon Sep 17 00:00:00 2001 From: Jwsxs Date: Sun, 21 Sep 2025 14:45:09 -0300 Subject: [PATCH 2/3] Changes for fast navigation Intended for large playlists, pressing Ctrl+Up/Down will move 10 lines, and also loops correctly on last and first line --- spotify_player/src/command.rs | 20 +++++--------------- spotify_player/src/event/page.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/spotify_player/src/command.rs b/spotify_player/src/command.rs index 739f6194..cba101db 100644 --- a/spotify_player/src/command.rs +++ b/spotify_player/src/command.rs @@ -319,18 +319,10 @@ impl Command { Self::SelectNextOrScrollDown10 => "select the 10th 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::SelectPreviousOrScrollUp10 => "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::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", @@ -365,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/event/page.rs b/spotify_player/src/event/page.rs index 288387de..683f950d 100644 --- a/spotify_player/src/event/page.rs +++ b/spotify_player/src/event/page.rs @@ -518,22 +518,42 @@ 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::SelectNextOrScrollDown10 => { let offset = count.unwrap_or(10); - 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::SelectPreviousOrScrollUp10 => { let offset = count.unwrap_or(10); - 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 => { From aa95d1353ab9048feecbf8b7cd55a819e7240c80 Mon Sep 17 00:00:00 2001 From: Jwsxs Date: Sun, 21 Sep 2025 20:34:52 -0300 Subject: [PATCH 3/3] removed unnecessary commands removed the two commands added, now using `PageSelectPreviousOrScrollUp` and `PageSelectNextOrScrollDown` for fast navigation, looping only on single line movement in case it's used on something else --- spotify_player/src/command.rs | 4 ---- spotify_player/src/config/keymap.rs | 4 ++-- spotify_player/src/event/page.rs | 24 ++---------------------- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/spotify_player/src/command.rs b/spotify_player/src/command.rs index cba101db..471a1ac0 100644 --- a/spotify_player/src/command.rs +++ b/spotify_player/src/command.rs @@ -32,9 +32,7 @@ pub enum Command { ClosePopup, SelectNextOrScrollDown, - SelectNextOrScrollDown10, SelectPreviousOrScrollUp, - SelectPreviousOrScrollUp10, PageSelectNextOrScrollDown, PageSelectPreviousOrScrollUp, SelectFirstOrScrollToTop, @@ -316,9 +314,7 @@ 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::SelectNextOrScrollDown10 => "select the 10th 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::SelectPreviousOrScrollUp10 => "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", diff --git a/spotify_player/src/config/keymap.rs b/spotify_player/src/config/keymap.rs index 47f47327..61f5ad6c 100644 --- a/spotify_player/src/config/keymap.rs +++ b/spotify_player/src/config/keymap.rs @@ -238,7 +238,7 @@ impl Default for KeymapConfig { }, Keymap { key_sequence: "C-down".into(), - command: Command::SelectNextOrScrollDown10, + command: Command::PageSelectNextOrScrollDown, }, Keymap { key_sequence: "k".into(), @@ -254,7 +254,7 @@ impl Default for KeymapConfig { }, Keymap { key_sequence: "C-up".into(), - command: Command::SelectPreviousOrScrollUp10, + command: Command::PageSelectPreviousOrScrollUp, }, Keymap { key_sequence: "page_up".into(), diff --git a/spotify_player/src/event/page.rs b/spotify_player/src/event/page.rs index 683f950d..70657911 100644 --- a/spotify_player/src/event/page.rs +++ b/spotify_player/src/event/page.rs @@ -519,17 +519,7 @@ pub fn handle_navigation_command( Command::SelectNextOrScrollDown => { let offset = count.unwrap_or(1); let temp = id + offset; - if (temp > len - 1) { - page.select(0 + temp - len); - } else { - page.select(id + offset); - } - true - } - Command::SelectNextOrScrollDown10 => { - let offset = count.unwrap_or(10); - let temp = id + offset; - if (temp > len - 1) { + if temp > len - 1 { page.select(0 + temp - len); } else { page.select(id + offset); @@ -539,17 +529,7 @@ pub fn handle_navigation_command( Command::SelectPreviousOrScrollUp => { let offset = count.unwrap_or(1); 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::SelectPreviousOrScrollUp10 => { - let offset = count.unwrap_or(10); - let temp = id as isize - offset as isize; - if (temp < 0) { + if temp < 0 { page.select((len as isize + temp) as usize); } else { page.select(temp as usize);