diff --git a/src/menu.h b/src/menu.h index 5925d9e1..ca5fe3dc 100644 --- a/src/menu.h +++ b/src/menu.h @@ -279,6 +279,12 @@ namespace NCurses /// bool isStatic(int pos = -1) const; + /// Checks whether given position is separator + /// @param pos position to be checked, -1 checks currently highlighted position + /// @return true if position is separator, false otherwise + /// + bool isSeparator(int pos = -1) const; + /// Selects/deselects given position /// @param pos position in list /// @param state state of selection @@ -956,6 +962,12 @@ template bool NCurses::Menu::isStatic(int pos) const return (*itsOptionsPtr)[pos]->isStatic; } +template bool NCurses::Menu::isSeparator(int pos) const +{ + pos = pos == -1 ? itsHighlight : pos; + return !itsOptionsPtr->at(pos); +} + template bool NCurses::Menu::hasSelected() const { for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->end(); ++it) diff --git a/src/search_engine.h b/src/search_engine.h index f006f233..43203403 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -38,7 +38,7 @@ class SearchEngine : public Screen< Menu< std::pair > > virtual bool isTabbable() { return true; } virtual MPD::Song *CurrentSong(); - virtual MPD::Song *GetSong(size_t pos) { return w->at(pos).second; } + virtual MPD::Song *GetSong(size_t pos) { return !w->isSeparator(pos) ? w->at(pos).second : 0; } virtual bool allowsSelection() { return w->Choice() >= StaticOptions; } virtual void ReverseSelection() { w->ReverseSelection(StaticOptions); }