fix for bug with colors, more clean-ups

This commit is contained in:
unK
2008-09-03 03:02:20 +02:00
parent 723de0687e
commit 3bdac53feb
8 changed files with 139 additions and 158 deletions

View File

@@ -46,7 +46,7 @@
## value with { }|{ } eg. {%a - %t}|{%f}
##
## text can also have different color than the main window has,
## eg. if you want length to have other color, write [color]%t[/color]
## eg. if you want length to have other color, write [.color]%t[/color]
##
## available colors:
##
@@ -60,7 +60,7 @@
## - white
##
#
#song_list_format = "{[green](%l)[/green] }{%a - }{%t}|{[white]%f[/white]}"
#song_list_format = "{[.green](%l)[/green] }{%a - }{%t}|{[.white]%f[/white]}"
#
#song_status_format = "{(%l) }{%a - }{%t}|{%f}"
#
@@ -68,9 +68,9 @@
#
#song_library_format = "{%n - }{%t}|{%f}"
#
#browser_playlist_prefix = "[red]playlist[/red] "
#browser_playlist_prefix = "[.red]playlist[/red] "
#
#selected_item_prefix = "[magenta]"
#selected_item_prefix = "[.magenta]"
#
#selected_item_suffix = "[/magenta]"
#

View File

@@ -48,55 +48,55 @@ ColorPair Window::into_color(const string &str)
}
else
{
if (str == "[a]")
if (str == "[.a]")
AltCharset(1);
else if (str == "[b]")
else if (str == "[.b]")
Bold(1);
else if (str == "[r]")
else if (str == "[.r]")
Reverse(1);
else if (str == "[red]")
else if (str == "[.red]")
{
colors.first = clRed;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[black]")
else if (str == "[.black]")
{
colors.first = clBlack;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[blue]")
else if (str == "[.blue]")
{
colors.first = clBlue;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[green]")
else if (str == "[.green]")
{
colors.first = clGreen;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[yellow]")
else if (str == "[.yellow]")
{
colors.first = clYellow;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[magenta]")
else if (str == "[.magenta]")
{
colors.first = clMagenta;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[cyan]")
else if (str == "[.cyan]")
{
colors.first = clCyan;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[white]")
else if (str == "[.white]")
{
colors.first = clWhite;
colors.second = itsBaseBgColor;
@@ -403,28 +403,28 @@ ColorPair Window::into_color(const string &str)
bool is_valid_color(const string &str)
{
return str == "[/]" ||
str == "[b]" ||
str == "[.b]" ||
str == "[/b]" ||
str == "[r]" ||
str == "[.r]" ||
str == "[/r]" ||
str == "[a]" ||
str == "[.a]" ||
str == "[/a]" ||
str == "[black]" ||
str == "[.black]" ||
str == "[/black]" ||
str == "[red]" ||
str == "[.red]" ||
str == "[/red]" ||
str == "[blue]" ||
str == "[.blue]" ||
str == "[/blue]" ||
str == "[green]" ||
str == "[.green]" ||
str == "[/green]" ||
str == "[yellow]" ||
str == "[.yellow]" ||
str == "[/yellow]" ||
str == "[magenta]" ||
str == "[.magenta]" ||
str == "[/magenta]" ||
str == "[cyan]" ||
str == "[.cyan]" ||
str == "[/cyan]" ||
str == "[white]" ||
str == "[.white]" ||
str == "[/white]";
/*str == "[black_red]"||

View File

@@ -44,7 +44,6 @@ extern int browsed_dir_scroll_begin;
extern time_t block_delay;
extern string browsed_dir;
extern string browsed_subdir;
extern bool messages_allowed;
extern bool block_progressbar_update;
@@ -320,7 +319,12 @@ string DisplayItem(const Item &item, void *)
switch (item.type)
{
case itDirectory:
return "[" + item.name + "]";
{
if (item.song)
return "[..]";
int slash = item.name.find_last_of("/");
return "[" + (slash != string::npos ? item.name.substr(slash+1) : item.name) + "]";
}
case itSong:
return DisplaySong(*item.song);
case itPlaylist:
@@ -594,17 +598,17 @@ void PrepareSearchEngine(Song &s)
s.Clear();
mSearcher->Clear();
mSearcher->Reset();
mSearcher->AddOption("[b]Filename:[/b] " + s.GetShortFilename());
mSearcher->AddOption("[b]Title:[/b] " + s.GetTitle());
mSearcher->AddOption("[b]Artist:[/b] " + s.GetArtist());
mSearcher->AddOption("[b]Album:[/b] " + s.GetAlbum());
mSearcher->AddOption("[b]Year:[/b] " + s.GetYear());
mSearcher->AddOption("[b]Track:[/b] " + s.GetTrack());
mSearcher->AddOption("[b]Genre:[/b] " + s.GetGenre());
mSearcher->AddOption("[b]Comment:[/b] " + s.GetComment());
mSearcher->AddOption("[.b]Filename:[/b] " + s.GetShortFilename());
mSearcher->AddOption("[.b]Title:[/b] " + s.GetTitle());
mSearcher->AddOption("[.b]Artist:[/b] " + s.GetArtist());
mSearcher->AddOption("[.b]Album:[/b] " + s.GetAlbum());
mSearcher->AddOption("[.b]Year:[/b] " + s.GetYear());
mSearcher->AddOption("[.b]Track:[/b] " + s.GetTrack());
mSearcher->AddOption("[.b]Genre:[/b] " + s.GetGenre());
mSearcher->AddOption("[.b]Comment:[/b] " + s.GetComment());
mSearcher->AddSeparator();
mSearcher->AddOption("[b]Search mode:[/b] " + (search_mode_match ? search_mode_one : search_mode_two));
mSearcher->AddOption("[b]Case sensitive:[/b] " + (string)(search_case_sensitive ? "Yes" : "No"));
mSearcher->AddOption("[.b]Search mode:[/b] " + (search_mode_match ? search_mode_one : search_mode_two));
mSearcher->AddOption("[.b]Case sensitive:[/b] " + (string)(search_case_sensitive ? "Yes" : "No"));
mSearcher->AddSeparator();
mSearcher->AddOption("Search");
mSearcher->AddOption("Reset");
@@ -765,37 +769,37 @@ bool GetSongInfo(Song &s)
mTagEditor->Clear();
mTagEditor->Reset();
mTagEditor->AddStaticOption("[b][white]Song name: [/white][green][/b]" + s.GetShortFilename() + "[/green]");
mTagEditor->AddStaticOption("[b][white]Location in DB: [/white][green][/b]" + s.GetDirectory() + "[/green]");
mTagEditor->AddStaticOption("[.b][.white]Song name: [/white][.green][/b]" + s.GetShortFilename() + "[/green]");
mTagEditor->AddStaticOption("[.b][.white]Location in DB: [/white][.green][/b]" + s.GetDirectory() + "[/green]");
mTagEditor->AddStaticOption("");
mTagEditor->AddStaticOption("[b][white]Length: [/white][green][/b]" + s.GetLength() + "[/green]");
mTagEditor->AddStaticOption("[.b][.white]Length: [/white][.green][/b]" + s.GetLength() + "[/green]");
# ifdef HAVE_TAGLIB_H
mTagEditor->AddStaticOption("[b][white]Bitrate: [/white][green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]");
mTagEditor->AddStaticOption("[b][white]Sample rate: [/white][green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]");
mTagEditor->AddStaticOption("[b][white]Channels: [/white][green][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]");
mTagEditor->AddStaticOption("[.b][.white]Bitrate: [/white][.green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]");
mTagEditor->AddStaticOption("[.b][.white]Sample rate: [/white][.green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]");
mTagEditor->AddStaticOption("[.b][.white]Channels: [/white][.green][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]");
# endif
mTagEditor->AddSeparator();
# ifdef HAVE_TAGLIB_H
mTagEditor->AddOption("[b]Title:[/b] " + s.GetTitle());
mTagEditor->AddOption("[b]Artist:[/b] " + s.GetArtist());
mTagEditor->AddOption("[b]Album:[/b] " + s.GetAlbum());
mTagEditor->AddOption("[b]Year:[/b] " + s.GetYear());
mTagEditor->AddOption("[b]Track:[/b] " + s.GetTrack());
mTagEditor->AddOption("[b]Genre:[/b] " + s.GetGenre());
mTagEditor->AddOption("[b]Comment:[/b] " + s.GetComment());
mTagEditor->AddOption("[.b]Title:[/b] " + s.GetTitle());
mTagEditor->AddOption("[.b]Artist:[/b] " + s.GetArtist());
mTagEditor->AddOption("[.b]Album:[/b] " + s.GetAlbum());
mTagEditor->AddOption("[.b]Year:[/b] " + s.GetYear());
mTagEditor->AddOption("[.b]Track:[/b] " + s.GetTrack());
mTagEditor->AddOption("[.b]Genre:[/b] " + s.GetGenre());
mTagEditor->AddOption("[.b]Comment:[/b] " + s.GetComment());
mTagEditor->AddSeparator();
mTagEditor->AddOption("Save");
mTagEditor->AddOption("Cancel");
# else
mTagEditor->AddStaticOption("[b]Title:[/b] " + s.GetTitle());
mTagEditor->AddStaticOption("[b]Artist:[/b] " + s.GetArtist());
mTagEditor->AddStaticOption("[b]Album:[/b] " + s.GetAlbum());
mTagEditor->AddStaticOption("[b]Year:[/b] " + s.GetYear());
mTagEditor->AddStaticOption("[b]Track:[/b] " + s.GetTrack());
mTagEditor->AddStaticOption("[b]Genre:[/b] " + s.GetGenre());
mTagEditor->AddStaticOption("[b]Comment:[/b] " + s.GetComment());
mTagEditor->AddStaticOption("[.b]Title:[/b] " + s.GetTitle());
mTagEditor->AddStaticOption("[.b]Artist:[/b] " + s.GetArtist());
mTagEditor->AddStaticOption("[.b]Album:[/b] " + s.GetAlbum());
mTagEditor->AddStaticOption("[.b]Year:[/b] " + s.GetYear());
mTagEditor->AddStaticOption("[.b]Track:[/b] " + s.GetTrack());
mTagEditor->AddStaticOption("[.b]Genre:[/b] " + s.GetGenre());
mTagEditor->AddStaticOption("[.b]Comment:[/b] " + s.GetComment());
mTagEditor->AddSeparator();
mTagEditor->AddOption("Back");
# endif
@@ -818,7 +822,7 @@ bool SortDirectory(const Item &a, const Item &b)
return a.type < b.type;
}
void GetDirectory(string dir)
void GetDirectory(string dir, string subdir)
{
int highlightme = -1;
browsed_dir_scroll_begin = 0;
@@ -826,10 +830,13 @@ void GetDirectory(string dir)
mBrowser->Reset();
browsed_dir = dir;
mBrowser->Clear(0);
if (dir != "/")
{
Item parent;
parent.name = "..";
int slash = dir.find_last_of("/");
parent.song = (Song *) 1; // in that way we assume that's really parent dir
parent.name = slash != string::npos ? dir.substr(0, slash) : "/";
parent.type = itDirectory;
mBrowser->AddOption(parent);
}
@@ -849,15 +856,8 @@ void GetDirectory(string dir)
}
case itDirectory:
{
string directory;
string subdir = it->name;
if (dir == "/")
directory = subdir.substr(browsed_dir.size()-1,subdir.size()-browsed_dir.size()+1);
else
directory = subdir.substr(browsed_dir.size()+1,subdir.size()-browsed_dir.size()-1);
if (directory == browsed_subdir)
if (it->name == subdir)
highlightme = mBrowser->Size()+1;
it->name = directory;
mBrowser->AddOption(*it);
break;
}
@@ -878,7 +878,6 @@ void GetDirectory(string dir)
}
}
mBrowser->Highlight(highlightme);
browsed_subdir.clear();
if (current_screen == csBrowser)
mBrowser->Hide();

View File

@@ -51,7 +51,7 @@ string DisplayItem(const Item &, void * = NULL);
string DisplaySong(const Song &, void * = &Config.song_list_format);
void ShowMessage(const string &, int = Config.message_delay_time);
bool SortDirectory(const Item &a, const Item &b);
void GetDirectory(string);
void GetDirectory(string, string = "/");
bool GetSongInfo(Song &);
void PrepareSearchEngine(Song &s);
void Search(SongList &, Song &);

View File

@@ -48,7 +48,7 @@ class Menu : public Window
typedef string (*ItemDisplayer) (const T &, void *);
public:
Menu(int startx, int starty, int width, int height, string title, Color color, Border border) : itsItemDisplayer(0), itsUserdata(0), Window(startx, starty, width, height, title, color, border), itsSelectedPrefix("[r]"), itsSelectedSuffix("[/r]"), itsStaticsNumber(0), itsBeginning(0), itsHighlight(0), itsHighlightColor(itsBaseColor), itsHighlightEnabled(1) { SetColor(color); }
Menu(int startx, int starty, int width, int height, string title, Color color, Border border) : itsItemDisplayer(0), itsUserdata(0), Window(startx, starty, width, height, title, color, border), itsSelectedPrefix("[.r]"), itsSelectedSuffix("[/r]"), itsStaticsNumber(0), itsBeginning(0), itsHighlight(0), itsHighlightColor(itsBaseColor), itsHighlightEnabled(1) { SetColor(color); }
Menu(const Menu &);
virtual ~Menu();

View File

@@ -102,7 +102,6 @@ int stats_scroll_begin = 0;
int block_statusbar_update_delay = -1;
string browsed_dir = "/";
string browsed_subdir;
string song_lyrics;
string player_state;
string volume_state;
@@ -228,7 +227,7 @@ int main(int argc, char *argv[])
sHelp = new Scrollpad(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
sLyrics = static_cast<Scrollpad *>(sHelp->EmptyClone());
sHelp->Add(" [b]Keys - Movement\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Movement\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Up) + "Move Cursor up\n");
sHelp->Add(DisplayKeys(Key.Down) + "Move Cursor down\n");
sHelp->Add(DisplayKeys(Key.PageUp) + "Page up\n");
@@ -244,7 +243,7 @@ int main(int argc, char *argv[])
sHelp->Add(DisplayKeys(Key.MediaLibrary) + "Media library\n");
sHelp->Add(DisplayKeys(Key.PlaylistEditor) + "Playlist editor\n\n\n");
sHelp->Add(" [b]Keys - Global\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Global\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Stop) + "Stop\n");
sHelp->Add(DisplayKeys(Key.Pause) + "Pause\n");
sHelp->Add(DisplayKeys(Key.Next) + "Next track\n");
@@ -278,7 +277,7 @@ int main(int argc, char *argv[])
sHelp->Add(DisplayKeys(Key.Quit) + "Quit\n\n\n");
sHelp->Add(" [b]Keys - Playlist screen\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Playlist screen\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Play\n");
sHelp->Add(DisplayKeys(Key.Delete) + "Delete item/selected items from playlist\n");
sHelp->Add(DisplayKeys(Key.Clear) + "Clear playlist\n");
@@ -290,25 +289,25 @@ int main(int argc, char *argv[])
sHelp->Add(DisplayKeys(Key.GoToNowPlaying) + "Go to currently playing position\n");
sHelp->Add(DisplayKeys(Key.ToggleAutoCenter) + "Toggle auto center mode\n\n\n");
sHelp->Add(" [b]Keys - Browse screen\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Browse screen\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Enter directory/Add item to playlist and play\n");
sHelp->Add(DisplayKeys(Key.Space) + "Add item to playlist\n");
sHelp->Add(DisplayKeys(Key.GoToParentDir) + "Go to parent directory\n");
sHelp->Add(DisplayKeys(Key.Delete) + "Delete playlist\n\n\n");
sHelp->Add(" [b]Keys - Search engine\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Search engine\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Add item to playlist and play/change option\n");
sHelp->Add(DisplayKeys(Key.Space) + "Add item to playlist\n");
sHelp->Add(DisplayKeys(Key.StartSearching) + "Start searching immediately\n");
sHelp->Add(DisplayKeys(Key.GoToContainingDir) + "Go to directory containing found item\n\n\n");
sHelp->Add(" [b]Keys - Media library\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Media library\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n");
sHelp->Add(DisplayKeys(&Key.VolumeUp[0], 1) + "Next column\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Add to playlist and play song/album/artist's songs\n");
sHelp->Add(DisplayKeys(Key.Space) + "Add to playlist song/album/artist's songs\n\n\n");
sHelp->Add(" [b]Keys - Playlist Editor\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Playlist Editor\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n");
sHelp->Add(DisplayKeys(&Key.VolumeUp[0], 1) + "Next column\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Add item to playlist and play\n");
@@ -317,10 +316,10 @@ int main(int argc, char *argv[])
sHelp->Add(DisplayKeys(Key.MvSongDown) + "Move item/group of items down\n\n\n");
# ifdef HAVE_TAGLIB_H
sHelp->Add(" [b]Keys - Tag editor\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Tag editor\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Change option\n");
# else
sHelp->Add(" [b]Keys - Tag info\n -----------------------------------------[/b]\n");
sHelp->Add(" [.b]Keys - Tag info\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Return\n");
# endif
@@ -455,7 +454,7 @@ int main(int argc, char *argv[])
}
}
else
wHeader->WriteXY(0, 0, max_allowed_title_length, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search [b]5:[/b]Library [b]6:[/b]Playlist editor", 1);
wHeader->WriteXY(0, 0, max_allowed_title_length, "[.b]1:[/b]Help [.b]2:[/b]Playlist [.b]3:[/b]Browse [.b]4:[/b]Search [.b]5:[/b]Library [.b]6:[/b]Playlist editor", 1);
wHeader->SetColor(Config.volume_color);
wHeader->WriteXY(max_allowed_title_length, 0, volume_state);
@@ -538,10 +537,11 @@ int main(int argc, char *argv[])
Mpd->CommitSearch(list);
if (list.empty())
{
const int year_length = 7;
const string &album = mLibAlbums->GetCurrentOption();
Mpd->StartSearch(1);
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetCurrentOption());
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, album.substr(7, album.length()-7));
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, album.substr(year_length));
Mpd->CommitSearch(list);
}
}
@@ -589,6 +589,10 @@ int main(int argc, char *argv[])
mPlaylistEditor->Reset();
SongList list;
Mpd->GetPlaylistContent(mPlaylistList->GetCurrentOption(), list);
if (!list.empty())
mPlaylistEditor->SetTitle("Playlist's content (" + IntoStr(list.size()) + " item" + (list.size() == 1 ? ")" : "s)"));
else
mPlaylistEditor->SetTitle("Playlist's content");
bool bold = 0;
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
{
@@ -605,7 +609,7 @@ int main(int argc, char *argv[])
}
FreeSongList(list);
mPlaylistEditor->Window::Clear();
mPlaylistEditor->Refresh();
mPlaylistEditor->Display();
}
if (wCurrent == mPlaylistEditor && mPlaylistEditor->Empty())
@@ -798,29 +802,7 @@ int main(int argc, char *argv[])
{
found_pos = 0;
vFoundPositions.clear();
if (item.name == "..")
{
int i = browsed_dir.size();
while (browsed_dir[--i] != '/');
string tmp = browsed_dir.substr(0, i);
if (tmp != browsed_dir)
{
browsed_subdir = browsed_dir.substr(i+1, browsed_dir.size()-i-1);
GetDirectory(tmp);
}
else
{
browsed_subdir = tmp;
GetDirectory("/");
}
}
else
{
if (browsed_dir != "/")
GetDirectory(browsed_dir + "/" + item.name);
else
GetDirectory(item.name);
}
GetDirectory(item.name, browsed_dir);
break;
}
case itSong:
@@ -868,72 +850,72 @@ int main(int argc, char *argv[])
{
case 1:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New title:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New title:[/b] ", 1);
if (s.GetTitle() == UNKNOWN_TITLE)
s.SetTitle(wFooter->GetString());
else
s.SetTitle(wFooter->GetString(s.GetTitle()));
mTagEditor->UpdateOption(option, "[b]Title:[/b] " + s.GetTitle());
mTagEditor->UpdateOption(option, "[.b]Title:[/b] " + s.GetTitle());
break;
}
case 2:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New artist:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New artist:[/b] ", 1);
if (s.GetArtist() == UNKNOWN_ARTIST)
s.SetArtist(wFooter->GetString());
else
s.SetArtist(wFooter->GetString(s.GetArtist()));
mTagEditor->UpdateOption(option, "[b]Artist:[/b] " + s.GetArtist());
mTagEditor->UpdateOption(option, "[.b]Artist:[/b] " + s.GetArtist());
break;
}
case 3:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New album:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New album:[/b] ", 1);
if (s.GetAlbum() == UNKNOWN_ALBUM)
s.SetAlbum(wFooter->GetString());
else
s.SetAlbum(wFooter->GetString(s.GetAlbum()));
mTagEditor->UpdateOption(option, "[b]Album:[/b] " + s.GetAlbum());
mTagEditor->UpdateOption(option, "[.b]Album:[/b] " + s.GetAlbum());
break;
}
case 4:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New year:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New year:[/b] ", 1);
if (s.GetYear() == EMPTY_TAG)
s.SetYear(wFooter->GetString(4));
else
s.SetYear(wFooter->GetString(s.GetYear(), 4));
mTagEditor->UpdateOption(option, "[b]Year:[/b] " + s.GetYear());
mTagEditor->UpdateOption(option, "[.b]Year:[/b] " + s.GetYear());
break;
}
case 5:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New track:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New track:[/b] ", 1);
if (s.GetTrack() == EMPTY_TAG)
s.SetTrack(wFooter->GetString(3));
else
s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
mTagEditor->UpdateOption(option, "[b]Track:[/b] " + s.GetTrack());
mTagEditor->UpdateOption(option, "[.b]Track:[/b] " + s.GetTrack());
break;
}
case 6:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New genre:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New genre:[/b] ", 1);
if (s.GetGenre() == EMPTY_TAG)
s.SetGenre(wFooter->GetString());
else
s.SetGenre(wFooter->GetString(s.GetGenre()));
mTagEditor->UpdateOption(option, "[b]Genre:[/b] " + s.GetGenre());
mTagEditor->UpdateOption(option, "[.b]Genre:[/b] " + s.GetGenre());
break;
}
case 7:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]New comment:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]New comment:[/b] ", 1);
if (s.GetComment() == EMPTY_TAG)
s.SetComment(wFooter->GetString());
else
s.SetComment(wFooter->GetString(s.GetComment()));
mTagEditor->UpdateOption(option, "[b]Comment:[/b] " + s.GetComment());
mTagEditor->UpdateOption(option, "[.b]Comment:[/b] " + s.GetComment());
break;
}
case 8:
@@ -1000,94 +982,94 @@ int main(int argc, char *argv[])
{
case 1:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Filename:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Filename:[/b] ", 1);
if (s.GetShortFilename() == EMPTY_TAG)
s.SetShortFilename(wFooter->GetString());
else
s.SetShortFilename(wFooter->GetString(s.GetShortFilename()));
mSearcher->UpdateOption(option, "[b]Filename:[/b] " + s.GetShortFilename());
mSearcher->UpdateOption(option, "[.b]Filename:[/b] " + s.GetShortFilename());
break;
}
case 2:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Title:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Title:[/b] ", 1);
if (s.GetTitle() == UNKNOWN_TITLE)
s.SetTitle(wFooter->GetString());
else
s.SetTitle(wFooter->GetString(s.GetTitle()));
mSearcher->UpdateOption(option, "[b]Title:[/b] " + s.GetTitle());
mSearcher->UpdateOption(option, "[.b]Title:[/b] " + s.GetTitle());
break;
}
case 3:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Artist:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Artist:[/b] ", 1);
if (s.GetArtist() == UNKNOWN_ARTIST)
s.SetArtist(wFooter->GetString());
else
s.SetArtist(wFooter->GetString(s.GetArtist()));
mSearcher->UpdateOption(option, "[b]Artist:[/b] " + s.GetArtist());
mSearcher->UpdateOption(option, "[.b]Artist:[/b] " + s.GetArtist());
break;
}
case 4:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Album:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Album:[/b] ", 1);
if (s.GetAlbum() == UNKNOWN_ALBUM)
s.SetAlbum(wFooter->GetString());
else
s.SetAlbum(wFooter->GetString(s.GetAlbum()));
mSearcher->UpdateOption(option, "[b]Album:[/b] " + s.GetAlbum());
mSearcher->UpdateOption(option, "[.b]Album:[/b] " + s.GetAlbum());
break;
}
case 5:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Year:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Year:[/b] ", 1);
if (s.GetYear() == EMPTY_TAG)
s.SetYear(wFooter->GetString(4));
else
s.SetYear(wFooter->GetString(s.GetYear(), 4));
mSearcher->UpdateOption(option, "[b]Year:[/b] " + s.GetYear());
mSearcher->UpdateOption(option, "[.b]Year:[/b] " + s.GetYear());
break;
}
case 6:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Track:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Track:[/b] ", 1);
if (s.GetTrack() == EMPTY_TAG)
s.SetTrack(wFooter->GetString(3));
else
s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
mSearcher->UpdateOption(option, "[b]Track:[/b] " + s.GetTrack());
mSearcher->UpdateOption(option, "[.b]Track:[/b] " + s.GetTrack());
break;
}
case 7:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Genre:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Genre:[/b] ", 1);
if (s.GetGenre() == EMPTY_TAG)
s.SetGenre(wFooter->GetString());
else
s.SetGenre(wFooter->GetString(s.GetGenre()));
mSearcher->UpdateOption(option, "[b]Genre:[/b] " + s.GetGenre());
mSearcher->UpdateOption(option, "[.b]Genre:[/b] " + s.GetGenre());
break;
}
case 8:
{
wFooter->WriteXY(0, Config.statusbar_visibility, "[b]Comment:[/b] ", 1);
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Comment:[/b] ", 1);
if (s.GetComment() == EMPTY_TAG)
s.SetComment(wFooter->GetString());
else
s.SetComment(wFooter->GetString(s.GetComment()));
mSearcher->UpdateOption(option, "[b]Comment:[/b] " + s.GetComment());
mSearcher->UpdateOption(option, "[.b]Comment:[/b] " + s.GetComment());
break;
}
case 10:
{
search_mode_match = !search_mode_match;
mSearcher->UpdateOption(option, "[b]Search mode:[/b] " + (search_mode_match ? search_mode_one : search_mode_two));
mSearcher->UpdateOption(option, "[.b]Search mode:[/b] " + (search_mode_match ? search_mode_one : search_mode_two));
break;
}
case 11:
{
search_case_sensitive = !search_case_sensitive;
mSearcher->UpdateOption(option, "[b]Case sensitive:[/b] " + (string)(search_case_sensitive ? "Yes" : "No"));
mSearcher->UpdateOption(option, "[.b]Case sensitive:[/b] " + (string)(search_case_sensitive ? "Yes" : "No"));
break;
}
case 13:
@@ -1099,7 +1081,7 @@ int main(int argc, char *argv[])
{
bool bold = 0;
mSearcher->AddSeparator();
mSearcher->AddStaticBoldOption("[white]Search results:[/white] [green]Found " + IntoStr(vSearched.size()) + (vSearched.size() > 1 ? " songs" : " song") + "[/green]");
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++)
@@ -1166,7 +1148,7 @@ int main(int argc, char *argv[])
if (Mpd->CommitQueue())
{
ShowMessage("Adding all songs artist's: " + artist);
Song *s = &mPlaylist->at(mPlaylist->GetChoice()-list.size());
Song *s = &mPlaylist->at(mPlaylist->Size()-list.size());
if (s->GetHash() == list[0]->GetHash())
{
if (Keypressed(input, Key.Enter))
@@ -1280,16 +1262,17 @@ int main(int argc, char *argv[])
{
case itDirectory:
{
string getdir = browsed_dir == "/" ? item.name : browsed_dir + "/" + item.name;
if (browsed_dir != "/" && mBrowser->GetChoice() == 1)
continue; // do not let add parent dir.
SongList list;
Mpd->GetDirectoryRecursive(getdir, list);
Mpd->GetDirectoryRecursive(item.name, list);
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
Mpd->QueueAddSong(**it);
if (Mpd->CommitQueue())
{
ShowMessage("Added folder: " + getdir);
ShowMessage("Added folder: " + item.name);
Song &s = mPlaylist->at(mPlaylist->Size()-list.size());
if (s.GetHash() != list[0]->GetHash())
ShowMessage(message_part_of_songs_added);
@@ -1822,7 +1805,7 @@ int main(int argc, char *argv[])
{
if (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
{
GetDirectory(vSearched[mSearcher->GetChoice()-search_engine_static_option-1]->GetDirectory());
GetDirectory(vSearched[mSearcher->GetRealChoice()-2]->GetDirectory());
for (int i = 1; i < mBrowser->Size(); i++)
{
if (mSearcher->GetCurrentOption() == mBrowser->GetOption(i))

View File

@@ -143,12 +143,12 @@ void DefaultKeys(ncmpcpp_keys &keys)
void DefaultConfiguration(ncmpcpp_config &conf)
{
conf.mpd_music_dir = "/var/lib/mpd/music";
conf.song_list_format = "{[green](%l)[/green] }{%a - }{%t}|{[white]%f[/white]}";
conf.song_list_format = "{[.green](%l)[/green] }{%a - }{%t}|{[.white]%f[/white]}";
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
conf.song_window_title_format = "{%a - }{%t}|{%f}";
conf.song_library_format = "{%n - }{%t}|{%f}";
conf.browser_playlist_prefix = "[red](playlist)[/red] ";
conf.selected_item_prefix = "[magenta]";
conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
conf.selected_item_prefix = "[.magenta]";
conf.selected_item_suffix = "[/magenta]";
conf.empty_tags_color = clCyan;
conf.header_color = clDefault;

View File

@@ -30,10 +30,10 @@ string UNKNOWN_ALBUM;
void DefineEmptyTags()
{
const string et_col = IntoStr(Config.empty_tags_color);
EMPTY_TAG = "[" + et_col + "]<empty>[/" + et_col + "]";
UNKNOWN_ARTIST = "[" + et_col + "]<no artist>[/" + et_col + "]";
UNKNOWN_TITLE = "[" + et_col + "]<no title>[/" + et_col + "]";
UNKNOWN_ALBUM = "[" + et_col + "]<no album>[/" + et_col + "]";
EMPTY_TAG = "[." + et_col + "]<empty>[/" + et_col + "]";
UNKNOWN_ARTIST = "[." + et_col + "]<no artist>[/" + et_col + "]";
UNKNOWN_TITLE = "[." + et_col + "]<no title>[/" + et_col + "]";
UNKNOWN_ALBUM = "[." + et_col + "]<no album>[/" + et_col + "]";
}
Song::Song(mpd_Song *s) : itsHash(0),
@@ -56,14 +56,13 @@ Song::Song(mpd_Song *s) : itsHash(0),
s->disc ? itsDisc = s->disc : itsDisc = "";
s->comment ? itsComment = s->comment : itsComment = "";
int i = itsFile.size();
try
int i = itsFile.find_last_of("/");
if (i != string::npos)
{
while (itsFile[--i] != '/');
itsDirectory = itsFile.substr(0, i);
itsShortName = itsFile.substr(i+1, itsFile.size()-i-1);
itsShortName = itsFile.substr(i+1);
}
catch (std::out_of_range)
else
{
itsDirectory = "/";
itsShortName = itsFile;