Revert "Edje entry: Start using the new tb_range_formats_get."
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 5 Sep 2011 12:07:31 +0000 (12:07 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 5 Sep 2011 12:07:31 +0000 (12:07 +0000)
This reverts commit 62260

Unfortunately the textblock function doesn't work as well as expected.

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

src/lib/edje_entry.c

index dc28e61..b3f74d3 100644 (file)
@@ -704,10 +704,7 @@ _edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNU
 }
 
 static void
-_anchors_visible_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en);
-
-static void
-_anchors_update(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
+_anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
 {
    Eina_List *l, *ll, *range = NULL;
    Evas_Coord x, y, w, h;
@@ -719,7 +716,6 @@ _anchors_update(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
    clip = evas_object_clip_get(o);
    x = y = w = h = -1;
    evas_object_geometry_get(o, &x, &y, &w, &h);
-   _anchors_visible_get(c, o, en);
    EINA_LIST_FOREACH(en->anchors, l, an)
      {
         // for item anchors
@@ -897,26 +893,22 @@ _anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, E
 }
 
 static void
-_anchors_visible_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
+_anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
 {
-   const Evas_Object_Textblock_Node_Format *node;
-   Eina_List *formats, *itr;
+   const Eina_List *anchors_a, *anchors_item;
    Anchor *an = NULL;
    _anchors_clear(c, o, en);
 
-   Evas_Textblock_Cursor *start, *end;
-   start = evas_object_textblock_cursor_new(o);
-   end = evas_object_textblock_cursor_new(o);
-   evas_textblock_cursor_visible_range_get(start, end);
-   formats = evas_textblock_cursor_range_formats_get(start, end);
-   evas_textblock_cursor_free(start);
-   evas_textblock_cursor_free(end);
+   anchors_a = evas_textblock_node_format_list_get(o, "a");
+   anchors_item = evas_textblock_node_format_list_get(o, "item");
 
-   EINA_LIST_FOREACH(formats, itr, node)
+   if (anchors_a)
      {
-        const char *s = evas_textblock_node_format_text_get(node);
-        if (!strncmp(s, "+ a ", 4))
+        const Evas_Object_Textblock_Node_Format *node;
+        const Eina_List *itr;
+        EINA_LIST_FOREACH(anchors_a, itr, node)
           {
+             const char *s = evas_textblock_node_format_text_get(node);
              char *p;
              an = calloc(1, sizeof(Anchor));
              if (!an)
@@ -958,8 +950,15 @@ _anchors_visible_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
                }
              an = NULL;
           }
-        else if (!strncmp(s, "+ item ", 7))
+     }
+
+   if (anchors_item)
+     {
+        const Evas_Object_Textblock_Node_Format *node;
+        const Eina_List *itr;
+        EINA_LIST_FOREACH(anchors_item, itr, node)
           {
+             const char *s = evas_textblock_node_format_text_get(node);
              char *p;
              an = calloc(1, sizeof(Anchor));
              if (!an)
@@ -981,8 +980,6 @@ _anchors_visible_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
               * here cause it doesn't really matter. */
           }
      }
-
-   eina_list_free(formats);
 }
 
 
@@ -1176,6 +1173,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                }
           }
         _sel_clear(en->cursor, rp->object, en);
+        _anchors_get(en->cursor, rp->object, en);
         _edje_emit(ed, "entry,key,backspace", rp->part->name);
         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
      }
@@ -1197,6 +1195,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                _delete(en->cursor, rp->object, en);
           }
         _sel_clear(en->cursor, rp->object, en);
+        _anchors_get(en->cursor, rp->object, en);
         _edje_emit(ed, "entry,changed", rp->part->name);
         _edje_emit(ed, "entry,changed,user", rp->part->name);
         _edje_emit(ed, "entry,key,delete", rp->part->name);
@@ -1309,6 +1308,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                   //yy
 //                  evas_textblock_cursor_format_prepend(en->cursor, "\t");
                   _text_filter_format_prepend(en, en->cursor, "\t");
+                  _anchors_get(en->cursor, rp->object, en);
                   _edje_emit(ed, "entry,changed", rp->part->name);
                   _edje_emit(ed, "entry,changed,user", rp->part->name);
                }
@@ -1370,6 +1370,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
 //                  evas_textblock_cursor_format_prepend(en->cursor, "ps");
                   _text_filter_format_prepend(en, en->cursor, "ps");
                }
+             _anchors_get(en->cursor, rp->object, en);
              _edje_emit(ed, "entry,changed", rp->part->name);
              _edje_emit(ed, "entry,changed,user", rp->part->name);
              _edje_emit(ed, "cursor,changed", rp->part->name);
@@ -1403,6 +1404,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                }
              else
                _text_filter_text_prepend(en, en->cursor, ev->string);
+             _anchors_get(en->cursor, rp->object, en);
              _edje_emit(ed, "entry,changed", rp->part->name);
              _edje_emit(ed, "entry,changed,user", rp->part->name);
              _edje_emit(ed, "cursor,changed", rp->part->name);
@@ -2092,6 +2094,7 @@ _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
    evas_object_textblock_text_markup_set(rp->object, text);
    _edje_entry_set_cursor_start(rp);
 
+   _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "entry,changed", rp->part->name);
    _edje_entry_imf_cursor_info_set(en);
 #if 0
@@ -2113,6 +2116,7 @@ _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
    evas_textblock_cursor_free(end_cur);
 
    /* We are updating according to the real cursor on purpose */
+   _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "entry,changed", rp->part->name);
 
    _edje_entry_real_part_configure(rp);
@@ -2130,6 +2134,7 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
    //xx
 //   evas_object_textblock_text_markup_prepend(en->cursor, text);
    _text_filter_markup_prepend(en, en->cursor, text);
+   _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "entry,changed", rp->part->name);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
 
@@ -2796,6 +2801,7 @@ _edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
    evas_textblock_cursor_free(tc);
 
    _edje_entry_imf_cursor_info_set(en);
+   _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "entry,changed", rp->part->name);
    _edje_emit(ed, "entry,changed,user", rp->part->name);
    _edje_emit(ed, "cursor,changed", rp->part->name);
@@ -2891,6 +2897,7 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *
      }
 
    _edje_entry_imf_cursor_info_set(en);
+   _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "preedit,changed", rp->part->name);
    _edje_emit(ed, "cursor,changed", rp->part->name);