Skip to content
Merged
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
Add next/prev page, jump to start/end to user config
  • Loading branch information
Toaster192 committed Sep 26, 2020
commit 5596f1d3253d2dc5260f94f38cd402738857d173
4 changes: 2 additions & 2 deletions src/handlers/album_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pub fn handler(key: Key, app: &mut App) {
};
}
}
Key::Ctrl('d') => app.get_current_user_saved_albums_next(),
Key::Ctrl('u') => app.get_current_user_saved_albums_previous(),
k if k == app.user_config.keys.next_page => app.get_current_user_saved_albums_next(),
k if k == app.user_config.keys.previous_page => app.get_current_user_saved_albums_previous(),
Key::Char('D') => app.current_user_saved_album_delete(ActiveBlock::AlbumList),
_ => {}
};
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ pub fn handler(key: Key, app: &mut App) {
app.home_scroll -= SMALL_SCROLL;
}
}
Key::Ctrl('d') => {
k if k == app.user_config.keys.next_page => {
app.home_scroll += LARGE_SCROLL;
}
Key::Ctrl('u') => {
k if k == app.user_config.keys.previous_page => {
if app.home_scroll > LARGE_SCROLL {
app.home_scroll -= LARGE_SCROLL;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/track_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn handler(key: Key, app: &mut App) {
on_enter(app);
}
// Scroll down
Key::Ctrl('d') => {
k if k == app.user_config.keys.next_page => {
match &app.track_table.context {
Some(context) => match context {
TrackTableContext::MyPlaylists => {
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn handler(key: Key, app: &mut App) {
};
}
// Scroll up
Key::Ctrl('u') => {
k if k == app.user_config.keys.previous_page => {
match &app.track_table.context {
Some(context) => match context {
TrackTableContext::MyPlaylists => {
Expand Down Expand Up @@ -143,8 +143,8 @@ pub fn handler(key: Key, app: &mut App) {
}
Key::Char('s') => handle_save_track_event(app),
Key::Char('S') => play_random_song(app),
Key::Ctrl('e') => jump_to_end(app),
Key::Ctrl('a') => jump_to_start(app),
k if k == app.user_config.keys.jump_to_end => jump_to_end(app),
k if k == app.user_config.keys.jump_to_start => jump_to_start(app),
//recommended song radio
Key::Char('r') => {
handle_recommended_tracks(app);
Expand Down
16 changes: 16 additions & 0 deletions src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ pub struct UserConfigPaths {
#[derive(Default, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct KeyBindingsString {
back: Option<String>,
next_page: Option<String>,
previous_page: Option<String>,
jump_to_start: Option<String>,
jump_to_end: Option<String>,
jump_to_album: Option<String>,
jump_to_artist_album: Option<String>,
jump_to_context: Option<String>,
Expand All @@ -167,6 +171,10 @@ pub struct KeyBindingsString {
#[derive(Clone)]
pub struct KeyBindings {
pub back: Key,
pub next_page: Key,
pub previous_page: Key,
pub jump_to_start: Key,
pub jump_to_end: Key,
pub jump_to_album: Key,
pub jump_to_artist_album: Key,
pub jump_to_context: Key,
Expand Down Expand Up @@ -226,6 +234,10 @@ impl UserConfig {
theme: Default::default(),
keys: KeyBindings {
back: Key::Char('q'),
next_page: Key::Ctrl('d'),
previous_page: Key::Ctrl('u'),
jump_to_start: Key::Ctrl('a'),
jump_to_end: Key::Ctrl('e'),
jump_to_album: Key::Char('a'),
jump_to_artist_album: Key::Char('A'),
jump_to_context: Key::Char('o'),
Expand Down Expand Up @@ -295,6 +307,10 @@ impl UserConfig {
};

to_keys!(back);
to_keys!(next_page);
to_keys!(previous_page);
to_keys!(jump_to_start);
to_keys!(jump_to_end);
to_keys!(jump_to_album);
to_keys!(jump_to_artist_album);
to_keys!(jump_to_context);
Expand Down