start option numeration from 0 instead of 1 (1 was really stupid idea)

This commit is contained in:
unK
2008-09-05 08:33:18 +02:00
parent 9c3bd9dfb7
commit 5e7e0931a6
5 changed files with 84 additions and 113 deletions

View File

@@ -74,7 +74,7 @@ void UpdateItemList(Menu<Item> *menu)
break;
}
}
menu->BoldOption(i+1, bold);
menu->BoldOption(i, bold);
bold = 0;
}
}
@@ -94,7 +94,7 @@ void UpdateSongList(Menu<Song> *menu)
break;
}
}
menu->BoldOption(i+1, bold);
menu->BoldOption(i, bold);
bold = 0;
}
menu->Refresh();
@@ -102,7 +102,7 @@ void UpdateSongList(Menu<Song> *menu)
void UpdateFoundList(const SongList &v, Menu<string> *menu)
{
int i = search_engine_static_option+1;
int i = search_engine_static_option;
bool bold = 0;
for (SongList::const_iterator it = v.begin(); it != v.end(); it++, i++)
{
@@ -120,18 +120,6 @@ void UpdateFoundList(const SongList &v, Menu<string> *menu)
menu->Refresh();
}
void DeleteSong(int id)
{
Mpd->QueueDeleteSong(id);
mPlaylist->DeleteOption(id+1);
}
void PlaylistDeleteSong(const string &path, int id)
{
Mpd->QueueDeleteFromPlaylist(path, id);
mPlaylistEditor->DeleteOption(id+1);
}
string DisplayKeys(int *key, int size)
{
bool backspace = 1;
@@ -973,7 +961,7 @@ void GetDirectory(string dir, string subdir)
case itDirectory:
{
if (it->name == subdir)
highlightme = mBrowser->Size()+1;
highlightme = mBrowser->Size();
mBrowser->AddOption(*it);
break;
}

View File

@@ -34,9 +34,6 @@ void UpdateItemList(Menu<Item> *);
void UpdateSongList(Menu<Song> *);
void UpdateFoundList(const SongList &, Menu<string> *);
void DeleteSong(int);
void PlaylistDeleteSong(const string &, int);
string DisplayKeys(int *, int = 2);
bool Keypressed(int, const int *);
bool SortSongsByTrack(Song *, Song *);

View File

@@ -86,10 +86,9 @@ class Menu : public Window
virtual void Highlighting(bool hl) { itsHighlightEnabled = hl; NeedsRedraw.push_back(itsHighlight); Refresh(); }
int GetRealChoice() const;
virtual int GetChoice() const { return itsHighlight+1; }
virtual int GetChoice() const { return itsHighlight; }
virtual int Size() const { return itsOptions.size(); }
int MaxRealChoice() const { return itsOptions.size()-itsStaticsNumber; }
bool Empty() { return itsOptions.empty(); }
virtual bool IsStatic(int);
@@ -250,7 +249,6 @@ void Menu<T>::AddSeparator()
template <class T>
void Menu<T>::UpdateOption(int index, const T &item, Location location, bool separator)
{
index--;
try
{
itsOptions.at(index)->location = location;
@@ -266,7 +264,6 @@ void Menu<T>::UpdateOption(int index, const T &item, Location location, bool sep
template <class T>
void Menu<T>::BoldOption(int index, bool bold)
{
index--;
try
{
itsOptions.at(index)->is_bold = bold;
@@ -280,7 +277,6 @@ void Menu<T>::BoldOption(int index, bool bold)
template <class T>
void Menu<T>::MakeStatic(int index, bool stat)
{
index--;
try
{
if (stat && !itsOptions.at(index)->is_static)
@@ -312,7 +308,7 @@ string Menu<T>::GetOption(int i) const
{
try
{
return DisplayOption(itsOptions.at(i-1)->item);
return DisplayOption(itsOptions.at(i)->item);
}
catch (std::out_of_range)
{
@@ -323,7 +319,6 @@ string Menu<T>::GetOption(int i) const
template <class T>
void Menu<T>::DeleteOption(int no)
{
no--;
try
{
if (itsOptions.at(no)->is_static)
@@ -403,7 +398,7 @@ void Menu<T>::Refresh(bool redraw_whole_window)
itsBeginning = MaxBeginning;
if (itsHighlight >= itsOptions.size()-1)
Highlight(itsOptions.size());
Highlight(itsOptions.size()-1);
while (itsHighlight-itsBeginning > itsHeight-1)
itsBeginning++;
@@ -639,8 +634,6 @@ void Menu<T>::Go(Where where)
template <class T>
void Menu<T>::Highlight(int which)
{
which--;
int old_highlight = itsHighlight;
int old_beginning = itsBeginning;
@@ -704,7 +697,6 @@ void Menu<T>::Clear(bool clear_screen)
template <class T>
void Menu<T>::Select(int option, bool selected)
{
option--;
try
{
if (itsOptions.at(option)->selected != selected)
@@ -719,7 +711,6 @@ void Menu<T>::Select(int option, bool selected)
template <class T>
bool Menu<T>::Selected(int option)
{
option--;
try
{
return itsOptions.at(option)->selected;
@@ -748,7 +739,7 @@ bool Menu<T>::IsAnySelected()
template <class T>
void Menu<T>::GetSelectedList(vector<int> &v)
{
int i = 1;
int i = 0;
for (T_const_iterator it = itsOptions.begin(); it != itsOptions.end(); it++, i++)
if ((*it)->selected)
v.push_back(i);
@@ -762,7 +753,7 @@ int Menu<T>::GetRealChoice() const
for (int i = 0; i < itsHighlight; it++, i++)
if (!(*it)->is_static) real_choice++;
return real_choice+1;
return real_choice;
}
template <class T>
@@ -770,7 +761,7 @@ bool Menu<T>::IsStatic(int option)
{
try
{
return itsOptions.at(option-1)->is_static;
return itsOptions.at(option)->is_static;
}
catch (std::out_of_range)
{

View File

@@ -202,6 +202,8 @@ int main(int argc, char *argv[])
mTagEditor = new Menu<string>(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
mSearcher = static_cast<Menu<string> *>(mTagEditor->Clone());
mSearcher->SetSelectPrefix(Config.selected_item_prefix);
mSearcher->SetSelectSuffix(Config.selected_item_suffix);
int lib_artist_width = COLS/3-1;
int lib_albums_width = COLS/3;
@@ -789,14 +791,14 @@ int main(int argc, char *argv[])
case csPlaylist:
{
if (!mPlaylist->Empty())
Mpd->PlayID(mPlaylist->at(mPlaylist->GetChoice()-1).GetID());
Mpd->PlayID(mPlaylist->at(mPlaylist->GetChoice()).GetID());
break;
}
case csBrowser:
{
GO_TO_PARENT_DIR:
const Item &item = mBrowser->at(mBrowser->GetChoice()-1);
const Item &item = mBrowser->at(mBrowser->GetChoice());
switch (item.type)
{
case itDirectory:
@@ -842,7 +844,7 @@ int main(int argc, char *argv[])
case csTagEditor:
{
# ifdef HAVE_TAGLIB_H
int id = mTagEditor->GetRealChoice();
int id = mTagEditor->GetRealChoice()+1;
int option = mTagEditor->GetChoice();
LOCK_STATUSBAR;
Song &s = edited_song;
@@ -940,7 +942,7 @@ int main(int argc, char *argv[])
Mpd->UpdateDirectory(s.GetDirectory());
if (prev_screen == csSearcher)
{
*vSearched[mSearcher->GetRealChoice()-2] = s;
*vSearched[mSearcher->GetRealChoice()-1] = s;
mSearcher->UpdateOption(mSearcher->GetChoice(), DisplaySong(s));
}
}
@@ -974,12 +976,11 @@ int main(int argc, char *argv[])
{
ENTER_SEARCH_ENGINE_SCREEN:
int id = mSearcher->GetChoice();
int option = mSearcher->GetChoice();
LOCK_STATUSBAR;
Song &s = searched_song;
switch (id)
switch (option+1)
{
case 1:
{
@@ -1077,16 +1078,14 @@ int main(int argc, char *argv[])
{
ShowMessage("Searching...");
Search(vSearched, s);
ShowMessage("Searching finished!");
if (!vSearched.empty())
{
bool bold = 0;
mSearcher->AddSeparator();
mSearcher->AddStaticBoldOption("[.white]Search results:[/white] [.green]Found " + IntoStr(vSearched.size()) + (vSearched.size() > 1 ? " songs" : " song") + "[/green]");
mSearcher->AddSeparator();
for (SongList::const_iterator it = vSearched.begin(); it != vSearched.end(); it++)
{
{
for (int j = 0; j < mPlaylist->Size(); j++)
{
if (mPlaylist->at(j).GetHash() == (*it)->GetHash())
@@ -1098,8 +1097,8 @@ int main(int argc, char *argv[])
bold ? mSearcher->AddBoldOption(DisplaySong(**it)) : mSearcher->AddOption(DisplaySong(**it));
bold = 0;
}
for (int i = 1; i <=13; i++)
ShowMessage("Searching finished!");
for (int i = 0; i < 13; i++)
mSearcher->MakeStatic(i, 1);
mSearcher->Go(wDown);
mSearcher->Go(wDown);
@@ -1119,7 +1118,7 @@ int main(int argc, char *argv[])
}
default:
{
Song &s = *vSearched[mSearcher->GetRealChoice()-2];
Song &s = *vSearched[mSearcher->GetRealChoice()-1];
int id = Mpd->AddSong(s);
if (id >= 0)
{
@@ -1180,7 +1179,7 @@ int main(int argc, char *argv[])
{
if (!mLibSongs->Empty())
{
Song &s = mLibSongs->at(mLibSongs->GetChoice()-1);
Song &s = mLibSongs->at(mLibSongs->GetChoice());
int id = Mpd->AddSong(s);
if (id >= 0)
{
@@ -1230,7 +1229,7 @@ int main(int argc, char *argv[])
{
if (!mPlaylistEditor->Empty())
{
Song &s = mPlaylistEditor->at(mPlaylistEditor->GetChoice()-1);
Song &s = mPlaylistEditor->at(mPlaylistEditor->GetChoice());
int id = Mpd->AddSong(s);
if (id >= 0)
{
@@ -1264,12 +1263,12 @@ int main(int argc, char *argv[])
{
if (current_screen == csBrowser)
{
const Item &item = mBrowser->at(mBrowser->GetChoice()-1);
const Item &item = mBrowser->at(mBrowser->GetChoice());
switch (item.type)
{
case itDirectory:
{
if (browsed_dir != "/" && mBrowser->GetChoice() == 1)
if (browsed_dir != "/" && !mBrowser->GetChoice())
continue; // do not let add parent dir.
SongList list;
@@ -1315,7 +1314,7 @@ int main(int argc, char *argv[])
}
else if (current_screen == csSearcher && !vSearched.empty())
{
int id = mSearcher->GetChoice()-search_engine_static_option-1;
int id = mSearcher->GetChoice()-search_engine_static_option;
if (id < 0)
continue;
@@ -1409,7 +1408,10 @@ int main(int argc, char *argv[])
vector<int> list;
mPlaylist->GetSelectedList(list);
for (vector<int>::const_reverse_iterator it = list.rbegin(); it != list.rend(); it++)
DeleteSong(*it-1);
{
Mpd->QueueDeleteSong(*it);
mPlaylist->DeleteOption(*it);
}
ShowMessage("Selected items deleted!");
redraw_me = 1;
}
@@ -1422,7 +1424,8 @@ int main(int argc, char *argv[])
{
TraceMpdStatus();
timer = time(NULL);
DeleteSong(mPlaylist->GetChoice()-1);
Mpd->QueueDeleteSong(mPlaylist->GetChoice());
mPlaylist->DeleteOption(mPlaylist->GetChoice());
mPlaylist->Refresh();
mPlaylist->ReadKey(input);
}
@@ -1434,7 +1437,7 @@ int main(int argc, char *argv[])
else if (current_screen == csBrowser || wCurrent == mPlaylistList)
{
LOCK_STATUSBAR;
int id = wCurrent->GetChoice()-1;
int id = wCurrent->GetChoice();
const string &name = wCurrent == mBrowser ? mBrowser->at(id).name : mPlaylistList->at(id);
if (current_screen != csBrowser || mBrowser->at(id).type == itPlaylist)
{
@@ -1467,7 +1470,10 @@ int main(int argc, char *argv[])
vector<int> list;
mPlaylistEditor->GetSelectedList(list);
for (vector<int>::const_reverse_iterator it = list.rbegin(); it != list.rend(); it++)
PlaylistDeleteSong(mPlaylistList->GetCurrentOption(), *it-1);
{
Mpd->QueueDeleteFromPlaylist(mPlaylistList->GetCurrentOption(), *it);
mPlaylistEditor->DeleteOption(*it);
}
ShowMessage("Selected items deleted from playlist '" + mPlaylistList->GetCurrentOption() + "'!");
redraw_me = 1;
}
@@ -1478,7 +1484,8 @@ int main(int argc, char *argv[])
{
TraceMpdStatus();
timer = time(NULL);
PlaylistDeleteSong(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1);
Mpd->QueueDeleteFromPlaylist(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice());
mPlaylistEditor->DeleteOption(mPlaylistEditor->GetChoice());
mPlaylistEditor->Refresh();
mPlaylistEditor->ReadKey(input);
}
@@ -1563,11 +1570,8 @@ int main(int argc, char *argv[])
mPlaylist->GetSelectedList(list);
for (vector<int>::iterator it = list.begin(); it != list.end(); it++)
{
--*it;
if (*it == now_playing)
mPlaylist->BoldOption(now_playing+1, 0);
}
mPlaylist->BoldOption(now_playing, 0);
vector<int>origs(list);
@@ -1575,9 +1579,9 @@ int main(int argc, char *argv[])
{
TraceMpdStatus();
timer = time(NULL);
mPlaylist->Highlight(list[(list.size()-1)/2]);
for (vector<int>::iterator it = list.begin(); it != list.end(); it++)
mPlaylist->Swap(--*it, *it);
mPlaylist->Highlight(list[(list.size()-1)/2]);
mPlaylist->Refresh();
mPlaylist->ReadKey(input);
}
@@ -1588,7 +1592,7 @@ int main(int argc, char *argv[])
else
{
int from, to;
from = to = mPlaylist->GetChoice()-1;
from = to = mPlaylist->GetChoice();
while (Keypressed(input, Key.MvSongUp) && to > 0)
{
TraceMpdStatus();
@@ -1610,18 +1614,15 @@ int main(int argc, char *argv[])
vector<int> list;
mPlaylistEditor->GetSelectedList(list);
for (vector<int>::iterator it = list.begin(); it != list.end(); it++)
--*it;
vector<int>origs(list);
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{
TraceMpdStatus();
timer = time(NULL);
mPlaylistEditor->Highlight(list[(list.size()-1)/2]);
for (vector<int>::iterator it = list.begin(); it != list.end(); it++)
mPlaylistEditor->Swap(--*it, *it);
mPlaylistEditor->Highlight(list[(list.size()-1)/2]);
mPlaylistEditor->Refresh();
mPlaylistEditor->ReadKey(input);
}
@@ -1633,7 +1634,7 @@ int main(int argc, char *argv[])
else
{
int from, to;
from = to = mPlaylistEditor->GetChoice()-1;
from = to = mPlaylistEditor->GetChoice();
while (Keypressed(input, Key.MvSongUp) && to > 0)
{
TraceMpdStatus();
@@ -1661,11 +1662,8 @@ int main(int argc, char *argv[])
mPlaylist->GetSelectedList(list);
for (vector<int>::iterator it = list.begin(); it != list.end(); it++)
{
--*it;
if (*it == now_playing)
mPlaylist->BoldOption(now_playing+1, 0);
}
mPlaylist->BoldOption(now_playing, 0);
vector<int>origs(list);
@@ -1673,9 +1671,9 @@ int main(int argc, char *argv[])
{
TraceMpdStatus();
timer = time(NULL);
mPlaylist->Highlight(list[(list.size()-1)/2]+2);
for (vector<int>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
mPlaylist->Swap(++*it, *it);
mPlaylist->Highlight(list[(list.size()-1)/2]);
mPlaylist->Refresh();
mPlaylist->ReadKey(input);
}
@@ -1686,7 +1684,7 @@ int main(int argc, char *argv[])
else
{
int from, to;
from = to = mPlaylist->GetChoice()-1;
from = to = mPlaylist->GetChoice();
while (Keypressed(input, Key.MvSongDown) && to < mPlaylist->Size()-1)
{
TraceMpdStatus();
@@ -1709,18 +1707,15 @@ int main(int argc, char *argv[])
vector<int> list;
mPlaylistEditor->GetSelectedList(list);
for (vector<int>::iterator it = list.begin(); it != list.end(); it++)
--*it;
vector<int>origs(list);
while (Keypressed(input, Key.MvSongDown) && list.back() < mPlaylistEditor->Size()-1)
{
TraceMpdStatus();
timer = time(NULL);
mPlaylistEditor->Highlight(list[(list.size()-1)/2]+2);
for (vector<int>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
mPlaylistEditor->Swap(++*it, *it);
mPlaylistEditor->Highlight(list[(list.size()-1)/2]);
mPlaylistEditor->Refresh();
mPlaylistEditor->ReadKey(input);
}
@@ -1732,7 +1727,7 @@ int main(int argc, char *argv[])
else
{
int from, to;
from = to = mPlaylistEditor->GetChoice()-1;
from = to = mPlaylistEditor->GetChoice();
while (Keypressed(input, Key.MvSongDown) && to < mPlaylistEditor->Size()-1)
{
TraceMpdStatus();
@@ -1849,7 +1844,7 @@ int main(int argc, char *argv[])
else if (Keypressed(input, Key.GoToNowPlaying))
{
if (current_screen == csPlaylist && now_playing >= 0)
mPlaylist->Highlight(now_playing+1);
mPlaylist->Highlight(now_playing);
}
else if (Keypressed(input, Key.ToggleRepeat))
{
@@ -1888,12 +1883,12 @@ int main(int argc, char *argv[])
else if (Keypressed(input, Key.EditTags))
{
if ((wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mBrowser && mBrowser->at(mBrowser->GetChoice()-1).type == itSong)
|| (wCurrent == mBrowser && mBrowser->at(mBrowser->GetChoice()).type == itSong)
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
{
int id = wCurrent->GetChoice()-1;
int id = wCurrent->GetChoice();
Song *s;
switch (current_screen)
{
@@ -1933,7 +1928,7 @@ int main(int argc, char *argv[])
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
{
int id = wCurrent->GetChoice()-1;
int id = wCurrent->GetChoice();
Song *s;
switch (current_screen)
{
@@ -1941,7 +1936,7 @@ int main(int argc, char *argv[])
s = &mPlaylist->at(id);
break;
case csSearcher:
s = vSearched[mSearcher->GetRealChoice()-2];
s = vSearched[id-search_engine_static_option];
break;
case csLibrary:
s = &mLibSongs->at(id);
@@ -1958,7 +1953,7 @@ int main(int argc, char *argv[])
string option = DisplaySong(*s);
GetDirectory(s->GetDirectory());
for (int i = 1; i <= mBrowser->Size(); i++)
for (int i = 0; i < mBrowser->Size(); i++)
{
if (option == mBrowser->GetOption(i))
{
@@ -1973,7 +1968,7 @@ int main(int argc, char *argv[])
{
if (wCurrent == mSearcher)
{
mSearcher->Highlight(13); // highlight 'search' button
mSearcher->Highlight(12); // highlight 'search' button
goto ENTER_SEARCH_ENGINE_SCREEN;
}
}
@@ -1998,13 +1993,13 @@ int main(int argc, char *argv[])
{
if (wCurrent == mPlaylist || wCurrent == mBrowser || (wCurrent == mSearcher && !vSearched.empty()) || wCurrent == mLibSongs || wCurrent == mPlaylistEditor)
{
for (int i = 1; i <= wCurrent->Size(); i++)
for (int i = 0; i < wCurrent->Size(); i++)
wCurrent->Select(i, !wCurrent->Selected(i) && !wCurrent->IsStatic(i));
// hackish shit begins
if (wCurrent == mBrowser && browsed_dir != "/")
wCurrent->Select(1, 0); // [..] cannot be selected, uhm.
wCurrent->Select(0, 0); // [..] cannot be selected, uhm.
if (wCurrent == mSearcher)
wCurrent->Select(14, 0); // 'Reset' cannot be selected, omgplz.
wCurrent->Select(13, 0); // 'Reset' cannot be selected, omgplz.
// hacking shit ends. need better solution :/
ShowMessage("Selection reversed!");
}
@@ -2015,7 +2010,7 @@ int main(int argc, char *argv[])
{
if (wCurrent->IsAnySelected())
{
for (int i = 1; i <= wCurrent->Size(); i++)
for (int i = 0; i < wCurrent->Size(); i++)
wCurrent->Select(i, 0);
ShowMessage("Items deselected!");
}
@@ -2036,13 +2031,13 @@ int main(int argc, char *argv[])
{
case csPlaylist:
{
Song *s = new Song(mPlaylist->at(*it-1));
Song *s = new Song(mPlaylist->at(*it));
result.push_back(s);
break;
}
case csBrowser:
{
const Item &item = mBrowser->at(*it-1);
const Item &item = mBrowser->at(*it);
switch (item.type)
{
case itDirectory:
@@ -2069,19 +2064,19 @@ int main(int argc, char *argv[])
}
case csSearcher:
{
Song *s = new Song(*vSearched[*it-search_engine_static_option-1]);
Song *s = new Song(*vSearched[*it-search_engine_static_option]);
result.push_back(s);
break;
}
case csLibrary:
{
Song *s = new Song(mLibSongs->at(*it-1));
Song *s = new Song(mLibSongs->at(*it));
result.push_back(s);
break;
}
case csPlaylistEditor:
{
Song *s = new Song(mPlaylistEditor->at(*it-1));
Song *s = new Song(mPlaylistEditor->at(*it));
result.push_back(s);
break;
}
@@ -2140,7 +2135,7 @@ int main(int argc, char *argv[])
else
wCurrent->Refresh(1);
if (id == 1)
if (id == 0)
{
for (SongList::const_iterator it = result.begin(); it != result.end(); it++)
Mpd->QueueAddSong(**it);
@@ -2152,7 +2147,7 @@ int main(int argc, char *argv[])
ShowMessage(message_part_of_songs_added);
}
}
else if (id == 2)
else if (id == 1)
{
LOCK_STATUSBAR;
wFooter->WriteXY(0, Config.statusbar_visibility, "Save playlist as: ", 1);
@@ -2167,15 +2162,15 @@ int main(int argc, char *argv[])
}
}
else if (id > 2 && id < mDialog->Size())
else if (id > 1 && id < mDialog->Size()-1)
{
for (SongList::const_iterator it = result.begin(); it != result.end(); it++)
Mpd->QueueAddToPlaylist(playlists[id-4], **it);
Mpd->QueueAddToPlaylist(playlists[id-3], **it);
Mpd->CommitQueue();
ShowMessage("Selected items added to playlist '" + playlists[id-4] + "'!");
ShowMessage("Selected items added to playlist '" + playlists[id-3] + "'!");
}
if (id != mDialog->Size())
if (id != mDialog->Size()-1)
{
// refresh playlist's lists
if (browsed_dir == "/")
@@ -2195,12 +2190,12 @@ int main(int argc, char *argv[])
{
for (int i = 0; i < mPlaylist->Size(); i++)
{
if (!mPlaylist->Selected(i+1) && i != now_playing)
if (!mPlaylist->Selected(i) && i != now_playing)
Mpd->QueueDeleteSongId(mPlaylist->at(i).GetID());
}
// if mpd deletes now playing song deletion will be sluggishly slow
// then so we have to assure it will be deleted at the very end.
if (!mPlaylist->Selected(now_playing+1))
if (!mPlaylist->Selected(now_playing))
Mpd->QueueDeleteSongId(mPlaylist->at(now_playing).GetID());
ShowMessage("Deleting all items but selected...");
@@ -2247,7 +2242,7 @@ int main(int argc, char *argv[])
transform(findme.begin(), findme.end(), findme.begin(), tolower);
ShowMessage("Searching...");
for (int i = (wCurrent == mBrowser ? search_engine_static_option : 1); i <= wCurrent->Size(); i++)
for (int i = (wCurrent == mBrowser ? search_engine_static_option-1 : 0); i < wCurrent->Size(); i++)
{
string name = OmitBBCodes(wCurrent->GetOption(i));
transform(name.begin(), name.end(), name.begin(), tolower);
@@ -2338,13 +2333,13 @@ int main(int argc, char *argv[])
}
else if (
(wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mBrowser && mBrowser->at(mBrowser->GetChoice()-1).type == itSong)
|| (wCurrent == mBrowser && mBrowser->at(mBrowser->GetChoice()).type == itSong)
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
{
Song *s;
int id = wCurrent->GetChoice()-1;
int id = wCurrent->GetChoice();
switch (current_screen)
{
case csPlaylist:

View File

@@ -146,8 +146,8 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
{
old_playing = now_playing;
now_playing = Mpd->GetCurrentSongPos();
mPlaylist->BoldOption(old_playing+1, 0);
mPlaylist->BoldOption(now_playing+1, 1);
mPlaylist->BoldOption(old_playing, 0);
mPlaylist->BoldOption(now_playing, 1);
}
if (changed.Playlist)
@@ -193,7 +193,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
for (int i = 0; i < mPlaylist->Size(); i++)
{
if (*list[i] != mPlaylist->at(i))
mPlaylist->UpdateOption(i+1, *list[i]);
mPlaylist->UpdateOption(i, *list[i]);
}
}
FreeSongList(list);
@@ -244,7 +244,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
case psPlay:
{
player_state = "Playing: ";
mPlaylist->BoldOption(now_playing+1, 1);
mPlaylist->BoldOption(now_playing, 1);
changed.ElapsedTime = 1;
break;
}
@@ -259,7 +259,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
wFooter->SetColor(Config.progressbar_color);
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
wFooter->SetColor(Config.statusbar_color);
mPlaylist->BoldOption(old_playing+1, 0);
mPlaylist->BoldOption(old_playing, 0);
now_playing = -1;
player_state.clear();
break;
@@ -280,10 +280,10 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
Mpd->Play(now_playing);
}
if (old_playing >= 0)
mPlaylist->BoldOption(old_playing+1, 0);
mPlaylist->BoldOption(now_playing+1, 1);
mPlaylist->BoldOption(old_playing, 0);
mPlaylist->BoldOption(now_playing, 1);
if (Config.autocenter_mode)
mPlaylist->Highlight(now_playing+1);
mPlaylist->Highlight(now_playing);
repeat_one_allowed = 0;
}
if (!Mpd->GetElapsedTime())