diff console/libgnt/gntutils.c @ 14420:c4a32405af68

[gaim-migrate @ 17128] Keep things neat and clean in gnt_util_onscreen_width_to_pointer. The only use of this function currently is to truncate a string to make sure it fits in the drawing area, eg, the title of a window, or in the combobox. The function is called on a newly allocated string, which is truncated (if necessary), printed, and freed. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 02 Sep 2006 18:55:27 +0000
parents b50aa149e09d
children cfd5bcc06a7e
line wrap: on
line diff
--- a/console/libgnt/gntutils.c	Sat Sep 02 16:55:32 2006 +0000
+++ b/console/libgnt/gntutils.c	Sat Sep 02 18:55:27 2006 +0000
@@ -20,15 +20,15 @@
 			if (*s == '\n' || *s == '\r')
 			{
 				count++;
-				len = g_utf8_pointer_to_offset(last, s);
+				len = gnt_util_onscreen_width(last, s);
 				if (max < len)
 					max = len;
 				last = s + 1;
 			}
-			s++;
+			s = g_utf8_next_char(s);
 		}
 
-		len = g_utf8_pointer_to_offset(last, s);
+		len = gnt_util_onscreen_width(last, s);
 		if (max < len)
 			max = len;
 	}
@@ -50,11 +50,11 @@
 	return width;
 }
 
-char *gnt_util_onscreen_width_to_pointer(const char *string, int len, int *w)
+const char *gnt_util_onscreen_width_to_pointer(const char *string, int len, int *w)
 {
 	int size;
 	int width = 0;
-	char *str = (char*)string;
+	const char *str = string;
 
 	while (width < len && *str) {
 		size = g_unichar_iswide(g_utf8_get_char(str)) ? 2 : 1;