From 943b9155ee52471c2390313318ef4662c1a0fcbd Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Fri, 12 Dec 2008 22:04:07 +0100 Subject: [PATCH] update example configuration file and ReadConfiguration() function --- doc/config | 36 ++++++++++++++++++++---------------- src/settings.cpp | 26 +++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/doc/config b/doc/config index 9f249667..ecf7c354 100644 --- a/doc/config +++ b/doc/config @@ -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 ##### # diff --git a/src/settings.cpp b/src/settings.cpp index 1d7c1433..791900e2 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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) {