Skip to content

Commit

Permalink
Add next/prev page, jump to start/end to user config (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
Toaster192 authored Sep 30, 2020
1 parent 0e8f372 commit 0620803
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
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 @@ -145,6 +145,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 @@ -171,6 +175,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 @@ -233,6 +241,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 @@ -304,6 +316,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

0 comments on commit 0620803

Please sign in to comment.