extend configuration

This commit is contained in:
unK
2008-09-14 17:02:50 +02:00
parent 9ae8249b73
commit 2b8d90a264
7 changed files with 92 additions and 36 deletions

View File

@@ -106,6 +106,8 @@
# #
#default_tag_editor_left_col = "albums" (albums/dirs) #default_tag_editor_left_col = "albums" (albums/dirs)
# #
#default_tag_editor_pattern = "%n - %t"
#
#header_visibility = "yes" #header_visibility = "yes"
# #
#statusbar_visibility = "yes" #statusbar_visibility = "yes"
@@ -130,6 +132,10 @@
# #
#main_window_color = "yellow" #main_window_color = "yellow"
# #
#color1 = "white"
#
#color2 = "green"
#
#main_window_highlight_color = "yellow" #main_window_highlight_color = "yellow"
# #
#progressbar_color = "default" #progressbar_color = "default"
@@ -138,3 +144,7 @@
# #
#active_column_color = "red" #active_column_color = "red"
# #
#window_border_color = "green"
#
#active_window_border = "red"
#

View File

@@ -54,6 +54,12 @@ ColorPair Window::IntoColor(const string &str)
Bold(1); Bold(1);
else if (str == "[.r]") else if (str == "[.r]")
Reverse(1); Reverse(1);
else if (str == "[.default]")
{
colors.first = itsBaseColor;
colors.second = itsBaseBgColor;
itsColors.push(colors);
}
else if (str == "[.red]") else if (str == "[.red]")
{ {
colors.first = clRed; colors.first = clRed;
@@ -410,6 +416,8 @@ bool Window::IsValidColor(const string &str)
str == "[.a]" || str == "[.a]" ||
str == "[/a]" || str == "[/a]" ||
str == "[.default]" ||
str == "[/default]" ||
str == "[.black]" || str == "[.black]" ||
str == "[/black]" || str == "[/black]" ||
str == "[.red]" || str == "[.red]" ||

View File

@@ -665,7 +665,7 @@ string DisplaySong(const Song &s, void *s_template, const Menu<Song> *menu)
{ {
right = 1; right = 1;
lresult = result; lresult = result;
result = ""; result.clear();
i = 0; i = 0;
} }
} }
@@ -690,15 +690,15 @@ string GetInfo(Song &s)
s.SetComment(f.tag()->comment().to8Bit(UNICODE)); s.SetComment(f.tag()->comment().to8Bit(UNICODE));
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
result = "[.b][.white]Filename: [/white][.green][/b]" + s.GetShortFilename() + "[/green]\n"; result = "[.b][." + Config.color1 + "]Filename: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetShortFilename() + "[/" + Config.color2 + "]\n";
result += "[.b][.white]Directory: [/white][.green][/b]" + s.GetDirectory() + "[/green]\n\n"; result += "[.b][." + Config.color1 + "]Directory: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetDirectory() + "[/" + Config.color2 + "]\n\n";
result += "[.b][.white]Length: [/white][.green][/b]" + s.GetLength() + "[/green]\n"; result += "[.b][." + Config.color1 + "]Length: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetLength() + "[/" + Config.color2 + "]\n";
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
if (!f.isNull()) if (!f.isNull())
{ {
result += "[.b][.white]Bitrate: [/white][.green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]\n"; result += "[.b][." + Config.color1 + "]Bitrate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/" + Config.color2 + "]\n";
result += "[.b][.white]Sample rate: [/white][.green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]\n"; result += "[.b][." + Config.color1 + "]Sample rate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/" + Config.color2 + "]\n";
result += "[.b][.white]Channels: [/white][.green][/b]" + string(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]\n"; result += "[.b][." + Config.color1 + "]Channels: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + string(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/" + Config.color2 + "]\n";
} }
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
result += "\n[.b]Title:[/b] " + s.GetTitle(); result += "\n[.b]Title:[/b] " + s.GetTitle();

View File

@@ -1151,7 +1151,7 @@ int main(int argc, char *argv[])
bool bold = 0; bool bold = 0;
int found = mSearcher->Size()-search_engine_static_options; int found = mSearcher->Size()-search_engine_static_options;
mSearcher->InsertSeparator(14); mSearcher->InsertSeparator(14);
mSearcher->Insert(15, std::pair<string, Song>("[.white]Search results:[/white] [.green]Found " + IntoStr(found) + (found > 1 ? " songs" : " song") + "[/green]", Song()), 1, 1); mSearcher->Insert(15, std::pair<string, Song>("[." + Config.color1 + "]Search results:[/" + Config.color1 + "] [." + Config.color2 + "]Found " + IntoStr(found) + (found > 1 ? " songs" : " song") + "[/" + Config.color2 + "]", Song()), 1, 1);
mSearcher->InsertSeparator(16); mSearcher->InsertSeparator(16);
UpdateFoundList(); UpdateFoundList();
ShowMessage("Searching finished!"); ShowMessage("Searching finished!");
@@ -2485,7 +2485,7 @@ int main(int argc, char *argv[])
const int dialog_width = COLS*0.8; const int dialog_width = COLS*0.8;
const int dialog_height = LINES*0.6; const int dialog_height = LINES*0.6;
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", clYellow, brGreen); Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border);
mDialog->SetTimeout(ncmpcpp_window_timeout); mDialog->SetTimeout(ncmpcpp_window_timeout);
mDialog->AddOption("Current MPD playlist"); mDialog->AddOption("Current MPD playlist");

View File

@@ -156,8 +156,11 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.song_library_format = "{%n - }{%t}|{%f}"; conf.song_library_format = "{%n - }{%t}|{%f}";
conf.tag_editor_album_format = "{(%y) }%b"; conf.tag_editor_album_format = "{(%y) }%b";
conf.browser_playlist_prefix = "[.red](playlist)[/red] "; conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
conf.pattern = "%n - %t";
conf.selected_item_prefix = "[.magenta]"; conf.selected_item_prefix = "[.magenta]";
conf.selected_item_suffix = "[/magenta]"; conf.selected_item_suffix = "[/magenta]";
conf.color1 = "white";
conf.color2 = "green";
conf.empty_tags_color = clCyan; conf.empty_tags_color = clCyan;
conf.header_color = clDefault; conf.header_color = clDefault;
conf.volume_color = clDefault; conf.volume_color = clDefault;
@@ -168,6 +171,8 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.progressbar_color = clDefault; conf.progressbar_color = clDefault;
conf.statusbar_color = clDefault; conf.statusbar_color = clDefault;
conf.active_column_color = clRed; conf.active_column_color = clRed;
conf.window_border = brGreen;
conf.active_window_border = brRed;
conf.colors_enabled = true; conf.colors_enabled = true;
conf.fancy_scrolling = true; conf.fancy_scrolling = true;
conf.columns_in_playlist = false; conf.columns_in_playlist = false;
@@ -230,9 +235,11 @@ string GetLineValue(const string &line, char a, char b)
string IntoStr(Color color) string IntoStr(Color color)
{ {
string result = ""; string result;
if (color == clBlack) if (color == clDefault)
result = "default";
else if (color == clBlack)
result = "black"; result = "black";
else if (color == clRed) else if (color == clRed)
result = "red"; result = "red";
@@ -488,6 +495,11 @@ void ReadConfiguration(ncmpcpp_config &conf)
if (!v.empty()) if (!v.empty())
conf.browser_playlist_prefix = v; conf.browser_playlist_prefix = v;
} }
else if (it->find("default_tag_editor_pattern") != string::npos)
{
if (!v.empty())
conf.pattern = v;
}
else if (it->find("selected_item_prefix") != string::npos) else if (it->find("selected_item_prefix") != string::npos)
{ {
if (!v.empty()) if (!v.empty())
@@ -498,6 +510,16 @@ void ReadConfiguration(ncmpcpp_config &conf)
if (!v.empty()) if (!v.empty())
conf.selected_item_suffix = v; conf.selected_item_suffix = v;
} }
else if (it->find("color1") != string::npos)
{
if (!v.empty())
conf.color1 = v;
}
else if (it->find("color2") != string::npos)
{
if (!v.empty())
conf.color2 = v;
}
else if (it->find("colors_enabled") != string::npos) else if (it->find("colors_enabled") != string::npos)
{ {
conf.colors_enabled = v == "yes"; conf.colors_enabled = v == "yes";
@@ -597,6 +619,16 @@ void ReadConfiguration(ncmpcpp_config &conf)
if (!v.empty()) if (!v.empty())
conf.active_column_color = IntoColor(v); conf.active_column_color = IntoColor(v);
} }
else if (it->find("window_border_color ") != string::npos)
{
if (!v.empty())
conf.window_border = Border(IntoColor(v));
}
else if (it->find("active_window_border") != string::npos)
{
if (!v.empty())
conf.active_window_border = Border(IntoColor(v));
}
} }
f.close(); f.close();
} }

View File

@@ -100,9 +100,14 @@ struct ncmpcpp_config
string tag_editor_album_format; string tag_editor_album_format;
string browser_playlist_prefix; string browser_playlist_prefix;
string pattern;
string selected_item_prefix; string selected_item_prefix;
string selected_item_suffix; string selected_item_suffix;
string color1;
string color2;
Color empty_tags_color; Color empty_tags_color;
Color header_color; Color header_color;
Color volume_color; Color volume_color;
@@ -114,6 +119,9 @@ struct ncmpcpp_config
Color statusbar_color; Color statusbar_color;
Color active_column_color; Color active_column_color;
Border window_border;
Border active_window_border;
bool colors_enabled; bool colors_enabled;
bool fancy_scrolling; bool fancy_scrolling;
bool columns_in_playlist; bool columns_in_playlist;

View File

@@ -31,8 +31,6 @@ extern ncmpcpp_keys Key;
extern Menu<string> *mTagEditor; extern Menu<string> *mTagEditor;
extern Window *wFooter; extern Window *wFooter;
string pattern = "%n - %t";
string FindSharedDir(Menu<Song> *menu) string FindSharedDir(Menu<Song> *menu)
{ {
SongList list; SongList list;
@@ -79,7 +77,7 @@ string DisplayTag(const Song &s, void *data, const Menu<Song> *null)
case 6: case 6:
return s.GetComment(); return s.GetComment();
case 8: case 8:
return s.GetNewName().empty() ? s.GetShortFilename() : s.GetShortFilename() + " [.green]->[/green] " + s.GetNewName(); return s.GetNewName().empty() ? s.GetShortFilename() : s.GetShortFilename() + " [." + Config.color2 + "]->[/" + Config.color2 + "] " + s.GetNewName();
default: default:
return ""; return "";
} }
@@ -97,13 +95,13 @@ bool GetSongTags(Song &s)
mTagEditor->Clear(); mTagEditor->Clear();
mTagEditor->Reset(); mTagEditor->Reset();
mTagEditor->AddOption("[.b][.white]Song name: [/white][.green][/b]" + s.GetShortFilename() + "[/green]", 0, 1); mTagEditor->AddOption("[.b][." + Config.color1 + "]Song name: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetShortFilename() + "[/" + Config.color2 + "]", 0, 1);
mTagEditor->AddOption("[.b][.white]Location in DB: [/white][.green][/b]" + s.GetDirectory() + "[/green]", 0, 1); mTagEditor->AddOption("[.b][." + Config.color1 + "]Location in DB: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetDirectory() + "[/" + Config.color2 + "]", 0, 1);
mTagEditor->AddOption("", 0, 1); mTagEditor->AddOption("", 0, 1);
mTagEditor->AddOption("[.b][.white]Length: [/white][.green][/b]" + s.GetLength() + "[/green]", 0, 1); mTagEditor->AddOption("[.b][." + Config.color1 + "]Length: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetLength() + "[/" + Config.color2 + "]", 0, 1);
mTagEditor->AddOption("[.b][.white]Bitrate: [/white][.green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]", 0, 1); mTagEditor->AddOption("[.b][." + Config.color1 + "]Bitrate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/" + Config.color2 + "]", 0, 1);
mTagEditor->AddOption("[.b][.white]Sample rate: [/white][.green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]", 0, 1); mTagEditor->AddOption("[.b][." + Config.color1 + "]Sample rate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/" + Config.color2 + "]", 0, 1);
mTagEditor->AddOption("[.b][.white]Channels: [/white][.green][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]", 0, 1); mTagEditor->AddOption("[.b][." + Config.color1 + "]Channels: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/" + Config.color2 + "]", 0, 1);
mTagEditor->AddSeparator(); mTagEditor->AddSeparator();
@@ -247,7 +245,7 @@ void __deal_with_filenames(SongList &v)
int width = 30; int width = 30;
int height = 6; int height = 6;
Menu<string> *Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, width, height, "", Config.main_color, brGreen); Menu<string> *Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, width, height, "", Config.main_color, Config.window_border);
Main->SetTimeout(ncmpcpp_window_timeout); Main->SetTimeout(ncmpcpp_window_timeout);
Main->AddOption("Get tags from filename"); Main->AddOption("Get tags from filename");
Main->AddOption("Rename files"); Main->AddOption("Rename files");
@@ -285,7 +283,7 @@ void __deal_with_filenames(SongList &v)
if (choice != 3) if (choice != 3)
{ {
Legend = new Scrollpad((COLS-width)/2+one_width, (LINES-height)/2, two_width, height, "Legend", Config.main_color, brGreen); Legend = new Scrollpad((COLS-width)/2+one_width, (LINES-height)/2, two_width, height, "Legend", Config.main_color, Config.window_border);
Legend->SetTimeout(ncmpcpp_window_timeout); Legend->SetTimeout(ncmpcpp_window_timeout);
Legend->Add("%a - artist\n"); Legend->Add("%a - artist\n");
Legend->Add("%t - title\n"); Legend->Add("%t - title\n");
@@ -302,16 +300,16 @@ void __deal_with_filenames(SongList &v)
Legend->Add("%C - comment\n\n"); Legend->Add("%C - comment\n\n");
Legend->Add("[.b]Files:[/b]\n"); Legend->Add("[.b]Files:[/b]\n");
for (SongList::const_iterator it = v.begin(); it != v.end(); it++) for (SongList::const_iterator it = v.begin(); it != v.end(); it++)
Legend->Add("[.green]*[/green] " + (*it)->GetShortFilename() + "\n"); Legend->Add("[." + Config.color2 + "]*[/" + Config.color2 + "] " + (*it)->GetShortFilename() + "\n");
Preview = static_cast<Scrollpad *>(Legend->EmptyClone()); Preview = static_cast<Scrollpad *>(Legend->EmptyClone());
Preview->SetTitle("Preview"); Preview->SetTitle("Preview");
Preview->SetTimeout(ncmpcpp_window_timeout); Preview->SetTimeout(ncmpcpp_window_timeout);
Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, one_width, height, "", Config.main_color, brRed); Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, one_width, height, "", Config.main_color, Config.active_window_border);
Main->SetTimeout(ncmpcpp_window_timeout); Main->SetTimeout(ncmpcpp_window_timeout);
Main->AddOption("[.b]Pattern:[/b] " + pattern); Main->AddOption("[.b]Pattern:[/b] " + Config.pattern);
Main->AddOption("Preview"); Main->AddOption("Preview");
Main->AddOption("Legend"); Main->AddOption("Legend");
Main->AddSeparator(); Main->AddSeparator();
@@ -356,12 +354,12 @@ void __deal_with_filenames(SongList &v)
{ {
LockStatusbar(); LockStatusbar();
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Pattern:[/b] ", 1); wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Pattern:[/b] ", 1);
string new_pattern = wFooter->GetString(pattern); string new_pattern = wFooter->GetString(Config.pattern);
UnlockStatusbar(); UnlockStatusbar();
if (!new_pattern.empty()) if (!new_pattern.empty())
{ {
pattern = new_pattern; Config.pattern = new_pattern;
Main->UpdateOption(0, "[.b]Pattern:[/b] " + pattern); Main->UpdateOption(0, "[.b]Pattern:[/b] " + Config.pattern);
} }
break; break;
} }
@@ -380,10 +378,10 @@ void __deal_with_filenames(SongList &v)
if (preview) if (preview)
{ {
Preview->Add("[.b]" + s.GetShortFilename() + ":[/b]\n"); Preview->Add("[.b]" + s.GetShortFilename() + ":[/b]\n");
Preview->Add(ParseFilename(s, pattern, preview) + "\n"); Preview->Add(ParseFilename(s, Config.pattern, preview) + "\n");
} }
else else
ParseFilename(s, pattern, preview); ParseFilename(s, Config.pattern, preview);
} }
else else
{ {
@@ -391,7 +389,7 @@ void __deal_with_filenames(SongList &v)
int last_dot = file.find_last_of("."); int last_dot = file.find_last_of(".");
string extension = file.substr(last_dot); string extension = file.substr(last_dot);
s.GetEmptyFields(1); s.GetEmptyFields(1);
string new_file = GenerateFilename(s, pattern); string new_file = GenerateFilename(s, Config.pattern);
if (new_file.empty()) if (new_file.empty())
{ {
if (preview) if (preview)
@@ -405,7 +403,7 @@ void __deal_with_filenames(SongList &v)
} }
if (!preview) if (!preview)
s.SetNewName(new_file + extension); s.SetNewName(new_file + extension);
Preview->Add(file + " [.green]->[/green] " + new_file + extension + "\n"); Preview->Add(file + " [." + Config.color2 + "]->[/" + Config.color2 + "] " + new_file + extension + "\n");
s.GetEmptyFields(0); s.GetEmptyFields(0);
} }
} }
@@ -437,18 +435,18 @@ void __deal_with_filenames(SongList &v)
} }
else if (Keypressed(input, Key.VolumeUp) && Active == Main) else if (Keypressed(input, Key.VolumeUp) && Active == Main)
{ {
Active->SetBorder(brGreen); Active->SetBorder(Config.window_border);
Active->Display(1); Active->Display(1);
Active = Helper; Active = Helper;
Active->SetBorder(brRed); Active->SetBorder(Config.active_window_border);
Active->Display(); Active->Display();
} }
else if (Keypressed(input, Key.VolumeDown) && Active == Helper) else if (Keypressed(input, Key.VolumeDown) && Active == Helper)
{ {
Active->SetBorder(brGreen); Active->SetBorder(Config.window_border);
Active->Display(); Active->Display();
Active = Main; Active = Main;
Active->SetBorder(brRed); Active->SetBorder(Config.active_window_border);
Active->Display(1); Active->Display(1);
} }
} }