Skip to content

Commit

Permalink
Add next/prev page, jump to start/end to user config
Browse files Browse the repository at this point in the history
  • Loading branch information
Toaster192 committed Aug 31, 2020
1 parent f20a9ed commit bf96d13
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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.previous_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.next_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

0 comments on commit bf96d13

Please sign in to comment.