Skip to content

Commit 58bab83

Browse files
Toaster192lanej
authored andcommitted
Add next/prev page, jump to start/end to user config (Rigellute#566)
1 parent 32d8706 commit 58bab83

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

Diff for: src/handlers/album_list.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub fn handler(key: Key, app: &mut App) {
5151
};
5252
}
5353
}
54-
Key::Ctrl('d') => app.get_current_user_saved_albums_next(),
55-
Key::Ctrl('u') => app.get_current_user_saved_albums_previous(),
54+
k if k == app.user_config.keys.next_page => app.get_current_user_saved_albums_next(),
55+
k if k == app.user_config.keys.previous_page => app.get_current_user_saved_albums_previous(),
5656
Key::Char('D') => app.current_user_saved_album_delete(ActiveBlock::AlbumList),
5757
_ => {}
5858
};

Diff for: src/handlers/home.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ pub fn handler(key: Key, app: &mut App) {
1515
app.home_scroll -= SMALL_SCROLL;
1616
}
1717
}
18-
Key::Ctrl('d') => {
18+
k if k == app.user_config.keys.next_page => {
1919
app.home_scroll += LARGE_SCROLL;
2020
}
21-
Key::Ctrl('u') => {
21+
k if k == app.user_config.keys.previous_page => {
2222
if app.home_scroll > LARGE_SCROLL {
2323
app.home_scroll -= LARGE_SCROLL;
2424
} else {

Diff for: src/handlers/track_table.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn handler(key: Key, app: &mut App) {
4040
on_enter(app);
4141
}
4242
// Scroll down
43-
Key::Ctrl('d') => {
43+
k if k == app.user_config.keys.next_page => {
4444
match &app.track_table.context {
4545
Some(context) => match context {
4646
TrackTableContext::MyPlaylists => {
@@ -93,7 +93,7 @@ pub fn handler(key: Key, app: &mut App) {
9393
};
9494
}
9595
// Scroll up
96-
Key::Ctrl('u') => {
96+
k if k == app.user_config.keys.previous_page => {
9797
match &app.track_table.context {
9898
Some(context) => match context {
9999
TrackTableContext::MyPlaylists => {
@@ -143,8 +143,8 @@ pub fn handler(key: Key, app: &mut App) {
143143
}
144144
Key::Char('s') => handle_save_track_event(app),
145145
Key::Char('S') => play_random_song(app),
146-
Key::Ctrl('e') => jump_to_end(app),
147-
Key::Ctrl('a') => jump_to_start(app),
146+
k if k == app.user_config.keys.jump_to_end => jump_to_end(app),
147+
k if k == app.user_config.keys.jump_to_start => jump_to_start(app),
148148
//recommended song radio
149149
Key::Char('r') => {
150150
handle_recommended_tracks(app);

Diff for: src/user_config.rs

+16
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ pub struct UserConfigPaths {
145145
#[derive(Default, Clone, Debug, PartialEq, Serialize, Deserialize)]
146146
pub struct KeyBindingsString {
147147
back: Option<String>,
148+
next_page: Option<String>,
149+
previous_page: Option<String>,
150+
jump_to_start: Option<String>,
151+
jump_to_end: Option<String>,
148152
jump_to_album: Option<String>,
149153
jump_to_artist_album: Option<String>,
150154
jump_to_context: Option<String>,
@@ -171,6 +175,10 @@ pub struct KeyBindingsString {
171175
#[derive(Clone)]
172176
pub struct KeyBindings {
173177
pub back: Key,
178+
pub next_page: Key,
179+
pub previous_page: Key,
180+
pub jump_to_start: Key,
181+
pub jump_to_end: Key,
174182
pub jump_to_album: Key,
175183
pub jump_to_artist_album: Key,
176184
pub jump_to_context: Key,
@@ -233,6 +241,10 @@ impl UserConfig {
233241
theme: Default::default(),
234242
keys: KeyBindings {
235243
back: Key::Char('q'),
244+
next_page: Key::Ctrl('d'),
245+
previous_page: Key::Ctrl('u'),
246+
jump_to_start: Key::Ctrl('a'),
247+
jump_to_end: Key::Ctrl('e'),
236248
jump_to_album: Key::Char('a'),
237249
jump_to_artist_album: Key::Char('A'),
238250
jump_to_context: Key::Char('o'),
@@ -304,6 +316,10 @@ impl UserConfig {
304316
};
305317

306318
to_keys!(back);
319+
to_keys!(next_page);
320+
to_keys!(previous_page);
321+
to_keys!(jump_to_start);
322+
to_keys!(jump_to_end);
307323
to_keys!(jump_to_album);
308324
to_keys!(jump_to_artist_album);
309325
to_keys!(jump_to_context);

0 commit comments

Comments
 (0)