Code

screen_song: show song range
authorMax Kellermann <max@duempel.org>
Sun, 25 Jul 2010 12:48:31 +0000 (14:48 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 25 Jul 2010 12:48:31 +0000 (14:48 +0200)
NEWS
src/screen_song.c

diff --git a/NEWS b/NEWS
index b3269edda2098287d162138cda83237d9af40056..775a6453afae570294aa174ed76c9bfeeb5c2c10 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,5 @@
 ncmpc 0.18 - not yet released
+* screen_song: show song range
 * po: added Italian translation
 
 
index 2c451c1599c38d2043fafa9ee97d3289c8daf24c..e738fc2914f9eb4f57faec1220ea54e38ff9d82b 100644 (file)
@@ -269,7 +269,34 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c)
                char length[16];
                format_duration_short(length, sizeof(length),
                                      mpd_song_get_duration(song));
-               screen_song_append(_(tag_labels[LABEL_LENGTH]), length,
+
+               const char *value = length;
+
+#if LIBMPDCLIENT_CHECK_VERSION(2,3,0)
+               char buffer[64];
+
+               if (mpd_song_get_end(song) > 0) {
+                       char start[16], end[16];
+                       format_duration_short(start, sizeof(start),
+                                             mpd_song_get_start(song));
+                       format_duration_short(end, sizeof(end),
+                                             mpd_song_get_end(song));
+
+                       snprintf(buffer, sizeof(buffer), "%s [%s-%s]\n",
+                                length, start, end);
+                       value = buffer;
+               } else if (mpd_song_get_start(song) > 0) {
+                       char start[16];
+                       format_duration_short(start, sizeof(start),
+                                             mpd_song_get_start(song));
+
+                       snprintf(buffer, sizeof(buffer), "%s [%s-]\n",
+                                length, start);
+                       value = buffer;
+               }
+#endif
+
+               screen_song_append(_(tag_labels[LABEL_LENGTH]), value,
                                   max_tag_label_width);
        }