summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 97f1070)
raw | patch | inline | side by side (parent: 97f1070)
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Tue, 12 Jun 2012 21:15:44 +0000 (23:15 +0200) | ||
committer | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Tue, 12 Jun 2012 21:15:44 +0000 (23:15 +0200) |
That is, you can now do things like this:
"[%artist%|(artist n/a)] - [%title%|(title n/a)]"
"[%artist%|(artist n/a)] - [%title%|(title n/a)]"
NEWS | patch | blob | history | |
doc/ncmpc.1 | patch | blob | history | |
src/strfsong.c | patch | blob | history |
index 804b6d2dec35dfaeb2168c676db66e98dfaac8b8..ab2d7b58aeaf5a528df6d7b9b645fb55ff9147c9 100644 (file)
--- a/NEWS
+++ b/NEWS
ncmpc 0.21 - not yet released
* add a chat screen for communication with other clients on the same server
+* song format: evaluate literal strings as true
ncmpc 0.20 - (02/05/2012)
diff --git a/doc/ncmpc.1 b/doc/ncmpc.1
index 9f9b166c9dde8860b30400d3e1e82d3779231d02..a298b33ced328978dba31e8e67b5fb5a41384d99 100644 (file)
--- a/doc/ncmpc.1
+++ b/doc/ncmpc.1
@@ -248,7 +248,7 @@ ncmpc is running. To edit key bindings press 'K' and use the key editor in ncmpc
Format of song display for status and the list window.
The metadata delimiters are: %name%, %artist%, %track%, %time%, %file%, %shortfile%.
-The [] operators are used to group output such that if no metadata delimiters are found or matched between '[' and ']', then none of the characters between '[' and ']' are output. '&' and '|' are logical operators for AND and OR. '#' is used to escape characters.
+The [] operators are used to group output such that if none of the metadata delimiters between '[' and ']' are matched, then none of the characters between '[' and ']' are output; literal text is always output. '&' and '|' are logical operators for AND and OR. '#' is used to escape characters.
Some useful examples for format are:
and
"[[%artist% \- ]%title%]|[%file]"
+
+Another one is:
+
+ "[%artist%|(artist n/a)] - [%title%|(title n/a)]"
+
.SH "CHAT PROTOCOL"
If ncmpc has been compiled with "chat" support, it uses the client-to-client protocol available in MPD 0.17 or higher to communicate with other clients. In order to receive messages it subscribes to the channel with the name "chat", and displays any message sent there as-is. When the user enters a message, it is first with the prefix specified by the \fBchat-prefix\fR option (or the default prefix), and then sent to the "chat" channel for others to read.
.SH "BUGS"
diff --git a/src/strfsong.c b/src/strfsong.c
index 4e9b8d6bbc04f1e5f100dcb0968e957b4b254675..35086e85de41afe083d2f43e71f58ebd7453f7a9 100644 (file)
--- a/src/strfsong.c
+++ b/src/strfsong.c
gchar *temp;
gsize n, length = 0;
gboolean found = FALSE;
+ /* "missed" helps handling the case of mere literal text like
+ found==TRUE instead of found==FALSE. */
+ gboolean missed = FALSE;
s[0] = '\0';
/* OR */
if (p[0] == '|') {
++p;
- if(!found) {
+ if(missed && !found) {
s[0] = '\0';
length = 0;
+ missed = FALSE;
} else {
p = skip(p);
}
/* AND */
if (p[0] == '&') {
++p;
- if(!found) {
+ if(missed && !found) {
p = skip(p);
} else {
found = FALSE;
+ missed = FALSE;
}
continue;
}
g_strlcat(s, temp, max);
length = strlen(s);
found = TRUE;
+ } else {
+ missed = TRUE;
}
g_free(temp);
continue;
/* EXPRESSION END */
if (p[0] == ']') {
if(last) *last = p+1;
- if(!found && length) {
+ if(missed && !found && length) {
s[0] = '\0';
length = 0;
}
g_strlcat(s, ident, max);
length+=templen;
g_free(ident);
+
+ missed = TRUE;
} else {
gsize templen = strlen(temp);