summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2010-12-23 12:47:23 +0000
committerTom Hacohen <tom@stosb.com>2010-12-23 12:47:23 +0000
commit6481adfb2b3ffafe10a58304e54d5ec5b33375ff (patch)
tree3849739a66867914c8b094b579c4f995069e954e /legacy
parent9f652685663271e9d1d96a41e36814f9e08372d9 (diff)
Evas textblock: Fixed cursor_pos_get/set to be absolute, and not node specific like they were.
SVN revision: 55738
Diffstat (limited to 'legacy')
-rw-r--r--legacy/evas/src/lib/canvas/evas_object_textblock.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_object_textblock.c b/legacy/evas/src/lib/canvas/evas_object_textblock.c
index 37ca592ebc..694fcd127b 100644
--- a/legacy/evas/src/lib/canvas/evas_object_textblock.c
+++ b/legacy/evas/src/lib/canvas/evas_object_textblock.c
@@ -5304,8 +5304,19 @@ _evas_textblock_node_format_pos_get(const Evas_Object_Textblock_Node_Format *fmt
5304EAPI int 5304EAPI int
5305evas_textblock_cursor_pos_get(const Evas_Textblock_Cursor *cur) 5305evas_textblock_cursor_pos_get(const Evas_Textblock_Cursor *cur)
5306{ 5306{
5307 Evas_Object_Textblock *o;
5308 Evas_Object_Textblock_Node_Text *n;
5309 size_t npos = 0;
5310
5307 if (!cur) return -1; 5311 if (!cur) return -1;
5308 return cur->pos; 5312 o = (Evas_Object_Textblock *)(cur->obj->object_data);
5313 n = o->text_nodes;
5314 while (n != cur->node)
5315 {
5316 npos += eina_ustrbuf_length_get(n->unicode);
5317 n = _NODE_TEXT(EINA_INLIST_GET(n)->next);
5318 }
5319 return npos + cur->pos;
5309} 5320}
5310 5321
5311/** 5322/**
@@ -5317,11 +5328,13 @@ evas_textblock_cursor_pos_get(const Evas_Textblock_Cursor *cur)
5317EAPI void 5328EAPI void
5318evas_textblock_cursor_pos_set(Evas_Textblock_Cursor *cur, int _pos) 5329evas_textblock_cursor_pos_set(Evas_Textblock_Cursor *cur, int _pos)
5319{ 5330{
5320 size_t len, pos; 5331 Evas_Object_Textblock *o;
5332 Evas_Object_Textblock_Node_Text *n;
5333 size_t pos;
5321 5334
5322 if (!cur) return; 5335 if (!cur) return;
5323 if (!cur->node) return; 5336 o = (Evas_Object_Textblock *)(cur->obj->object_data);
5324 len = eina_ustrbuf_length_get(cur->node->unicode); 5337
5325 if (_pos < 0) 5338 if (_pos < 0)
5326 { 5339 {
5327 pos = 0; 5340 pos = 0;
@@ -5331,10 +5344,14 @@ evas_textblock_cursor_pos_set(Evas_Textblock_Cursor *cur, int _pos)
5331 pos = (size_t) _pos; 5344 pos = (size_t) _pos;
5332 } 5345 }
5333 5346
5334 if (pos > len) 5347 n = o->text_nodes;
5348 while (pos >= eina_ustrbuf_length_get(n->unicode))
5335 { 5349 {
5336 pos = len; 5350 pos -= eina_ustrbuf_length_get(n->unicode);
5351 n = _NODE_TEXT(EINA_INLIST_GET(n)->next);
5337 } 5352 }
5353
5354 cur->node = n;
5338 cur->pos = pos; 5355 cur->pos = pos;
5339 5356
5340} 5357}