]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aft.c
Rename length status item to seconds_total and print it only once.
[paraslash.git] / aft.c
diff --git a/aft.c b/aft.c
index 95de88011a31f2c8780ef11ff1c9b434b1e5b83a..483ab2526e1c1c4259b871644cbab704e524b73d 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -787,15 +787,21 @@ static short unsigned get_duration_width(int seconds)
        return width + 6;
 }
 
-static void get_duration_buf(int seconds, char *buf, short unsigned max_width)
+static void get_duration_buf(int seconds, char *buf, struct ls_options *opts)
 {
        unsigned hours = seconds / 3600, mins = (seconds % 3600) / 60;
+       short unsigned max_width;
 
-       if (!hours) /* m:ss or mm:ss */
+       if (!hours) { /* m:ss or mm:ss */
+               max_width = opts->mode == LS_MODE_LONG?
+                       opts->widths.duration_width : 4;
                sprintf(buf, "%*u:%02u", max_width - 3, mins, seconds % 60);
-       else /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */
+       } else { /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */
+               max_width = opts->mode == LS_MODE_LONG?
+                       opts->widths.duration_width : 7;
                sprintf(buf, "%*u:%02u:%02u", max_width - 6, hours, mins,
                        seconds % 60);
+       }
 }
 
 static char *make_attribute_lines(const char *att_bitmap, struct afs_info *afsi)
@@ -816,20 +822,16 @@ static char *make_lyrics_lines(struct afs_info *afsi)
        char *lyrics_name;
 
        lyr_get_name_by_id(afsi->lyrics_id, &lyrics_name);
-       if (!lyrics_name)
-               return make_message("lyrics_id: %u\n", afsi->lyrics_id);
        return make_message("lyrics_id: %u\nlyrics_name: %s\n",
-               afsi->lyrics_id, lyrics_name);
+               afsi->lyrics_id, lyrics_name? lyrics_name : "(none)");
 }
 
 static char *make_image_lines(struct afs_info *afsi)
 {
        char *image_name;
        img_get_name_by_id(afsi->image_id, &image_name);
-       if (!image_name)
-               return make_message("image_id: %u\n", afsi->image_id);
        return make_message("image_id: %u\nimage_name: %s\n",
-               afsi->image_id, image_name);
+               afsi->image_id, image_name? image_name : "(none)");
 }
 
 static int print_list_item(struct ls_data *d, struct ls_options *opts,
@@ -856,7 +858,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                sizeof(last_played_time), current_time, opts->mode);
        if (ret < 0)
                return ret;
-       get_duration_buf(afhi->seconds_total, duration_buf, w->duration_width);
+       get_duration_buf(afhi->seconds_total, duration_buf, opts);
        if (have_score) {
                if (opts->mode == LS_MODE_LONG)
                        sprintf(score_buf, "%*li ", w->score_width, d->score);
@@ -910,6 +912,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                        "frequency: %dHz\n"
                        "channels: %d\n"
                        "duration: %s\n"
+                       "seconds_total: %lu\n"
                        "num_played: %d\n"
                        "last_played: %s\n"
                        "tag info: %s\n",
@@ -926,6 +929,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                        afhi->frequency,
                        afhi->channels,
                        duration_buf,
+                       afhi->seconds_total,
                        afsi->num_played,
                        last_played_time,
                        afhi->info_string