aboutsummaryrefslogtreecommitdiff
path: root/src/event
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-05-02 14:44:03 +0530
committerkrolxon <krolyxon@tutanota.com>2024-05-02 14:44:03 +0530
commitb04423d18d25bf889001a20d7bc8853de4816754 (patch)
tree2de8ebe215b9dc617f9a45a3cfa195fe7c691daa /src/event
parentb7fc6bc1a70da169f80afdc790c1a8ccf853d319 (diff)
add swapping keys
Diffstat (limited to 'src/event')
-rwxr-xr-xsrc/event/handler.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/event/handler.rs b/src/event/handler.rs
index 8fd41c3..85334a9 100755
--- a/src/event/handler.rs
+++ b/src/event/handler.rs
@@ -175,6 +175,33 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
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
KeyCode::Char('U') => {
app.conn.conn.rescan()?;