fix highlighting and change search mode a bit
This commit is contained in:
@@ -81,6 +81,8 @@
|
||||
#
|
||||
#key_prev_found_position = ','
|
||||
#
|
||||
#key_toggle_find_mode = 'w'
|
||||
#
|
||||
#key_edit_tags = 'e'
|
||||
#
|
||||
#key_go_to_position = 'g'
|
||||
|
||||
@@ -70,12 +70,14 @@
|
||||
#
|
||||
#browser_playlist_prefix = "[red]playlist[/red] "
|
||||
#
|
||||
##### interface settings #####
|
||||
##### various settings #####
|
||||
#
|
||||
#autocenter_mode = "no"
|
||||
#
|
||||
#repeat_one_mode = "no"
|
||||
#
|
||||
#find_mode = "wrapped"
|
||||
#
|
||||
#header_visibility = "yes"
|
||||
#
|
||||
#statusbar_visibility = "yes"
|
||||
|
||||
@@ -489,13 +489,11 @@ void Menu::Highlight(int which)
|
||||
else
|
||||
return;
|
||||
|
||||
if (which >= itsHeight/2)
|
||||
if (which >= itsHeight/2 && itsOptions.size() > itsHeight)
|
||||
{
|
||||
itsBeginning = itsHighlight-itsHeight/2;
|
||||
if (itsBeginning > itsOptions.size()-itsHeight)
|
||||
itsBeginning = itsOptions.size()-itsHeight;
|
||||
if (itsBeginning < 0)
|
||||
itsBeginning = 0;
|
||||
}
|
||||
else
|
||||
itsBeginning = 0;
|
||||
|
||||
@@ -244,6 +244,7 @@ int main(int argc, char *argv[])
|
||||
sHelp->Add(DisplayKeys(Key.FindBackward) + "Backward find\n");
|
||||
sHelp->Add(DisplayKeys(Key.PrevFoundPosition) + "Go to previous found position\n");
|
||||
sHelp->Add(DisplayKeys(Key.NextFoundPosition) + "Go to next found position\n");
|
||||
sHelp->Add(DisplayKeys(Key.ToggleFindMode) + "Toggle find mode\n");
|
||||
sHelp->Add(DisplayKeys(Key.EditTags) + tag_screen_keydesc);
|
||||
sHelp->Add(DisplayKeys(Key.GoToPosition) + "Go to chosen position in current song\n");
|
||||
sHelp->Add(DisplayKeys(Key.Lyrics) + "Show/hide song's lyrics\n\n");
|
||||
@@ -1549,7 +1550,7 @@ int main(int argc, char *argv[])
|
||||
|| (current_screen == csSearcher && !vSearched.empty()))
|
||||
{
|
||||
string how = Keypressed(input, Key.FindForward) ? "forward" : "backward";
|
||||
found_pos = 0;
|
||||
found_pos = -1;
|
||||
vFoundPositions.clear();
|
||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||
LOCK_STATUSBAR;
|
||||
@@ -1561,32 +1562,31 @@ int main(int argc, char *argv[])
|
||||
continue;
|
||||
transform(findme.begin(), findme.end(), findme.begin(), tolower);
|
||||
|
||||
if (Keypressed(input, Key.FindForward)) // forward
|
||||
for (int i = 1; i <= mCurrent->MaxChoice(); i++)
|
||||
{
|
||||
for (int i = mCurrent->GetChoice(); i <= mCurrent->MaxChoice(); i++)
|
||||
string name = mCurrent->GetOption(i);
|
||||
transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
if (name.find(findme) != string::npos && !mCurrent->IsStatic(i))
|
||||
{
|
||||
string name = mCurrent->GetOption(i);
|
||||
transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
if (name.find(findme) != string::npos && !mCurrent->IsStatic(i))
|
||||
vFoundPositions.push_back(i);
|
||||
}
|
||||
}
|
||||
else // backward
|
||||
{
|
||||
for (int i = mCurrent->GetChoice(); i > 0; i--)
|
||||
{
|
||||
string name = mCurrent->GetOption(i);
|
||||
transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
if (name.find(findme) != string::npos && !mCurrent->IsStatic(i))
|
||||
vFoundPositions.push_back(i);
|
||||
vFoundPositions.push_back(i);
|
||||
if (Keypressed(input, Key.FindForward)) // forward
|
||||
{
|
||||
if (found_pos < 0 && i >= mCurrent->GetChoice())
|
||||
found_pos = vFoundPositions.size()-1;
|
||||
}
|
||||
else // backward
|
||||
{
|
||||
if (i <= mCurrent->GetChoice())
|
||||
found_pos = vFoundPositions.size()-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vFoundPositions.empty())
|
||||
if (Config.wrapped_search ? vFoundPositions.empty() : found_pos < 0)
|
||||
ShowMessage("Unable to find \"" + findme + "\"");
|
||||
else
|
||||
{
|
||||
mCurrent->Highlight(vFoundPositions.front());
|
||||
mCurrent->Highlight(vFoundPositions[found_pos < 0 ? 0 : found_pos]);
|
||||
mCurrent->Highlighting(1);
|
||||
}
|
||||
}
|
||||
@@ -1602,19 +1602,29 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
{
|
||||
if (Keypressed(input, Key.NextFoundPosition))
|
||||
if (Config.wrapped_search)
|
||||
{
|
||||
mCurrent->Highlight(vFoundPositions.front());
|
||||
found_pos = 0;
|
||||
if (Keypressed(input, Key.NextFoundPosition))
|
||||
{
|
||||
mCurrent->Highlight(vFoundPositions.front());
|
||||
found_pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrent->Highlight(vFoundPositions.back());
|
||||
found_pos = vFoundPositions.size()-1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrent->Highlight(vFoundPositions.back());
|
||||
found_pos = vFoundPositions.size()-1;
|
||||
}
|
||||
found_pos = Keypressed(input, Key.NextFoundPosition) ? vFoundPositions.size()-1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.ToggleFindMode))
|
||||
{
|
||||
Config.wrapped_search = !Config.wrapped_search;
|
||||
ShowMessage("Search mode: " + string(Config.wrapped_search ? "Wrapped" : "Normal"));
|
||||
}
|
||||
else if (Keypressed(input, Key.Lyrics))
|
||||
{
|
||||
if (wCurrent == sLyrics)
|
||||
|
||||
@@ -61,6 +61,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.FindBackward[0] = '?';
|
||||
keys.NextFoundPosition[0] = '.';
|
||||
keys.PrevFoundPosition[0] = ',';
|
||||
keys.ToggleFindMode[0] = 'w';
|
||||
keys.EditTags[0] = 'e';
|
||||
keys.GoToPosition[0] = 'g';
|
||||
keys.Lyrics[0] = 'l';
|
||||
@@ -109,6 +110,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.FindBackward[1] = null_key;
|
||||
keys.NextFoundPosition[1] = null_key;
|
||||
keys.PrevFoundPosition[1] = null_key;
|
||||
keys.ToggleFindMode[1] = null_key;
|
||||
keys.EditTags[1] = null_key;
|
||||
keys.GoToPosition[1] = null_key;
|
||||
keys.Lyrics[1] = null_key;
|
||||
@@ -147,6 +149,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.statusbar_visibility = true;
|
||||
conf.autocenter_mode = false;
|
||||
conf.repeat_one_mode = false;
|
||||
conf.wrapped_search = true;
|
||||
conf.set_window_title = true;
|
||||
conf.mpd_connection_timeout = 15;
|
||||
conf.crossfade_time = 5;
|
||||
@@ -330,6 +333,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
||||
GetKeys(*it, keys.NextFoundPosition);
|
||||
else if (it->find("key_prev_found_position ") != string::npos)
|
||||
GetKeys(*it, keys.PrevFoundPosition);
|
||||
else if (it->find("key_toggle_find_mode ") != string::npos)
|
||||
GetKeys(*it, keys.ToggleFindMode);
|
||||
else if (it->find("key_edit_tags ") != string::npos)
|
||||
GetKeys(*it, keys.EditTags);
|
||||
else if (it->find("key_go_to_position ") != string::npos)
|
||||
@@ -431,6 +436,9 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
if (it->find("repeat_one_mode") != string::npos)
|
||||
conf.repeat_one_mode = v == "yes";
|
||||
|
||||
if (it->find("find_mode") != string::npos)
|
||||
conf.wrapped_search = v == "wrapped";
|
||||
|
||||
if (it->find("enable_window_title") != string::npos)
|
||||
conf.set_window_title = v == "yes";
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ struct ncmpcpp_keys
|
||||
int FindBackward[2];
|
||||
int NextFoundPosition[2];
|
||||
int PrevFoundPosition[2];
|
||||
int ToggleFindMode[2];
|
||||
int EditTags[2];
|
||||
int GoToPosition[2];
|
||||
int Lyrics[2];
|
||||
@@ -104,6 +105,7 @@ struct ncmpcpp_config
|
||||
bool statusbar_visibility;
|
||||
bool autocenter_mode;
|
||||
bool repeat_one_mode;
|
||||
bool wrapped_search;
|
||||
|
||||
int mpd_connection_timeout;
|
||||
int crossfade_time;
|
||||
|
||||
Reference in New Issue
Block a user