# HG changeset patch # User yaz # Date 1162645001 28800 # Node ID 111f30d09ef29bc2aef678a6acacfb2bfd346932 # Parent 727807ecf74af1cd55fcec77c064d973d2f4ca64 [svn] audtool improvement: - print playlist titles in current codeset. - justify multi byte characters correctly in playlist-display and playqueue-display. diff -r 727807ecf74a -r 111f30d09ef2 ChangeLog --- a/ChangeLog Fri Nov 03 18:47:00 2006 -0800 +++ b/ChangeLog Sat Nov 04 04:56:41 2006 -0800 @@ -1,3 +1,11 @@ +2006-11-04 02:47:00 +0000 William Pitcock + revision [2817] + - merge debian's manpage with ours, and improve overall spelling and grammar + + trunk/audtool.1.in | 279 +++++++++++++++++++++++++++++------------------------ + 1 file changed, 156 insertions(+), 123 deletions(-) + + 2006-11-01 09:31:16 +0000 Yoshiki Yazawa revision [2815] - libguess update. a bug in JOHAB detecting was fixed. diff -r 727807ecf74a -r 111f30d09ef2 audtool/audtool.c --- a/audtool/audtool.c Fri Nov 03 18:47:00 2006 -0800 +++ b/audtool/audtool.c Sat Nov 04 04:56:41 2006 -0800 @@ -18,6 +18,7 @@ #include #include +#include #include "libaudacious/beepctrl.h" #include "audtool.h" @@ -91,6 +92,8 @@ gint i; gchar *remote_uri; + setlocale(LC_CTYPE, ""); + if (argc < 2) { g_print("%s: usage: %s \n", argv[0], argv[0]); @@ -464,7 +467,9 @@ { gint i, ii, frames, length, total; gchar *songname; - + gchar *fmt = NULL, *p; + gint column; + i = xmms_remote_get_playlist_length(session); g_print("%d tracks.\n", i); @@ -478,8 +483,28 @@ length = frames / 1000; total += length; - g_print("%4d | %-60s | %d:%.2d\n", - ii + 1, songname, length / 60, length % 60); + /* adjust width for multi byte characters */ + column = 60; + if(songname){ + p = songname; + while(*p){ + gint stride; + stride = g_utf8_next_char(p) - p; + if(g_unichar_iswide(g_utf8_get_char(p)) || + g_unichar_iswide_cjk(g_utf8_get_char(p))){ + column += (stride - 2); + } + else { + column += (stride - 1); + } + p = g_utf8_next_char(p); + } + + } + + fmt = g_strdup_printf("%%4d | %%-%ds | %%d:%%.2d\n", column); + g_print(fmt, ii + 1, songname, length / 60, length % 60); + g_free(fmt); } g_print("Total length: %d:%.2d\n", total / 60, total % 60); @@ -707,6 +732,8 @@ { gint i, ii, position, frames, length, total; gchar *songname; + gchar *fmt = NULL, *p; + gint column; i = xmms_remote_get_playqueue_length(session); @@ -722,8 +749,27 @@ length = frames / 1000; total += length; - g_print("%4d | %4d | %-60s | %d:%.2d\n", - ii + 1, position + 1, songname, length / 60, length % 60); + /* adjust width for multi byte characters */ + column = 60; + if(songname) { + p = songname; + while(*p){ + gint stride; + stride = g_utf8_next_char(p) - p; + if(g_unichar_iswide(g_utf8_get_char(p)) || + g_unichar_iswide_cjk(g_utf8_get_char(p))){ + column += (stride - 2); + } + else { + column += (stride - 1); + } + p = g_utf8_next_char(p); + } + } + + fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d\n", column); + g_print(fmt, ii + 1, position + 1, songname, length / 60, length % 60); + g_free(fmt); } g_print("Total length: %d:%.2d\n", total / 60, total % 60);