diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 4705fe38..ffd62bef 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1703,6 +1703,8 @@ int main(int argc, char *argv[]) songs = myPlaylist->Items; else if (myScreen->ActiveWindow() == myPlaylistEditor->Content) songs = myPlaylistEditor->Content; + else if (myScreen == mySearcher) + mySearcher->SelectAlbum(); if (songs && !songs->Empty()) { diff --git a/src/search_engine.cpp b/src/search_engine.cpp index 47661428..ffa87195 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -337,6 +337,36 @@ void SearchEngine::Scroll(int input) } } +void SearchEngine::SelectAlbum() +{ + size_t pos = w->Choice(); + if (pos < StaticOptions) + return; // not on a song + + std::string album = w->at(pos).second->GetAlbum(); + + // select song under cursor + w->Select(pos, 1); + + // go up + while (pos > StaticOptions) + { + if (w->at(--pos).second->GetAlbum() != album) + break; + else + w->Select(pos, 1); + } + + // go down + while (pos < w->Size() - 1) + { + if (w->at(++pos).second->GetAlbum() != album) + break; + else + w->Select(pos, 1); + } +} + void SearchEngine::Prepare() { for (size_t i = 0; i < w->Size(); ++i) diff --git a/src/search_engine.h b/src/search_engine.h index 284b3e5a..b71ca842 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -49,6 +49,7 @@ class SearchEngine : public Screen< Menu< std::pair > > void UpdateFoundList(); void Scroll(int); + void SelectAlbum(); static size_t StaticOptions; static size_t SearchButton;