Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions spotify_player/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions spotify_player/src/config/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
14 changes: 12 additions & 2 deletions spotify_player/src/event/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down