use macro instead of calling clearing find history routines explicitly

This commit is contained in:
Andrzej Rybczak
2008-11-04 17:26:22 +01:00
parent e227d53296
commit e5e4734b0e

View File

@@ -67,6 +67,12 @@
} while (0) } while (0)
#endif // HAVE_TAGLIB_H #endif // HAVE_TAGLIB_H
#define CLEAR_FIND_HISTORY \
do { \
found_pos = 0; \
vFoundPositions.clear(); \
} while (0)
ncmpcpp_config Config; ncmpcpp_config Config;
ncmpcpp_keys Key; ncmpcpp_keys Key;
@@ -459,8 +465,7 @@ int main(int argc, char *argv[])
{ {
if (mLibArtists->Empty()) if (mLibArtists->Empty())
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
TagList list; TagList list;
mLibAlbums->Clear(0); mLibAlbums->Clear(0);
mLibSongs->Clear(0); mLibSongs->Clear(0);
@@ -616,8 +621,7 @@ int main(int argc, char *argv[])
{ {
if (mEditorLeftCol->Empty()) if (mEditorLeftCol->Empty())
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mEditorLeftCol->Window::Clear(); mEditorLeftCol->Window::Clear();
mEditorTags->Clear(); mEditorTags->Clear();
TagList list; TagList list;
@@ -955,8 +959,7 @@ int main(int argc, char *argv[])
{ {
case itDirectory: case itDirectory:
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
GetDirectory(item.name, browsed_dir); GetDirectory(item.name, browsed_dir);
redraw_header = 1; redraw_header = 1;
break; break;
@@ -1313,8 +1316,7 @@ int main(int argc, char *argv[])
} }
case 15: case 15:
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
PrepareSearchEngine(sought_pattern); PrepareSearchEngine(sought_pattern);
ShowMessage("Search state reset"); ShowMessage("Search state reset");
break; break;
@@ -1874,8 +1876,7 @@ int main(int argc, char *argv[])
{ {
if (current_screen == csLibrary && input == Key.VolumeUp[0]) if (current_screen == csLibrary && input == Key.VolumeUp[0])
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
if (wCurrent == mLibArtists) if (wCurrent == mLibArtists)
{ {
if (mLibSongs->Empty()) if (mLibSongs->Empty())
@@ -1897,8 +1898,7 @@ int main(int argc, char *argv[])
} }
else if (wCurrent == mPlaylistList && input == Key.VolumeUp[0]) else if (wCurrent == mPlaylistList && input == Key.VolumeUp[0])
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mPlaylistList->HighlightColor(Config.main_highlight_color); mPlaylistList->HighlightColor(Config.main_highlight_color);
wCurrent->Refresh(); wCurrent->Refresh();
wCurrent = mPlaylistEditor; wCurrent = mPlaylistEditor;
@@ -1907,8 +1907,7 @@ int main(int argc, char *argv[])
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
else if (current_screen == csTagEditor && input == Key.VolumeUp[0]) else if (current_screen == csTagEditor && input == Key.VolumeUp[0])
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
if (wCurrent == mEditorLeftCol) if (wCurrent == mEditorLeftCol)
{ {
mEditorLeftCol->HighlightColor(Config.main_highlight_color); mEditorLeftCol->HighlightColor(Config.main_highlight_color);
@@ -1932,8 +1931,7 @@ int main(int argc, char *argv[])
{ {
if (current_screen == csLibrary && input == Key.VolumeDown[0]) if (current_screen == csLibrary && input == Key.VolumeDown[0])
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
if (wCurrent == mLibSongs) if (wCurrent == mLibSongs)
{ {
mLibSongs->HighlightColor(Config.main_highlight_color); mLibSongs->HighlightColor(Config.main_highlight_color);
@@ -1953,8 +1951,7 @@ int main(int argc, char *argv[])
} }
else if (wCurrent == mPlaylistEditor && input == Key.VolumeDown[0]) else if (wCurrent == mPlaylistEditor && input == Key.VolumeDown[0])
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mPlaylistEditor->HighlightColor(Config.main_highlight_color); mPlaylistEditor->HighlightColor(Config.main_highlight_color);
wCurrent->Refresh(); wCurrent->Refresh();
wCurrent = mPlaylistList; wCurrent = mPlaylistList;
@@ -1963,8 +1960,7 @@ int main(int argc, char *argv[])
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
else if (current_screen == csTagEditor && input == Key.VolumeDown[0]) else if (current_screen == csTagEditor && input == Key.VolumeDown[0])
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
if (wCurrent == mEditorTags) if (wCurrent == mEditorTags)
{ {
mEditorTags->HighlightColor(Config.main_highlight_color); mEditorTags->HighlightColor(Config.main_highlight_color);
@@ -3395,8 +3391,7 @@ int main(int argc, char *argv[])
SWITCHER_PLAYLIST_REDIRECT: SWITCHER_PLAYLIST_REDIRECT:
if (current_screen != csPlaylist && current_screen != csTinyTagEditor) if (current_screen != csPlaylist && current_screen != csTinyTagEditor)
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
wCurrent = mPlaylist; wCurrent = mPlaylist;
wCurrent->Hide(); wCurrent->Hide();
current_screen = csPlaylist; current_screen = csPlaylist;
@@ -3409,8 +3404,7 @@ int main(int argc, char *argv[])
SWITCHER_BROWSER_REDIRECT: SWITCHER_BROWSER_REDIRECT:
if (current_screen != csBrowser && current_screen != csTinyTagEditor) if (current_screen != csBrowser && current_screen != csTinyTagEditor)
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mBrowser->Empty() ? GetDirectory(browsed_dir) : UpdateItemList(mBrowser); mBrowser->Empty() ? GetDirectory(browsed_dir) : UpdateItemList(mBrowser);
wCurrent = mBrowser; wCurrent = mBrowser;
wCurrent->Hide(); wCurrent->Hide();
@@ -3423,8 +3417,7 @@ int main(int argc, char *argv[])
{ {
if (current_screen != csSearcher && current_screen != csTinyTagEditor) if (current_screen != csSearcher && current_screen != csTinyTagEditor)
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
if (mSearcher->Empty()) if (mSearcher->Empty())
PrepareSearchEngine(sought_pattern); PrepareSearchEngine(sought_pattern);
wCurrent = mSearcher; wCurrent = mSearcher;
@@ -3443,8 +3436,7 @@ int main(int argc, char *argv[])
{ {
if (current_screen != csLibrary && current_screen != csTinyTagEditor) if (current_screen != csLibrary && current_screen != csTinyTagEditor)
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mLibArtists->HighlightColor(Config.active_column_color); mLibArtists->HighlightColor(Config.active_column_color);
mLibAlbums->HighlightColor(Config.main_highlight_color); mLibAlbums->HighlightColor(Config.main_highlight_color);
@@ -3466,8 +3458,7 @@ int main(int argc, char *argv[])
{ {
if (current_screen != csPlaylistEditor && current_screen != csTinyTagEditor) if (current_screen != csPlaylistEditor && current_screen != csTinyTagEditor)
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mPlaylistList->HighlightColor(Config.active_column_color); mPlaylistList->HighlightColor(Config.active_column_color);
mPlaylistEditor->HighlightColor(Config.main_highlight_color); mPlaylistEditor->HighlightColor(Config.main_highlight_color);
@@ -3489,8 +3480,7 @@ int main(int argc, char *argv[])
{ {
if (current_screen != csTagEditor && current_screen != csTinyTagEditor) if (current_screen != csTagEditor && current_screen != csTinyTagEditor)
{ {
found_pos = 0; CLEAR_FIND_HISTORY;
vFoundPositions.clear();
mEditorAlbums->HighlightColor(Config.active_column_color); mEditorAlbums->HighlightColor(Config.active_column_color);
mEditorDirs->HighlightColor(Config.active_column_color); mEditorDirs->HighlightColor(Config.active_column_color);