add swapping keys
This commit is contained in:
parent
b7fc6bc1a7
commit
b04423d18d
|
|
@ -12,6 +12,8 @@ A MPD client in Rust
|
||||||
- `D` to get dmenu prompt
|
- `D` to get dmenu prompt
|
||||||
- `j` OR `Down` to scroll down
|
- `j` OR `Down` to scroll down
|
||||||
- `k` OR `Up` to scroll up
|
- `k` OR `Up` to scroll up
|
||||||
|
- `J` to swap highlighted song with next one
|
||||||
|
- `K` to swap highlighted song with previous one
|
||||||
- `l` OR `Right` add song to playlist or go inside the directory
|
- `l` OR `Right` add song to playlist or go inside the directory
|
||||||
- `h` OR `Left` to go back to previous directory
|
- `h` OR `Left` to go back to previous directory
|
||||||
- `Tab` to cycle through tabs
|
- `Tab` to cycle through tabs
|
||||||
|
|
@ -41,3 +43,4 @@ A MPD client in Rust
|
||||||
- [x] metadata based tree view
|
- [x] metadata based tree view
|
||||||
- [x] view playlist
|
- [x] view playlist
|
||||||
- [x] change playlist name
|
- [x] change playlist name
|
||||||
|
- [ ] add lyrics fetcher
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,33 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
|
||||||
app.update_queue();
|
app.update_queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swap highlighted song with next one
|
||||||
|
KeyCode::Char('J') => {
|
||||||
|
let current: u32 = app.queue_list.index as u32;
|
||||||
|
let next: u32 = if (current + 1) as usize == app.queue_list.list.len() {
|
||||||
|
app.queue_list.index as u32
|
||||||
|
} else {
|
||||||
|
app.queue_list.index += 1;
|
||||||
|
(current + 1) as u32
|
||||||
|
};
|
||||||
|
app.conn.conn.swap(current, next)?;
|
||||||
|
app.update_queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap highlighted song with previous one
|
||||||
|
KeyCode::Char('K') => {
|
||||||
|
let current: u32 = app.queue_list.index as u32;
|
||||||
|
let prev: u32 = if current == 0 {
|
||||||
|
app.queue_list.index as u32
|
||||||
|
} else {
|
||||||
|
app.queue_list.index -= 1;
|
||||||
|
(current - 1) as u32
|
||||||
|
};
|
||||||
|
app.conn.conn.swap(current, prev)?;
|
||||||
|
app.update_queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update MPD database
|
// Update MPD database
|
||||||
KeyCode::Char('U') => {
|
KeyCode::Char('U') => {
|
||||||
app.conn.conn.rescan()?;
|
app.conn.conn.rescan()?;
|
||||||
|
|
|
||||||
Reference in New Issue