diff --git a/src/help.cpp b/src/help.cpp index 961e8cfc..77bb4819 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -197,7 +197,7 @@ void Help::GetKeybindings() *w << DisplayKeys(Key.Crop) << "Clear playlist but hold currently playing/selected items\n"; *w << DisplayKeys(Key.MvSongUp) << "Move item(s) up\n"; *w << DisplayKeys(Key.MvSongDown) << "Move item(s) down\n"; - *w << DisplayKeys(Key.MoveTo) << "Move item(s) to given position\n"; + *w << DisplayKeys(Key.MoveTo) << "Move selected item(s) to cursor position\n"; *w << DisplayKeys(Key.Add) << "Add url/file/directory to playlist\n"; *w << DisplayKeys(Key.SavePlaylist) << "Save playlist\n"; *w << DisplayKeys(Key.SortPlaylist) << "Sort playlist\n"; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 7338a778..bcc2cef2 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -835,57 +835,40 @@ int main(int argc, char *argv[]) ShowMessage("%s", MPD::Message::FunctionDisabledFilteringEnabled); continue; } - - LockStatusbar(); - Statusbar() << "Move item(s) to given position: "; - string strpos = wFooter->GetString(10); - UnlockStatusbar(); - - if (strpos.empty()) + if (!myPlaylist->Main()->hasSelected()) + { + ShowMessage("No selected items to move!"); continue; - - int pos = StrToInt(strpos); - - if (pos < 0) - continue; - + } Playlist::BlockUpdate = 1; - if (myPlaylist->Main()->hasSelected()) + size_t pos = myPlaylist->Main()->Choice(); + // if cursor is at the last item, break convention and move at the end of playlist + if (pos == myPlaylist->Main()->Size()-1) + pos++; + vector list; + myPlaylist->Main()->GetSelected(list); + if (pos >= list.front() && pos <= list.back()) + continue; + int diff = pos-list.front(); + if (diff > 0) { - vector list; - myPlaylist->Main()->GetSelected(list); - if (pos+list.back()-list.front() > myPlaylist->Main()->Size()) - pos = myPlaylist->Main()->Size()+list.front()-list.back()-1; - int diff = pos-list.front(); - if (diff > 0) + diff -= list.size(); + for (vector::reverse_iterator it = list.rbegin(); it != list.rend(); it++) { - for (vector::reverse_iterator it = list.rbegin(); it != list.rend(); it++) - { - Mpd->QueueMove(*it, *it+diff); - myPlaylist->Main()->Move(*it, *it+diff); - } - } - else if (diff < 0) - { - for (vector::const_iterator it = list.begin(); it != list.end(); it++) - { - Mpd->QueueMove(*it, *it+diff); - myPlaylist->Main()->Move(*it, *it+diff); - } - } - myPlaylist->Main()->Highlight(list.front()+diff); - Mpd->CommitQueue(); - } - else - { - int current_pos = myPlaylist->Main()->Choice(); - int diff = pos-current_pos; - if (diff) - { - Mpd->Move(current_pos, current_pos+diff); - myPlaylist->Main()->Highlight(current_pos+diff); + Mpd->QueueMove(*it, *it+diff); + myPlaylist->Main()->Move(*it, *it+diff); } } + else if (diff < 0) + { + for (vector::const_iterator it = list.begin(); it != list.end(); it++) + { + Mpd->QueueMove(*it, *it+diff); + myPlaylist->Main()->Move(*it, *it+diff); + } + } + myPlaylist->Main()->Highlight(list.front()+diff); + Mpd->CommitQueue(); myPlaylist->FixPositions(); } else if (Keypressed(input, Key.Add))