changeset 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 be8211f068c4
children 2cee5577224b
files src/gtkhtml.c
diffstat 1 files changed, 11 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkhtml.c	Thu Sep 07 02:17:21 2000 +0000
+++ b/src/gtkhtml.c	Thu Sep 07 05:23:39 2000 +0000
@@ -2900,33 +2900,30 @@
 		 * we print the first half up to the whitespace char, then the second half. if we
 		 * didn't find a whitespace char, we search backwards for one. if we still don't find
 		 * one, we just print the two halves; it would have wrapped anyway */
-		/* FIXME: we should probably look for the previous whitespace character first, but eh. */
-		char *tmp1, *tmp2;
 		int pos = num / 2;
 		static int count = 0;
 		count ++;
-		while (pos < num && !isspace(text[pos])) pos++;
+		while (pos < num && (!isspace(text[pos]) || text[pos] == '\n')) pos++;
 		if (pos == num) {
 			pos = num/2;
-			while (pos > 0 && !isspace(text[pos])) pos--;
+			while (pos > 0 && (!isspace(text[pos]) || text[pos] == '\n')) pos--;
 			if (!pos) pos = num / 2;
 		}
-		tmp1 = g_malloc(pos + 1);
-		tmp2 = g_malloc(num - pos + 1);
-		g_snprintf(tmp1, pos + 1, "%s", text);
-		g_snprintf(tmp2, num - pos + 1, "%s", text + pos + 1);
-		gtk_html_add_text(html, cfont, fore, back, tmp1, pos + 1, uline, strike, url);
-		gtk_html_add_text(html, cfont, fore, back, text + pos, 1, uline, strike, url);
-		gtk_html_add_text(html, cfont, fore, back, tmp2, num - pos + 1, uline, strike, url);
-		g_free(tmp1);
-		g_free(tmp2);
+		gtk_html_add_text(html, cfont, fore, back, text, pos + 1, uline, strike, url);
+		gtk_html_add_text(html, cfont, fore, back, &text[pos+1], 1, uline, strike, url);
+		gtk_html_add_text(html, cfont, fore, back, &text[pos+2], num - pos + 1, uline, strike, url);
 		g_free(text);
 		count--;
 		if (!count) {
 			hbits = g_list_last(html->html_bits);
 			if (!hbits) return; /* does this ever happen? */
 			hb = (GtkHtmlBit *)hbits->data;
-			hb->newline = 1;
+			hb->newline++;
+			if (html->current_x > 0)
+				html->current_x = 0;
+			else
+				html->current_y += cfont->ascent + cfont->descent + 5;
+			return;
 		}
 		return;
 	}