# HG changeset patch # User Sadrul Habib Chowdhury # Date 1157078686 0 # Node ID 70f52ff1caec4dde39439fd92c420ced8f40bb48 # Parent 9e9699792bb9bee5bea7c61da6e603f36dc75011 [gaim-migrate @ 17105] fix the bug in textview committer: Tailor Script diff -r 9e9699792bb9 -r 70f52ff1caec console/libgnt/gnttextview.c --- 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; diff -r 9e9699792bb9 -r 70f52ff1caec console/libgnt/gntutils.h --- 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); diff -r 9e9699792bb9 -r 70f52ff1caec console/libgnt/test/tv.c --- 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();