console/libgnt/gntutils.c

changeset 14482
d974bd81de08
parent 14481
708344e48b1f
child 14485
4fc80c5c8c84
equal deleted inserted replaced
14481:708344e48b1f 14482:d974bd81de08
18 while (*s) 18 while (*s)
19 { 19 {
20 if (*s == '\n' || *s == '\r') 20 if (*s == '\n' || *s == '\r')
21 { 21 {
22 count++; 22 count++;
23 len = g_utf8_pointer_to_offset(last, s); 23 len = gnt_util_onscreen_width(last, s);
24 if (max < len) 24 if (max < len)
25 max = len; 25 max = len;
26 last = s + 1; 26 last = s + 1;
27 } 27 }
28 s++; 28 s = g_utf8_next_char(s);
29 } 29 }
30 30
31 len = g_utf8_pointer_to_offset(last, s); 31 len = gnt_util_onscreen_width(last, s);
32 if (max < len) 32 if (max < len)
33 max = len; 33 max = len;
34 } 34 }
35 35
36 if (height) 36 if (height)
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;

mercurial