Mercurial > pidgin
comparison src/gtkhtml.c @ 850:902be73a6a43
[gaim-migrate @ 860]
well, it does a little better job. at least now i'm learning from gtkhtml as opposed to just blindly hacking it :-P
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 07 Sep 2000 05:23:39 +0000 |
parents | 430a88eb4a68 |
children | 2cee5577224b |
comparison
equal
deleted
inserted
replaced
849:be8211f068c4 | 850:902be73a6a43 |
---|---|
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. | 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 | 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 | 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 */ | 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. */ | |
2904 char *tmp1, *tmp2; | |
2905 int pos = num / 2; | 2903 int pos = num / 2; |
2906 static int count = 0; | 2904 static int count = 0; |
2907 count ++; | 2905 count ++; |
2908 while (pos < num && !isspace(text[pos])) pos++; | 2906 while (pos < num && (!isspace(text[pos]) || text[pos] == '\n')) pos++; |
2909 if (pos == num) { | 2907 if (pos == num) { |
2910 pos = num/2; | 2908 pos = num/2; |
2911 while (pos > 0 && !isspace(text[pos])) pos--; | 2909 while (pos > 0 && (!isspace(text[pos]) || text[pos] == '\n')) pos--; |
2912 if (!pos) pos = num / 2; | 2910 if (!pos) pos = num / 2; |
2913 } | 2911 } |
2914 tmp1 = g_malloc(pos + 1); | 2912 gtk_html_add_text(html, cfont, fore, back, text, pos + 1, uline, strike, url); |
2915 tmp2 = g_malloc(num - pos + 1); | 2913 gtk_html_add_text(html, cfont, fore, back, &text[pos+1], 1, uline, strike, url); |
2916 g_snprintf(tmp1, pos + 1, "%s", text); | 2914 gtk_html_add_text(html, cfont, fore, back, &text[pos+2], num - pos + 1, uline, strike, url); |
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); | |
2921 g_free(tmp1); | |
2922 g_free(tmp2); | |
2923 g_free(text); | 2915 g_free(text); |
2924 count--; | 2916 count--; |
2925 if (!count) { | 2917 if (!count) { |
2926 hbits = g_list_last(html->html_bits); | 2918 hbits = g_list_last(html->html_bits); |
2927 if (!hbits) return; /* does this ever happen? */ | 2919 if (!hbits) return; /* does this ever happen? */ |
2928 hb = (GtkHtmlBit *)hbits->data; | 2920 hb = (GtkHtmlBit *)hbits->data; |
2929 hb->newline = 1; | 2921 hb->newline++; |
2922 if (html->current_x > 0) | |
2923 html->current_x = 0; | |
2924 else | |
2925 html->current_y += cfont->ascent + cfont->descent + 5; | |
2926 return; | |
2930 } | 2927 } |
2931 return; | 2928 return; |
2932 } | 2929 } |
2933 | 2930 |
2934 while (gdk_text_measure(cfont, text, num) > maxwidth) | 2931 while (gdk_text_measure(cfont, text, num) > maxwidth) |