Code

screen_queue: move ranges with one single "move" command
authorMax Kellermann <max@duempel.org>
Sun, 18 Oct 2009 00:21:13 +0000 (02:21 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 18 Oct 2009 00:21:13 +0000 (02:21 +0200)
Instead of swapping every single song in the selected range, send one
single "move" command which moves the neighbor song to the other end
of the range.

NEWS
src/screen_queue.c

diff --git a/NEWS b/NEWS
index 7b12cbec5f0cd462cf66e0bc2d8beca5f0737c2f..4e7906d3acef0a5d26044e9cd978580f1950987d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ ncmpc 0.16 - not yet released
 * strfsong: support multiple values for a tag
 * screen_browser: different colors for directories and playlists
 * screen_browser: display song duration
+* screen_queue: move ranges with one single "move" command
 
 
 ncmpc 0.15 - 2009-09-24
index 7d915ebf9b242496175727962c2794f1503631f2..02978eab5fd291b890b770fc77ef19cc0059c5ef 100644 (file)
@@ -785,8 +785,8 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd)
                if (range.start == 0 || range.end <= range.start)
                        return false;
 
-               for (unsigned i = range.start; i < range.end; ++i)
-                       mpdclient_cmd_swap(c, i, i - 1);
+               if (!mpdclient_cmd_move(c, range.end - 1, range.start - 1))
+                       return true;
 
                lw->selected--;
                lw->range_base--;
@@ -799,8 +799,8 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd)
                if (range.end >= playlist_length(&c->playlist))
                        return false;
 
-               for (int i = range.end - 1; i >= (int)range.start; --i)
-                       mpdclient_cmd_swap(c, i, i + 1);
+               if (!mpdclient_cmd_move(c, range.start, range.end))
+                       return true;
 
                lw->selected++;
                lw->range_base++;