improve searching a bit / fix going to previous found position
This commit is contained in:
@@ -599,6 +599,7 @@ template <class T> size_t NCurses::Menu<T>::RealChoice() const
|
||||
template <class T> bool NCurses::Menu<T>::Search(const std::string &constraint, size_t beginning, bool case_sensitive)
|
||||
{
|
||||
itsFound.clear();
|
||||
itsSearchConstraint.clear();
|
||||
if (constraint.empty())
|
||||
return false;
|
||||
itsSearchConstraint = constraint;
|
||||
@@ -631,11 +632,7 @@ template <class T> void NCurses::Menu<T>::PrevFound(bool wrap)
|
||||
return;
|
||||
std::set<size_t>::iterator prev = itsFound.lower_bound(itsHighlight);
|
||||
if (prev != itsFound.begin())
|
||||
{
|
||||
if (*prev == size_t(itsHighlight))
|
||||
prev--;
|
||||
Highlight(*prev);
|
||||
}
|
||||
Highlight(*--prev);
|
||||
else if (wrap)
|
||||
Highlight(*itsFound.rbegin());
|
||||
}
|
||||
|
||||
@@ -1489,14 +1489,16 @@ int main(int argc, char *argv[])
|
||||
string findme = wFooter->GetString(mList->GetSearchConstraint());
|
||||
UnlockStatusbar();
|
||||
time(&Timer);
|
||||
|
||||
if (!findme.empty())
|
||||
ShowMessage("Searching...");
|
||||
|
||||
bool success = mList->Search(findme, myScreen == mySearcher ? SearchEngine::StaticOptions : 0);
|
||||
|
||||
if (findme.empty())
|
||||
continue;
|
||||
|
||||
ShowMessage("Searching...");
|
||||
if (mList->Search(findme, myScreen == mySearcher ? SearchEngine::StaticOptions : 0))
|
||||
ShowMessage("Searching finished!");
|
||||
else
|
||||
ShowMessage("Unable to find \"%s\"", findme.c_str());
|
||||
success ? ShowMessage("Searching finished!") : ShowMessage("Unable to find \"%s\"", findme.c_str());
|
||||
|
||||
if (Keypressed(input, Key.FindForward))
|
||||
mList->NextFound(Config.wrapped_search);
|
||||
|
||||
Reference in New Issue
Block a user