update example configuration file and ReadConfiguration() function

This commit is contained in:
Andrzej Rybczak
2008-12-12 22:04:07 +01:00
parent 6f296e2419
commit 943b9155ee
2 changed files with 43 additions and 19 deletions

View File

@@ -51,21 +51,25 @@
## 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 be green, write $3%l$9
##
## available colors:
## available values:
##
## - black
## - red
## - green
## - yellow
## - blue
## - magenta
## - cyan
## - white
## - 0 - default window color
## - 1 - black
## - 2 - red
## - 3 - green
## - 4 - yellow
## - 5 - blue
## - 6 - magenta
## - 7 - cyan
## - 8 - white
## - 9 - end of current color
##
## Note: colors can be nested.
##
#
#song_list_format = "{[.green](%l)[/green] }{%a - }{%t}|{[.white]%f[/white]}"
#song_list_format = "{%a - }{%t}|{$8%f$9}%r{$3(%l)$9}"
#
#song_library_format = "{%n - }{%t}|{%f}"
#
@@ -73,11 +77,11 @@
#
#tag_editor_album_format = "{(%y) }%b"
#
#browser_playlist_prefix = "[.red]playlist[/red] "
#browser_playlist_prefix = "$2playlist$9 "
#
#selected_item_prefix = "[.magenta]"
#selected_item_prefix = "$6"
#
#selected_item_suffix = "[/magenta]"
#selected_item_suffix = "$9"
#
## colors are not supported for below veriables
#
@@ -93,10 +97,10 @@
##
## (width of column in %)[column's color]{displayed tag}
##
## - color is optional (if it's not present, default window color will be used)
## - color is optional (if you want the default one, type [])
##
#
#song_columns_list_format = "(8)[green]{l} (28)[cyan]{a} (28){b} (50)[red]{t}"
#song_columns_list_format = "(7)[green]{l} (28)[cyan]{a} (28)[]{b} (50)[red]{t}"
#
##### various settings #####
#

View File

@@ -53,6 +53,17 @@ namespace
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
}
void String2Buffer(const string &s, Buffer &buf)
{
for (string::const_iterator it = s.begin(); it != s.end(); it++)
{
if (*it != '$')
buf << *it;
else
buf << Color(*++it-'0');
}
}
Border IntoBorder(const string &color)
{
return (Border) IntoColor(color);
@@ -563,7 +574,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
else if (cl.find("browser_playlist_prefix") != string::npos)
{
if (!v.empty())
conf.browser_playlist_prefix << v;
{
conf.browser_playlist_prefix.Clear();
String2Buffer(v, conf.browser_playlist_prefix);
}
}
else if (cl.find("default_tag_editor_pattern") != string::npos)
{
@@ -573,12 +587,18 @@ void ReadConfiguration(ncmpcpp_config &conf)
else if (cl.find("selected_item_prefix") != string::npos)
{
if (!v.empty())
conf.selected_item_prefix << v;
{
conf.selected_item_prefix.Clear();
String2Buffer(v, conf.selected_item_prefix);
}
}
else if (cl.find("selected_item_suffix") != string::npos)
{
if (!v.empty())
conf.selected_item_suffix << v;
{
conf.selected_item_suffix.Clear();
String2Buffer(v, conf.selected_item_suffix);
}
}
else if (cl.find("color1") != string::npos)
{