Code

can shuffle selected list
authorRomain Bignon <romain@peerfuse.org>
Tue, 10 Feb 2009 13:09:32 +0000 (14:09 +0100)
committerMax Kellermann <max@duempel.org>
Tue, 10 Feb 2009 14:21:12 +0000 (15:21 +0100)
src/screen_play.c

index 665a986c3080dece6d2715046cd676bccfb10035..eb26893c1e5ace2e61fe1d26f2af1280fa381f86 100644 (file)
@@ -598,6 +598,21 @@ play_cmd(mpdclient_t *c, command_t cmd)
                center_playing_item(c);
                playlist_repaint();
                return false;
+       case CMD_SHUFFLE:
+       {
+               unsigned i = lw->selected_start + 1;
+               unsigned last_selected = lw->selected;
+               if(!lw->visual_selection)
+                       /* No visual selection, shuffle all list. */
+                       break;
+               for(; i <= lw->selected_end; ++i)
+                       mpdclient_cmd_move(c, i, lw->selected_start + (rand() % ((i - lw->selected_start) + 1)));
+
+               lw->selected = last_selected;
+               screen_status_printf(_("Shuffled selection!"));
+
+               return true;
+       }
        case CMD_LIST_MOVE_UP:
                if(lw->selected_start == 0)
                        return false;