Evas textblock: Fix a bug with ellipsis and word-wrap.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 19 Jan 2012 12:11:44 +0000 (12:11 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 19 Jan 2012 12:11:44 +0000 (12:11 +0000)
Ellipsis didn't work well with word wrapping textblocks.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@67333 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_textblock.c
src/tests/evas_test_textblock.c

index 12ca131..568911c 100644 (file)
@@ -3798,9 +3798,23 @@ _layout_par(Ctxt *c)
                         * char is a whitespace we should remove, so this
                         * is a wanted cutting point. */
                        else if (uwrap > it->text_pos + it_len)
-                          wrap = -1; /* Delay the cut in a smart way
-                                        i.e use the item_pos as the line_start, because
-                                        there's already no cut before*/
+                         {
+                            /* FIXME: Should redo the ellipsis handling.
+                             * If we can do ellipsis, just cut here. */
+                            if (it->format->ellipsis == 1.0)
+                              {
+                                 _layout_handle_ellipsis(c, it, i);
+                                 ret = 1;
+                                 goto end;
+                              }
+                            else
+                              {
+                                 /* Delay the cut in a smart way i.e use the
+                                    item_pos as the line_start, because
+                                    there's already no cut before*/
+                                 wrap = -1;
+                              }
+                        }
                        else
                           wrap -= it->text_pos; /* Cut here */
                     }
index a820f5c..cf6a78b 100644 (file)
@@ -1238,6 +1238,13 @@ START_TEST(evas_textblock_wrapping)
    evas_object_textblock_size_formatted_get(tb, &w, &h);
    fail_if((w > (nw / 2)) || (h != nh));
 
+   evas_object_textblock_text_markup_set(tb, "aaaaaaaaaaaaaaaaaa<br/>b");
+   evas_textblock_cursor_format_prepend(cur, "+ ellipsis=1.0 wrap=word");
+   evas_object_textblock_size_native_get(tb, &nw, &nh);
+   evas_object_resize(tb, nw / 2, nh * 2);
+   evas_object_textblock_size_formatted_get(tb, &w, &h);
+   fail_if(w > (nw / 2));
+
    END_TB_TEST();
 }
 END_TEST