improve searching a bit / fix going to previous found position

This commit is contained in:
Andrzej Rybczak
2009-03-08 17:45:28 +01:00
parent 2c30387a91
commit 6be91a8216
2 changed files with 9 additions and 10 deletions

View File

@@ -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());
}

View File

@@ -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);