Mercurial > pidgin
comparison src/gtkhtml.c @ 847:430a88eb4a68
[gaim-migrate @ 857]
better handling of strings. this one should actually work much much better.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 07 Sep 2000 01:30:33 +0000 |
parents | 2804dc8e9ba0 |
children | 902be73a6a43 |
comparison
equal
deleted
inserted
replaced
846:4b05985bae5e | 847:430a88eb4a68 |
---|---|
2894 /* | 2894 /* |
2895 * HTK_SCROLLED_WINDOW(GTK_WIDGET(layout)->parent)->vscrollbar->allocation.width) - 8; | 2895 * HTK_SCROLLED_WINDOW(GTK_WIDGET(layout)->parent)->vscrollbar->allocation.width) - 8; |
2896 */ | 2896 */ |
2897 | 2897 |
2898 if ((maxwidth == (hwidth - 8) && gdk_text_measure(cfont, text, num) > maxwidth) || gdk_text_measure(cfont, text, num) < 0) { | 2898 if ((maxwidth == (hwidth - 8) && gdk_text_measure(cfont, text, num) > maxwidth) || gdk_text_measure(cfont, text, num) < 0) { |
2899 /* so here's how it works. we divide it in half. we look for the next whitespace char. | |
2900 * we print the first half up to the whitespace char, then the second half. if we | |
2901 * didn't find a whitespace char, we search backwards for one. if we still don't find | |
2902 * one, we just print the two halves; it would have wrapped anyway */ | |
2903 /* FIXME: we should probably look for the previous whitespace character first, but eh. */ | |
2899 char *tmp1, *tmp2; | 2904 char *tmp1, *tmp2; |
2905 int pos = num / 2; | |
2900 static int count = 0; | 2906 static int count = 0; |
2901 count ++; | 2907 count ++; |
2902 tmp1 = g_malloc(num / 2 + 1); | 2908 while (pos < num && !isspace(text[pos])) pos++; |
2903 tmp2 = g_malloc(num / 2 + 2); | 2909 if (pos == num) { |
2904 g_snprintf(tmp1, num / 2 + 1, "%s", text); | 2910 pos = num/2; |
2905 g_snprintf(tmp2, num / 2 + 2, "%s", text + num / 2); | 2911 while (pos > 0 && !isspace(text[pos])) pos--; |
2906 gtk_html_add_text(html, cfont, fore, back, tmp1, num / 2 + 1, uline, strike, url); | 2912 if (!pos) pos = num / 2; |
2907 gtk_html_add_text(html, cfont, fore, back, tmp2, num / 2 + 2, uline, strike, url); | 2913 } |
2914 tmp1 = g_malloc(pos + 1); | |
2915 tmp2 = g_malloc(num - pos + 1); | |
2916 g_snprintf(tmp1, pos + 1, "%s", text); | |
2917 g_snprintf(tmp2, num - pos + 1, "%s", text + pos + 1); | |
2918 gtk_html_add_text(html, cfont, fore, back, tmp1, pos + 1, uline, strike, url); | |
2919 gtk_html_add_text(html, cfont, fore, back, text + pos, 1, uline, strike, url); | |
2920 gtk_html_add_text(html, cfont, fore, back, tmp2, num - pos + 1, uline, strike, url); | |
2908 g_free(tmp1); | 2921 g_free(tmp1); |
2909 g_free(tmp2); | 2922 g_free(tmp2); |
2910 g_free(text); | 2923 g_free(text); |
2911 count--; | 2924 count--; |
2912 if (!count) { | 2925 if (!count) { |