| 
      
      
      From: <sa...@us...> - 2006-09-01 02:45:54
      
     | 
| Revision: 17105
          http://svn.sourceforge.net/gaim/?rev=17105&view=rev
Author:   sadrul
Date:     2006-08-31 19:44:46 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
fix the bug in textview
Modified Paths:
--------------
    trunk/console/libgnt/gnttextview.c
    trunk/console/libgnt/gntutils.h
    trunk/console/libgnt/test/tv.c
Modified: trunk/console/libgnt/gnttextview.c
===================================================================
--- trunk/console/libgnt/gnttextview.c	2006-09-01 02:07:23 UTC (rev 17104)
+++ trunk/console/libgnt/gnttextview.c	2006-09-01 02:44:46 UTC (rev 17105)
@@ -324,9 +324,18 @@
 		}
 
 		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;
 		seg->end = end - view->string->str;
Modified: trunk/console/libgnt/gntutils.h
===================================================================
--- trunk/console/libgnt/gntutils.h	2006-09-01 02:07:23 UTC (rev 17104)
+++ trunk/console/libgnt/gntutils.h	2006-09-01 02:44:46 UTC (rev 17105)
@@ -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);
Modified: trunk/console/libgnt/test/tv.c
===================================================================
--- trunk/console/libgnt/test/tv.c	2006-09-01 02:07:23 UTC (rev 17104)
+++ trunk/console/libgnt/test/tv.c	2006-09-01 02:44:46 UTC (rev 17105)
@@ -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();
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |