| 48 start = g_utf8_next_char(start); |
48 start = g_utf8_next_char(start); |
| 49 } |
49 } |
| 50 return width; |
50 return width; |
| 51 } |
51 } |
| 52 |
52 |
| 53 char *gnt_util_onscreen_width_to_pointer(const char *string, int len, int *w) |
53 const char *gnt_util_onscreen_width_to_pointer(const char *string, int len, int *w) |
| 54 { |
54 { |
| 55 int size; |
55 int size; |
| 56 int width = 0; |
56 int width = 0; |
| 57 char *str = (char*)string; |
57 const char *str = string; |
| 58 |
58 |
| 59 while (width < len && *str) { |
59 while (width < len && *str) { |
| 60 size = g_unichar_iswide(g_utf8_get_char(str)) ? 2 : 1; |
60 size = g_unichar_iswide(g_utf8_get_char(str)) ? 2 : 1; |
| 61 if (width + size > len) |
61 if (width + size > len) |
| 62 break; |
62 break; |