summaryrefslogtreecommitdiff
path: root/src/display.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2009-09-26 18:29:52 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2009-09-26 18:29:52 +0200
commit4efaa189275e4b63d6ddb246a30c9f3dcaeeb908 (patch)
tree1d753ac4d5514e1f4b962327d8e3357fb2f5680b /src/display.cpp
parent3e75ff64553e0efdfb189314f86b26ad41792147 (diff)
ignore special chars that occurs in tag values
ncmpcpp shouldn't treat '$' characters that are part of a tag as special format chars.
Diffstat (limited to 'src/display.cpp')
-rw-r--r--src/display.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/display.cpp b/src/display.cpp
index f2099f43..ef9a34d2 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -221,12 +221,17 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
if (is_now_playing)
*menu << Config.now_playing_prefix;
- std::string line = s.toString(*static_cast<std::string *>(data));
+ std::string line = s.toString(*static_cast<std::string *>(data), "$");
for (std::string::const_iterator it = line.begin(); it != line.end(); ++it)
{
if (*it == '$')
{
- if (isdigit(*++it))
+ if (++it == line.end()) // end of format
+ {
+ *menu << '$';
+ break;
+ }
+ else if (isdigit(*it)) // color
{
*menu << Color(*it-'0');
}
@@ -240,8 +245,15 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
*menu << XY(menu->GetWidth()-buf.Str().length(), menu->Y()) << buf;
return;
}
- else
- *menu << *it;
+ else // not a color nor right align, just a random character
+ *menu << *--it;
+ }
+ else if (*it == MPD::Song::FormatEscapeCharacter)
+ {
+ // treat '$' as a normal character if song format escape char is prepended to it
+ if (++it == line.end() || *it != '$')
+ --it;
+ *menu << *it;
}
else
*menu << *it;