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)
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,
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);
"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",
afhi->frequency,
afhi->channels,
duration_buf,
+ afhi->seconds_total,
afsi->num_played,
last_played_time,
afhi->info_string