From: <kt...@us...> - 2010-08-18 07:30:45
|
Revision: 3794 http://cutter.svn.sourceforge.net/cutter/?rev=3794&view=rev Author: ktou Date: 2010-08-18 07:30:38 +0000 (Wed, 18 Aug 2010) Log Message: ----------- * module/ui/cut-console-ui.c: support multi width spaces. Modified Paths: -------------- cutter/trunk/ChangeLog cutter/trunk/module/ui/cut-console-ui.c Modified: cutter/trunk/ChangeLog =================================================================== --- cutter/trunk/ChangeLog 2010-07-28 14:51:42 UTC (rev 3793) +++ cutter/trunk/ChangeLog 2010-08-18 07:30:38 UTC (rev 3794) @@ -1,3 +1,7 @@ +2010-08-18 Kouhei Sutou <ko...@cl...> + + * module/ui/cut-console-ui.c: support multi width spaces. + 2010-07-28 Kouhei Sutou <ko...@co...> * module/report/cut-xml-report-factory.c: add missing parent Modified: cutter/trunk/module/ui/cut-console-ui.c =================================================================== --- cutter/trunk/module/ui/cut-console-ui.c 2010-07-28 14:51:42 UTC (rev 3793) +++ cutter/trunk/module/ui/cut-console-ui.c 2010-08-18 07:30:38 UTC (rev 3794) @@ -448,19 +448,37 @@ g_print(":\n"); } +static guint +utf8_n_spaces (const gchar *string) +{ + guint n = 0; + + for (; string[0]; string = g_utf8_next_char(string)) { + if (g_unichar_iswide_cjk(g_utf8_get_char(string))) { + n += 2; + } else if (string[0] == '\t') { + n += 8; + } else { + n++; + } + } + + return n; +} + static void print_test_on_start (CutConsoleUI *console, const gchar *name, CutTest *test, const gchar *indent) { GString *tab_stop; - gint name_length; + guint name_length; const gchar *description; description = cut_test_get_description(test); if (description) g_print(" %s%s\n", indent, description); - name_length = strlen(indent) + strlen(name) + 2; + name_length = utf8_n_spaces(indent) + utf8_n_spaces(name) + 2; tab_stop = g_string_new(""); while (name_length < (8 * 7 - 1)) { g_string_append_c(tab_stop, '\t'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |