changeset 14397:70f52ff1caec

[gaim-migrate @ 17105] fix the bug in textview committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 01 Sep 2006 02:44:46 +0000
parents 9e9699792bb9
children 2377498b4698
files console/libgnt/gnttextview.c console/libgnt/gntutils.h console/libgnt/test/tv.c
diffstat 3 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/console/libgnt/gnttextview.c	Fri Sep 01 02:07:23 2006 +0000
+++ b/console/libgnt/gnttextview.c	Fri Sep 01 02:44:46 2006 +0000
@@ -324,8 +324,17 @@
 		}
 
 		line = view->list->data;
-		end = gnt_util_onscreen_width_to_pointer(start,
-				widget->priv.width - line->length - 1, &len);
+		if ((end = strchr(start, '\n')) != NULL ||
+			(end = strchr(start, '\r')) != NULL) {
+			int l = gnt_util_onscreen_width(start, end - 1);
+			if (l >= widget->priv.width - line->length - 1) {
+				end = NULL;
+			}
+		}
+
+		if (end == NULL)
+			end = gnt_util_onscreen_width_to_pointer(start,
+					widget->priv.width - line->length - 1, &len);
 
 		seg = g_new0(GntTextSegment, 1);
 		seg->start = start - view->string->str;
--- a/console/libgnt/gntutils.h	Fri Sep 01 02:07:23 2006 +0000
+++ b/console/libgnt/gntutils.h	Fri Sep 01 02:44:46 2006 +0000
@@ -5,6 +5,7 @@
 
 void gnt_util_get_text_bound(const char *text, int *width, int *height);
 
+/* excluding *end */
 int gnt_util_onscreen_width(const char *start, const char *end);
 
 char *gnt_util_onscreen_width_to_pointer(const char *str, int len, int *w);
--- a/console/libgnt/test/tv.c	Fri Sep 01 02:07:23 2006 +0000
+++ b/console/libgnt/test/tv.c	Fri Sep 01 02:44:46 2006 +0000
@@ -83,6 +83,18 @@
 	gnt_entry_set_history_length(GNT_ENTRY(entry), -1);
 	g_signal_connect_after(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view);
 
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD);
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 1st line\n", GNT_TEXT_FLAG_NORMAL);
+
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD);
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 2nd line\n", GNT_TEXT_FLAG_NORMAL);
+
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD);
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 3rd line\n", GNT_TEXT_FLAG_NORMAL);
+
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD);
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 4th line\n", GNT_TEXT_FLAG_NORMAL);
+
 #ifdef STANDALONE
 	gnt_main();