From 7ef9f21bf231411ae20dacd545d31e0a7aec2b62 Mon Sep 17 00:00:00 2001 From: tasn Date: Thu, 23 Dec 2010 12:47:23 +0000 Subject: [PATCH] Evas textblock: Fixed cursor_pos_get/set to be absolute, and not node specific like they were. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@55738 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_object_textblock.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 37ca592..694fcd1 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -5304,8 +5304,19 @@ _evas_textblock_node_format_pos_get(const Evas_Object_Textblock_Node_Format *fmt EAPI int evas_textblock_cursor_pos_get(const Evas_Textblock_Cursor *cur) { + Evas_Object_Textblock *o; + Evas_Object_Textblock_Node_Text *n; + size_t npos = 0; + if (!cur) return -1; - return cur->pos; + o = (Evas_Object_Textblock *)(cur->obj->object_data); + n = o->text_nodes; + while (n != cur->node) + { + npos += eina_ustrbuf_length_get(n->unicode); + n = _NODE_TEXT(EINA_INLIST_GET(n)->next); + } + return npos + cur->pos; } /** @@ -5317,11 +5328,13 @@ evas_textblock_cursor_pos_get(const Evas_Textblock_Cursor *cur) EAPI void evas_textblock_cursor_pos_set(Evas_Textblock_Cursor *cur, int _pos) { - size_t len, pos; + Evas_Object_Textblock *o; + Evas_Object_Textblock_Node_Text *n; + size_t pos; if (!cur) return; - if (!cur->node) return; - len = eina_ustrbuf_length_get(cur->node->unicode); + o = (Evas_Object_Textblock *)(cur->obj->object_data); + if (_pos < 0) { pos = 0; @@ -5331,10 +5344,14 @@ evas_textblock_cursor_pos_set(Evas_Textblock_Cursor *cur, int _pos) pos = (size_t) _pos; } - if (pos > len) + n = o->text_nodes; + while (pos >= eina_ustrbuf_length_get(n->unicode)) { - pos = len; + pos -= eina_ustrbuf_length_get(n->unicode); + n = _NODE_TEXT(EINA_INLIST_GET(n)->next); } + + cur->node = n; cur->pos = pos; } -- 2.7.4