Tizen Native API  5.5
Textblock Object Functions

Functions used to create and manipulate textblock objects. Unlike Text Object Functions, these handle complex text, doing multiple styles and multiline text based on HTML-like tags. Of these extra features will be heavier on memory and processing cost.

Textblock Object Tutorial

This part explains about the textblock object's API and proper usage. The main user of the textblock object is the edje entry object in Edje, so that's a good place to learn from, but I think this document is more than enough, if it's not, please contact me and I'll update it.

Introduction

The textblock objects is, as implied, an object that can show big chunks of text. Textblock supports many features including: Text formatting, automatic and manual text alignment, embedding items (for example icons) and more. Textblock has three important parts, the text paragraphs, the format nodes and the cursors.

You can use markup to format text, for example: "<font_size=50>Big!</font_size>". You can also put more than one style directive in one tag: "<font_size=50 color=#F00>Big and Red!</font_size>". Please notice that we used "</font_size>" although the format also included color, this is because the first format determines the matching closing tag's name. You can also use anonymous tags, like: "<font_size=30>Big</>" which just pop any type of format, but it's advised to use the named alternatives instead.

Textblock Object Cursors

A textblock Cursor is data type that represents a position in a textblock. Each cursor contains information about the paragraph it points to, the position in that paragraph and the object itself. Cursors register to textblock objects upon creation, this means that once you created a cursor, it belongs to a specific obj and you can't for example copy a cursor "into" a cursor of a different object. Registered cursors also have the added benefit of updating automatically upon textblock changes, this means that if you have a cursor pointing to a specific character, it'll still point to it even after you change the whole object completely (as long as the char was not deleted), this is not possible without updating, because as mentioned, each cursor holds a character position. There are many functions that handle cursors, just check out the evas_textblock_cursor* functions. For creation and deletion of cursors check out:

See also:
evas_object_textblock_cursor_new()
evas_textblock_cursor_free()
Note:
Cursors are generally the correct way to handle text in the textblock object, and there are enough functions to do everything you need with them (no need to get big chunks of text and processing them yourself).

Textblock Object Paragraphs

The textblock object is made out of text splitted to paragraphs (delimited by the paragraph separation character). Each paragraph has many (or none) format nodes associated with it which are responsible for the formatting of that paragraph.

Textblock Object Format Nodes

As explained in Textblock Object Paragraphs each one of the format nodes is associated with a paragraph. There are two types of format nodes, visible and invisible: Visible: formats that a cursor can point to, i.e formats that occupy space, for example: newlines, tabs, items and etc. Some visible items are made of two parts, in this case, only the opening tag is visible. A closing tag (i.e a </tag> tag) should NEVER be visible. Invisible: formats that don't occupy space, for example: bold and underline. Being able to access format nodes is very important for some uses. For example, edje uses the "<a>" format to create links in the text (and pop popups above them when clicked). For the textblock object a is just a formatting instruction (how to color the text), but edje utilizes the access to the format nodes to make it do more. For more information, take a look at all the evas_textblock_node_format_* functions. The translation of "<tag>" tags to actual format is done according to the tags defined in the style, see evas_textblock_style_set

Special Formats

Textblock supports various format directives that can be used in markup. In addition to the mentioned format directives, textblock allows creating additional format directives using "tags" that can be set in the style see evas_textblock_style_set .

For more details see evas_textblock_style_page

Textblock supports the following formats:

Warning:
We don't guarantee any proper results if you create a Textblock object without setting the evas engine.

Functions

const char * evas_textblock_escape_string_get (const char *escape)
const char * evas_textblock_string_escape_get (const char *string, int *len_ret)
const char * evas_textblock_escape_string_range_get (const char *escape_start, const char *escape_end)
Evas_Textblock_Styleevas_textblock_style_new (void)
void evas_textblock_style_free (Evas_Textblock_Style *ts)
void evas_textblock_style_set (Evas_Textblock_Style *ts, const char *text)
const char * evas_textblock_style_get (const Evas_Textblock_Style *ts)
const
Evas_Object_Textblock_Node_Format
evas_textblock_node_format_next_get (const Evas_Object_Textblock_Node_Format *n)
const
Evas_Object_Textblock_Node_Format
evas_textblock_node_format_prev_get (const Evas_Object_Textblock_Node_Format *n)
void evas_textblock_cursor_set_at_format (Evas_Textblock_Cursor *cur, const Evas_Object_Textblock_Node_Format *n)
const
Evas_Object_Textblock_Node_Format
evas_textblock_cursor_format_get (const Evas_Textblock_Cursor *cur)
const char * evas_textblock_node_format_text_get (const Evas_Object_Textblock_Node_Format *fnode)
void evas_textblock_cursor_at_format_set (Evas_Textblock_Cursor *cur, const Evas_Object_Textblock_Node_Format *fmt)
Eina_Bool evas_textblock_cursor_format_is_visible_get (const Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_format_next (Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_format_prev (Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_is_format (const Evas_Textblock_Cursor *cur)
int evas_textblock_cursor_pos_get (const Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_line_set (Evas_Textblock_Cursor *cur, int line)
Eina_Bool evas_textblock_cursor_format_append (Evas_Textblock_Cursor *cur, const char *format)
Eina_Bool evas_textblock_cursor_format_prepend (Evas_Textblock_Cursor *cur, const char *format)
void evas_textblock_cursor_range_delete (Evas_Textblock_Cursor *cur1, Evas_Textblock_Cursor *cur2)
const char * evas_textblock_cursor_paragraph_text_get (const Evas_Textblock_Cursor *cur)
int evas_textblock_cursor_paragraph_text_length_get (const Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_visible_range_get (Evas_Textblock_Cursor *start, Evas_Textblock_Cursor *end)
Eina_Listevas_textblock_cursor_range_formats_get (const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2)
char * evas_textblock_cursor_range_text_get (const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2, Evas_Textblock_Text_Type format)
char * evas_textblock_cursor_content_get (const Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_geometry_bidi_get (const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, Evas_Coord *cx2, Evas_Coord *cy2, Evas_Coord *cw2, Evas_Coord *ch2, Evas_Textblock_Cursor_Type ctype)
int evas_textblock_cursor_geometry_get (const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, Evas_BiDi_Direction *dir, Evas_Textblock_Cursor_Type ctype)
int evas_textblock_cursor_char_geometry_get (const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
int evas_textblock_cursor_pen_geometry_get (const Evas_Textblock_Cursor *cur, Evas_Coord *cpen_x, Evas_Coord *cy, Evas_Coord *cadv, Evas_Coord *ch)
int evas_textblock_cursor_line_geometry_get (const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
int evas_textblock_cursor_line_coord_set (Evas_Textblock_Cursor *cur, Evas_Coord y)
Eina_Listevas_textblock_cursor_range_geometry_get (const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2)
Eina_Iteratorevas_textblock_cursor_range_simple_geometry_get (const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2)
Eina_Bool evas_textblock_cursor_format_item_geometry_get (const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
Eina_Bool evas_textblock_cursor_eol_get (const Evas_Textblock_Cursor *cur)
Eina_Bool evas_textblock_cursor_char_prev (Evas_Textblock_Cursor *obj)
 Advances the cursor one char backwards.
Eina_Bool evas_textblock_cursor_char_next (Evas_Textblock_Cursor *obj)
 Advances the cursor one char forward.
Eina_Bool evas_textblock_cursor_cluster_prev (Evas_Textblock_Cursor *obj)
 Advances the cursor one grapheme cluster backwards.
Eina_Bool evas_textblock_cursor_cluster_next (Evas_Textblock_Cursor *obj)
 Advances the cursor one grapheme cluster forward.
Eina_Bool evas_textblock_cursor_paragraph_next (Evas_Textblock_Cursor *obj)
 Advances to the start of the next text node.
Eina_Bool evas_textblock_cursor_paragraph_prev (Evas_Textblock_Cursor *obj)
 Advances to the end of the previous text node.
Eina_Bool evas_textblock_cursor_word_start (Evas_Textblock_Cursor *obj)
 Moves the cursor to the start of the word under the cursor.
Eina_Bool evas_textblock_cursor_word_end (Evas_Textblock_Cursor *obj)
 Moves the cursor to the end of the word under the cursor.

Typedefs

typedef struct
_Efl_Canvas_Textblock_Style 
Evas_Textblock_Style
typedef struct
_Efl_Text_Cursor_Handle 
Evas_Textblock_Cursor
typedef struct
_Evas_Textblock_Node_Format 
Evas_Object_Textblock_Node_Format
typedef Eina_Rectangle Evas_Textblock_Rectangle
typedef enum
_Evas_Textblock_Text_Type 
Evas_Textblock_Text_Type
typedef enum
_Evas_Textblock_Cursor_Type 
Evas_Textblock_Cursor_Type

Typedef Documentation

A format node.

XXX: Adapter for legacy.

A textblock cursor object, used to maipulate the cursor of an evas textblock

See also:
evas_object_textblock_cursor_new

Cursor type for evas textblock.

typedef struct _Evas_Textblock_Node_Format Evas_Textblock_Node_Format

A format node.

XXX: Adapter for legacy.

General-purpose rectangle that represents some geometry in this object.

Text type for evas textblock.


Enumeration Type Documentation

Cursor type for evas textblock.

Enumerator:
EVAS_TEXTBLOCK_CURSOR_UNDER 

cursor type is under

EVAS_TEXTBLOCK_CURSOR_BEFORE 

cursor type is before

Text type for evas textblock.

Enumerator:
EVAS_TEXTBLOCK_TEXT_RAW 

textblock text of type raw

EVAS_TEXTBLOCK_TEXT_PLAIN 

textblock text of type plain

EVAS_TEXTBLOCK_TEXT_MARKUP 

textblock text of type markup


Function Documentation

Adds a textblock to the given evas.

Parameters:
eThe given evas.
Returns:
The new textblock object.
Since :
2.3
Examples:
ecore_imf_example.c, and evas-images2.c.

TIZEN_ONLY(20161011): add ellipsis_disabled_set/get APIs

TIZEN_ONLY(20161011): add ellipsis_disabled_set/get APIs

double evas_object_textblock_ellipsis_get ( const Evas_Object eo_obj)

TIZEN_ONLY(20170703): Add ellipsize feature and refactory fade_ellipsis, marquee features.

void evas_object_textblock_ellipsis_set ( Evas_Object eo_obj,
double  ellipsis 
)

TIZEN_ONLY(20170703): Add ellipsize feature and refactory fade_ellipsis, marquee features.

TIZEN_ONLY(20160920): Add fade_ellipsis feature to TEXTBLOCK, TEXT part.

Set the cursor to point to the position of fmt.

Parameters:
curthe cursor to update
fmtthe format to update according to.
Since :
2.3
int evas_textblock_cursor_char_geometry_get ( const Evas_Textblock_Cursor cur,
Evas_Coord *  cx,
Evas_Coord *  cy,
Evas_Coord *  cw,
Evas_Coord *  ch 
)

Returns the geometry of the char at cur.

Parameters:
curthe position of the char.
cxthe x of the char.
cythe y of the char.
cwthe w of the char.
chthe h of the char.
Returns:
line number of the char on success, -1 on error.
Since :
2.3

Advances the cursor one char forward.

Returns:
true on success, false otherwise.
Since :
2.3

Advances the cursor one char backwards.

Returns:
true on success, false otherwise.
Since :
2.3
Examples:
ecore_imf_example.c.

Advances the cursor one grapheme cluster forward.

Returns:
true on success, false otherwise.

Advances the cursor one grapheme cluster backwards.

Returns:
true on success, false otherwise.

Return the content of the cursor.

Free the returned string pointer when done (if it is not NULL).

Parameters:
curthe cursor
Returns:
the text in the range, terminated by a nul byte (may be utf8).
Since :
2.3

Checks if the cursor points to the end of the line.

Parameters:
curthe cursor to check.
Returns:
EINA_TRUE if true, EINA_FALSE otherwise.
Since :
2.3

Adds format to the current cursor position. If the format being added is a visible format, add it *before* the cursor position, otherwise, add it after. This behavior is because visible formats are like characters and invisible should be stacked in a way that the last one is added last.

This function works with native formats, that means that style defined tags like
won't work here. For those kind of things use markup prepend.

Parameters:
curthe cursor to where to add format at.
formatthe format to add.
Returns:
Returns true if a visible format was added, false otherwise.
See also:
evas_textblock_cursor_format_prepend() Check if the current cursor position points to the terminating null of the last paragraph. (shouldn't be allowed to point to the terminating null of any previous paragraph anyway.
Parameters:
curthe cursor to look at.
Returns:
EINA_TRUE if the cursor points to the terminating null, EINA_FALSE otherwise.
Since :
2.3

Return the format node at the position pointed by cur.

Parameters:
curthe position to look at.
Returns:
the format node if found, NULL otherwise.
See also:
evas_textblock_cursor_format_is_visible_get()
Since :
2.3

Check if the current cursor position is a visible format. This way is more efficient than evas_textblock_cursor_format_get() to check for the existence of a visible format.

Parameters:
curthe cursor to look at.
Returns:
EINA_TRUE if the cursor points to a visible format, EINA_FALSE otherwise.
See also:
evas_textblock_cursor_format_get()
Since :
2.3
Eina_Bool evas_textblock_cursor_format_item_geometry_get ( const Evas_Textblock_Cursor cur,
Evas_Coord *  cx,
Evas_Coord *  cy,
Evas_Coord *  cw,
Evas_Coord *  ch 
)

Get the geometry of ?

Parameters:
curone side of the range.
cur2other side of the range.
Since :
3.0f(2.3.1)

Advances to the next format node

Parameters:
curthe cursor to be updated.
Returns:
EINA_TRUE on success EINA_FALSE otherwise.
Since :
2.3

Adds format to the current cursor position. If the format being added is a visible format, add it *before* the cursor position, otherwise, add it after. This behavior is because visible formats are like characters and invisible should be stacked in a way that the last one is added last. If the format is visible the cursor is advanced after it.

This function works with native formats, that means that style defined tags like
won't work here. For those kind of things use markup prepend.

Parameters:
curthe cursor to where to add format at.
formatthe format to add.
Returns:
Returns true if a visible format was added, false otherwise.
See also:
evas_textblock_cursor_format_prepend()
Since :
2.3

Advances to the previous format node.

Parameters:
curthe cursor to update.
Returns:
EINA_TRUE on success EINA_FALSE otherwise.
Since :
2.3
Eina_Bool evas_textblock_cursor_geometry_bidi_get ( const Evas_Textblock_Cursor cur,
Evas_Coord *  cx,
Evas_Coord *  cy,
Evas_Coord *  cw,
Evas_Coord *  ch,
Evas_Coord *  cx2,
Evas_Coord *  cy2,
Evas_Coord *  cw2,
Evas_Coord *  ch2,
Evas_Textblock_Cursor_Type  ctype 
)

Returns the geometry of two cursors ("split cursor"), if logical cursor is between LTR/RTL text, also considering paragraph direction. Upper cursor is shown for the text of the same direction as paragraph, lower cursor - for opposite.

Split cursor geometry is valid only in '|' cursor mode. In this case EINA_TRUE is returned and cx2, cy2, cw2, ch2 are set, otherwise it behaves like cursor_geometry_get.

Parameters:
[in]curthe cursor.
[out]cxthe x of the cursor (or upper cursor)
[out]cythe y of the cursor (or upper cursor)
[out]cwthe width of the cursor (or upper cursor)
[out]chthe height of the cursor (or upper cursor)
[out]cx2the x of the lower cursor
[out]cy2the y of the lower cursor
[out]cw2the width of the lower cursor
[out]ch2the height of the lower cursor
[in]ctypethe type of the cursor.
Returns:
EINA_TRUE for split cursor, EINA_FALSE otherwise
Since (EFL) :
1.8
Since :
2.3
int evas_textblock_cursor_geometry_get ( const Evas_Textblock_Cursor cur,
Evas_Coord *  cx,
Evas_Coord *  cy,
Evas_Coord *  cw,
Evas_Coord *  ch,
Evas_BiDi_Direction *  dir,
Evas_Textblock_Cursor_Type  ctype 
)

Returns the geometry of the cursor. Depends on the type of cursor requested. This should be used instead of char_geometry_get because there are weird special cases with BiDi text. in '_' cursor mode (i.e a line below the char) it's the same as char_geometry get, except for the case of the last char of a line which depends on the paragraph direction.

in '|' cursor mode (i.e a line between two chars) it is very variable. For example consider the following visual string: "abcCBA" (ABC are rtl chars), a cursor pointing on A should actually draw a '|' between the c and the C.

Parameters:
curthe cursor.
cxthe x of the cursor
cythe y of the cursor
cwthe width of the cursor
chthe height of the cursor
dirthe direction of the cursor, can be NULL.
ctypethe type of the cursor.
Returns:
line number of the char on success, -1 on error.
Since :
2.3
Examples:
ecore_imf_example.c.

Returns true if the cursor points to a format.

Parameters:
curthe cursor to check.
Returns:
EINA_TRUE if a cursor points to a format EINA_FALSE otherwise.
Since :
2.3

Set the cursor position according to the y coord.

Parameters:
curthe cur to be set.
ythe coord to set by.
Returns:
the line number found, -1 on error.
Since :
2.3
int evas_textblock_cursor_line_geometry_get ( const Evas_Textblock_Cursor cur,
Evas_Coord *  cx,
Evas_Coord *  cy,
Evas_Coord *  cw,
Evas_Coord *  ch 
)

Returns the geometry of the line at cur.

Parameters:
curthe position of the line.
cxthe x of the line.
cythe y of the line.
cwthe width of the line.
chthe height of the line.
Returns:
line number of the line on success, -1 on error.
Since :
2.3

Go to the start of the line passed

Parameters:
curcursor to update.
linenumber to set.
Returns:
EINA_TRUE on success, EINA_FALSE on error.
Since :
2.3

TIZEN_ONLY(20170703): Add ellipsize feature and refactory fade_ellipsis, marquee features.

Advances to the start of the next text node.

Returns:
true if managed to advance, false otherwise
Since :
2.3

Advances to the end of the previous text node.

Returns:
true if managed to advance, false otherwise
Since :
2.3

Return the text of the paragraph cur points to - returns the text in markup.

Parameters:
curthe cursor pointing to the paragraph.
Returns:
the text on success, NULL otherwise.
Since :
2.3

Return the length of the paragraph, cheaper the eina_unicode_strlen()

Parameters:
curthe position of the paragraph.
Returns:
the length of the paragraph on success, -1 otehrwise.
Since :
2.3
int evas_textblock_cursor_pen_geometry_get ( const Evas_Textblock_Cursor cur,
Evas_Coord *  cpen_x,
Evas_Coord *  cy,
Evas_Coord *  cadv,
Evas_Coord *  ch 
)

Returns the geometry of the pen at cur.

Parameters:
curthe position of the char.
cpen_xthe pen_x of the char.
cythe y of the char.
cadvthe adv of the char.
chthe h of the char.
Returns:
line number of the char on success, -1 on error.
Since :
2.3

Return the current cursor pos.

Parameters:
curthe cursor to take the position from.
Returns:
the position or -1 on error
Since :
2.3
Examples:
ecore_imf_example.c.

Delete the range between cur1 and cur2.

Parameters:
cur1one side of the range.
cur2the second side of the range
Returns:
Returns no value.
Since :
2.3
Examples:
ecore_imf_example.c.

Return the format nodes in the range between cur1 and cur2.

Parameters:
cur1one side of the range.
cur2the other side of the range
Returns:
the foramt nodes in the range. You have to free it.
Since (EFL) :
1.1
Since :
2.3

Get the geometry of a range.

Parameters:
cur1one side of the range.
cur2other side of the range.
Returns:
a list of Rectangles representing the geometry of the range.
Since :
2.3

Get the simple geometry of a range. The simple geometry is the geomtry in which rectangles in middle lines of range are merged into one big rectangle.

Since (EFL) :
1.13
Parameters:
cur1one side of the range.
cur2other side of the range.
Returns:
an iterator of rectangles representing the geometry of the range.
Since :
3.0f(2.3.1)

Return the text in the range between cur1 and cur2

Parameters:
cur1one side of the range.
cur2the other side of the range
formatThe form on which to return the text. Markup - in textblock markup. Plain - UTF8.
Returns:
the text in the range
See also:
elm_entry_markup_to_utf8()
Since :
2.3

Sets the cursor to point to the place where format points to.

Parameters:
curthe cursor to update.
nthe format node to update according.
Deprecated:
duplicate of evas_textblock_cursor_at_format_set
Since :
2.3

Return the currently visible range.

Parameters:
startthe start of the range.
endthe end of the range.
Returns:
EINA_TRUE on success, EINA_FALSE otherwise.
Since (EFL) :
1.1
Since :
2.3

Moves the cursor to the end of the word under the cursor.

Returns:
true on success, false otherwise
Since :
2.3

Moves the cursor to the start of the word under the cursor.

Returns:
true on success, false otherwise
Since :
2.3
const char* evas_textblock_escape_string_get ( const char *  escape)

Returns the unescaped version of escape.

Parameters:
escapethe string to be escaped
Returns:
the unescaped version of escape
Since :
2.3
const char* evas_textblock_escape_string_range_get ( const char *  escape_start,
const char *  escape_end 
)

Return the unescaped version of the string between start and end.

Parameters:
escape_startthe start of the string.
escape_endthe end of the string.
Returns:
the unescaped version of the range
Since :
2.3

Returns the next format node (after n)

Parameters:
nthe current format node - not null.
Returns:
Returns the next format node, may be null.
Since :
2.3

Returns the prev format node (after n)

Parameters:
nthe current format node - not null.
Returns:
Returns the prev format node, may be null.
Since :
2.3

Get the text format representation of the format node.

Parameters:
fnodethe format node.
Returns:
the textual format of the format node.
Since :
2.3
const char* evas_textblock_string_escape_get ( const char *  string,
int *  len_ret 
)

Returns the escaped version of the string.

Parameters:
stringto escape
len_retthe len of the part of the string that was used.
Returns:
the escaped string.
Since :
2.3

Destroys a textblock style.

Parameters:
tsThe textblock style to free.
Since :
2.3
Examples:
ecore_imf_example.c.
const char* evas_textblock_style_get ( const Evas_Textblock_Style ts)

Return the text of the style ts.

Parameters:
tsthe style to get it's text.
Returns:
the text of the style or null on error.
Since :
2.3

Creates a new textblock style.

Returns:
The new textblock style.
Since :
2.3
Examples:
ecore_imf_example.c, and evas-images2.c.
void evas_textblock_style_set ( Evas_Textblock_Style ts,
const char *  text 
)

Sets the style ts to the style passed as text by text. Expected a string consisting of many (or none) tag='format' pairs.

Parameters:
tsthe style to set.
textthe text to parse - NOT NULL.
Returns:
Returns no value.
Since :
2.3
Examples:
ecore_imf_example.c, and evas-images2.c.