Evas textblock: Added cursor_visible_range_get and cursor_range_formats_get.

SVN revision: 62259
This commit is contained in:
Tom Hacohen 2011-08-09 13:55:42 +00:00
parent 202623daed
commit e5b331009b
3 changed files with 106 additions and 0 deletions

View File

@ -453,3 +453,11 @@
2011-08-01 Tom Hacohen (TAsn)
* Textblock: Added lang to markup to set the lang of the text.
2011-08-09 Tom Hacohen (TAsn)
* Textblock: Added evas_textblock_cursor_range_formats_get which
returns the formats inside a range.
* Textblock: Added evas_textblock_cursor_visible_range_get which
updates the cursors to the ends of the area currently visible on
screen.

View File

@ -8180,6 +8180,26 @@ EAPI const char *evas_textblock_cursor_paragraph_text_get(const
*/
EAPI int evas_textblock_cursor_paragraph_text_length_get(const Evas_Textblock_Cursor *cur) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
/**
* Return the currently visible range.
*
* @param start the start of the range.
* @param end the end of the range.
* @return EINA_TRUE on success. EINA_FALSE otherwise.
* @since 1.1.0
*/
Eina_Bool evas_textblock_cursor_visible_range_get(Evas_Textblock_Cursor *start, Evas_Textblock_Cursor *end) EINA_ARG_NONNULL(1, 2);
/**
* Return the format nodes in the range between cur1 and cur2.
*
* @param cur1 one side of the range.
* @param cur2 the other side of the range
* @return the foramt nodes in the range. You have to free it.
* @since 1.1.0
*/
EAPI Eina_List * evas_textblock_cursor_range_formats_get(const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
/**
* Return the text in the range between cur1 and cur2
*

View File

@ -7471,6 +7471,68 @@ _evas_textblock_cursor_range_text_plain_get(const Evas_Textblock_Cursor *cur1, c
}
}
EAPI Eina_List *
evas_textblock_cursor_range_formats_get(const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2)
{
Evas_Object *obj = cur1->obj;
Eina_List *ret = NULL;
Evas_Object_Textblock_Node_Text *n1, *n2;
Evas_Object_Textblock_Node_Format *first, *last;
TB_HEAD_RETURN(NULL);
if (!cur1 || !cur1->node) return NULL;
if (!cur2 || !cur2->node) return NULL;
if (cur1->obj != cur2->obj) return NULL;
if (evas_textblock_cursor_compare(cur1, cur2) > 0)
{
const Evas_Textblock_Cursor *tc;
tc = cur1;
cur1 = cur2;
cur2 = tc;
}
n1 = cur1->node;
n2 = cur2->node;
/* FIXME: Change first and last getting to format_before_or_at_pos_get */
last = n2->format_node;
/* If the found format is on our text node, we should go to the last
* one, otherwise, the one we found is good enough. */
if (last->text_node == n2)
{
Evas_Object_Textblock_Node_Format *fnode = last;
while (fnode && (fnode->text_node == n2))
{
last = fnode;
fnode = _NODE_FORMAT(EINA_INLIST_GET(fnode)->next);
}
}
/* If the first format node is within the range (i.e points to n1) or if
* we have other formats in the range, go through them */
first = n1->format_node;
if ((first->text_node == n1) || (first != last))
{
Evas_Object_Textblock_Node_Format *fnode = first;
/* Go to the first one in the range */
if (first->text_node != n1)
{
first = _NODE_FORMAT(EINA_INLIST_GET(first)->next);
}
while (fnode)
{
ret = eina_list_append(ret, fnode);
if (fnode == last)
break;
fnode = _NODE_FORMAT(EINA_INLIST_GET(fnode)->next);
}
}
return ret;
}
EAPI char *
evas_textblock_cursor_range_text_get(const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2, Evas_Textblock_Text_Type format)
{
@ -7879,6 +7941,22 @@ evas_textblock_cursor_line_geometry_get(const Evas_Textblock_Cursor *cur, Evas_C
return ln->par->line_no + ln->line_no;
}
EAPI Eina_Bool
evas_textblock_cursor_visible_range_get(Evas_Textblock_Cursor *start, Evas_Textblock_Cursor *end)
{
Evas_Coord cy, ch;
Evas_Object *obj = start->obj;
TB_HEAD_RETURN(EINA_FALSE);
/* Clip is relative to the object */
cy = obj->cur.cache.clip.y - obj->cur.geometry.y;
ch = obj->cur.cache.clip.h;
evas_textblock_cursor_line_coord_set(start, cy);
evas_textblock_cursor_line_coord_set(end, cy + ch);
evas_textblock_cursor_line_char_last(end);
return EINA_TRUE;
}
EAPI Eina_Bool
evas_textblock_cursor_char_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, Evas_Coord y)
{