forked from enlightenment/efl
Evas textblock: Fixed cursor_pos_get/set to be absolute, and not node specific like they were.
SVN revision: 55738
This commit is contained in:
parent
9f65268566
commit
6481adfb2b
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue