diff --git a/doc/keys b/doc/keys index 9550e6f8..46b283a9 100644 --- a/doc/keys +++ b/doc/keys @@ -16,6 +16,14 @@ # #key_down = 258 'j' # +#key_up_album = '[' +# +#key_down_album = ']' +# +#key_up_artist = '{' +# +#key_down_artist = '}' +# #key_page_up = 339 # #key_page_down = 338 diff --git a/src/help.cpp b/src/help.cpp index 0539a769..d166bd2e 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -133,6 +133,10 @@ void Help::GetKeybindings() *w << " " << fmtBold << "Keys - Movement\n -----------------------------------------\n" << fmtBoldEnd; *w << DisplayKeys(Key.Up) << "Move Cursor up\n"; *w << DisplayKeys(Key.Down) << "Move Cursor down\n"; + *w << DisplayKeys(Key.UpAlbum) << "Move Cursor up one album\n"; + *w << DisplayKeys(Key.DownAlbum) << "Move Cursor down one album\n"; + *w << DisplayKeys(Key.UpArtist) << "Move Cursor up one artist\n"; + *w << DisplayKeys(Key.DownArtist) << "Move Cursor down one artist\n"; *w << DisplayKeys(Key.PageUp) << "Page up\n"; *w << DisplayKeys(Key.PageDown) << "Page down\n"; *w << DisplayKeys(Key.Home) << "Home\n"; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index b21e4914..7ff4b35a 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -439,6 +439,51 @@ int main(int argc, char *argv[]) { myScreen->Scroll(wDown, Key.Down); } + else if (Keypressed(input, Key.UpAlbum) || Keypressed(input, Key.DownAlbum) + || Keypressed(input, Key.UpArtist) || Keypressed(input, Key.DownArtist)) + { + Menu *songs = NULL; + if (myScreen == myPlaylist && !myPlaylist->Items->Empty()) + songs = myPlaylist->Items; + else if (myScreen->ActiveWindow() == myPlaylistEditor->Content) + songs = myPlaylistEditor->Content; + else if (myScreen == mySearcher) + mySearcher->Scroll(input); + + if (songs && !songs->Empty()) + { + size_t pos = songs->Choice(); + if (Keypressed(input, Key.UpAlbum)) + { + std::string album = songs->at(pos).GetAlbum(); + while (pos > 0) + if (songs->at(--pos).GetAlbum() != album) + break; + } + else if (Keypressed(input, Key.DownAlbum)) + { + std::string album = songs->at(pos).GetAlbum(); + while (pos < songs->Size() - 1) + if (songs->at(++pos).GetAlbum() != album) + break; + } + else if (Keypressed(input, Key.UpArtist)) + { + std::string artist = songs->at(pos).GetArtist(); + while (pos > 0) + if (songs->at(--pos).GetArtist() != artist) + break; + } + else if (Keypressed(input, Key.DownArtist)) + { + std::string artist = songs->at(pos).GetArtist(); + while (pos < songs->Size() - 1) + if (songs->at(++pos).GetArtist() != artist) + break; + } + songs->Highlight(pos); + } + } else if (Keypressed(input, Key.PageUp)) { myScreen->Scroll(wPageUp, Key.PageUp); diff --git a/src/search_engine.cpp b/src/search_engine.cpp index fadad454..a409cdbe 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -264,6 +264,90 @@ void SearchEngine::UpdateFoundList() } } +void SearchEngine::Scroll(int input) +{ + size_t pos = w->Choice(); + size_t oldpos = pos; + //w->Goto(pos); + //w->Goto(pos2); + //std::string album = w->at(pos).second->GetAlbum(); + //ShowMessage("pos (choice): %i / pos2 (realchoice): %i / album: %s", pos, pos2, album.c_str()); + //return; + + // above the reset button + if (pos < StaticOptions - 4) + { + if (Keypressed(input, Key.UpAlbum) || + Keypressed(input, Key.UpArtist)) + w->Highlight(0); + else if (Keypressed(input, Key.DownAlbum) || + Keypressed(input, Key.DownArtist)) + w->Highlight(StaticOptions - 4); // reset + return; + } + + // reset button + if (pos == StaticOptions - 4) + { + if (Keypressed(input, Key.UpAlbum) || + Keypressed(input, Key.UpArtist)) + w->Highlight(0); + else if (Keypressed(input, Key.DownAlbum) || + Keypressed(input, Key.DownArtist)) + w->Highlight(StaticOptions); // first search result + return; + } + + // first search result + if (pos == StaticOptions) + { + if (Keypressed(input, Key.UpAlbum)) + { + w->Highlight(StaticOptions - 4); // reset + return; + } + else if (Keypressed(input, Key.UpArtist)) + { + w->Highlight(0); + return; + } + } + + // we are in the search results at this point + if (pos >= StaticOptions) + { + if (Keypressed(input, Key.UpAlbum)) + { + std::string album = w->at(pos).second->GetAlbum(); + while (pos > StaticOptions) + if (w->at(--pos).second->GetAlbum() != album) + break; + } + else if (Keypressed(input, Key.DownAlbum)) + { + std::string album = w->at(pos).second->GetAlbum(); + while (pos < w->Size() - 1) + if (w->at(++pos).second->GetAlbum() != album) + break; + } + else if (Keypressed(input, Key.UpArtist)) + { + std::string artist = w->at(pos).second->GetArtist(); + while (pos > StaticOptions) + if (w->at(--pos).second->GetArtist() != artist) + break; + } + else if (Keypressed(input, Key.DownArtist)) + { + std::string artist = w->at(pos).second->GetArtist(); + while (pos < w->Size() - 1) + if (w->at(++pos).second->GetArtist() != artist) + break; + } + w->Highlight(pos); + } +} + 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 a40cf373..284b3e5a 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -48,6 +48,7 @@ class SearchEngine : public Screen< Menu< std::pair > > virtual List *GetList() { return w->Size() >= StaticOptions ? w : 0; } void UpdateFoundList(); + void Scroll(int); static size_t StaticOptions; static size_t SearchButton; diff --git a/src/settings.cpp b/src/settings.cpp index 9845b1fd..9a78613c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -150,6 +150,10 @@ void NcmpcppKeys::SetDefaults() { Up[0] = KEY_UP; Down[0] = KEY_DOWN; + UpAlbum[0] = '['; + DownAlbum[0] = ']'; + UpArtist[0] = '{'; + DownArtist[0] = '}'; PageUp[0] = KEY_PPAGE; PageDown[0] = KEY_NPAGE; Home[0] = KEY_HOME; @@ -224,6 +228,10 @@ void NcmpcppKeys::SetDefaults() Up[1] = 'k'; Down[1] = 'j'; + UpAlbum[1] = null_key; + DownAlbum[1] = null_key; + UpArtist[1] = null_key; + DownArtist[1] = null_key; PageUp[1] = null_key; PageDown[1] = null_key; Home[1] = null_key; @@ -418,6 +426,14 @@ void NcmpcppKeys::Read() GetKeys(key, Up); else if (key.find("key_down ") != std::string::npos) GetKeys(key, Down); + else if (key.find("key_up_album ") != std::string::npos) + GetKeys(key, UpAlbum); + else if (key.find("key_down_album ") != std::string::npos) + GetKeys(key, DownAlbum); + else if (key.find("key_up_artist ") != std::string::npos) + GetKeys(key, UpArtist); + else if (key.find("key_down_artist ") != std::string::npos) + GetKeys(key, DownArtist); else if (key.find("key_page_up ") != std::string::npos) GetKeys(key, PageUp); else if (key.find("key_page_down ") != std::string::npos) diff --git a/src/settings.h b/src/settings.h index ac5c96bd..491c298c 100644 --- a/src/settings.h +++ b/src/settings.h @@ -59,6 +59,10 @@ struct NcmpcppKeys int Up[2]; int Down[2]; + int UpAlbum[2]; + int DownAlbum[2]; + int UpArtist[2]; + int DownArtist[2]; int PageUp[2]; int PageDown[2]; int Home[2];