From 98dad1a52b0c75c18191b069c87ebb6f493e74ca Mon Sep 17 00:00:00 2001 From: Daniel Hirt Date: Fri, 9 Jun 2017 17:55:40 +0300 Subject: [PATCH] Canvas layout: port 'part_text' to Efl.Text.* The following API is now supported with efl_part: - Efl.Text.text { set; get; } - Efl.Text.Cursor.cursor { get; } - Efl.Text.Cursor.cursor_paragraph_first; - Efl.Text.Cursor.cursor_paragraph_last; - Efl.Text.Cursor.cursor_position { set; get; } - Efl.Text.Cursor.cursor_coord_set; - Efl.Text.Cursor.cursor_line_char_first; - Efl.Text.Cursor.cursor_line_char_last; - Efl.Text.Cursor.cursor_char_next; - Efl.Text.Cursor.cursor_char_prev; - Efl.Text.Cursor.cursor_line_jump_by; - Efl.Text.Cursor.cursor_copy; - Efl.Text.Cursor.cursor_content { get; } - Efl.Text.Cursor.cursor_geometry { get; } - Efl.Text.Cursor.cursor_text_insert; Many of the 'part_text' functionality was moved to legacy, too. See the edje_object.eo to see which ones are still supported. --- src/lib/edje/Edje_Legacy.h | 560 ++++++++++++ src/lib/edje/edje_entry.c | 157 +++- src/lib/edje/edje_legacy.c | 818 ++++++++++++++++++ src/lib/edje/edje_object.eo | 482 ----------- src/lib/edje/edje_part_text.c | 164 ++++ src/lib/edje/edje_private.h | 16 + src/lib/edje/edje_util.c | 644 +------------- .../edje/efl_canvas_layout_internal_text.eo | 17 +- src/lib/elementary/elm_entry.c | 6 +- 9 files changed, 1699 insertions(+), 1165 deletions(-) diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h index 5bdcef4db6..6022363e83 100644 --- a/src/lib/edje/Edje_Legacy.h +++ b/src/lib/edje/Edje_Legacy.h @@ -1375,6 +1375,566 @@ EAPI Eina_Bool edje_object_part_text_set(const Edje_Object *obj, const char *par */ EAPI const char * edje_object_part_text_get(const Edje_Object *obj, const char *part); +/** + * @brief Moves the cursor to the beginning of the text part @ref + * evas_textblock_cursor_paragraph_first + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_begin_set(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the end of the text part. @ref + * evas_textblock_cursor_paragraph_last + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_end_set(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Sets the cursor position to the given value + * + * @param[in] part The part name + * @param[in] cur The cursor to move + * @param[in] pos The position of the cursor + * + * @since 1.1.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_pos_set(Edje_Object *obj, const char * part, Edje_Cursor cur, int pos); + +/** + * @brief Retrieves the current position of the cursor + * + * @param[in] part The part name + * @param[in] cur The cursor to move + * + * @return The position of the cursor + * + * @since 1.1.0 + * + * @ingroup Edje_Object + */ +EAPI int edje_object_part_text_cursor_pos_get(const Edje_Object *obj, const char * part, Edje_Cursor cur); + +/** + * @brief Position the given cursor to a X,Y position. + * + * This is frequently used with the user cursor. + * + * @param[in] part The part containing the object. + * @param[in] cur The cursor to adjust. + * @param[in] x X Coordinate. + * @param[in] y Y Coordinate. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_coord_set(Edje_Object *obj, const char *part, Edje_Cursor cur, int x, int y); + +/** + * @brief Moves the cursor to the beginning of the line. @ref + * evas_textblock_cursor_line_char_first + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_line_begin_set(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the end of the line. @ref + * evas_textblock_cursor_line_char_last + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_line_end_set(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the previous char @ref + * evas_textblock_cursor_char_prev + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_prev(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Advances the cursor to the next cursor position. @ref + * evas_textblock_cursor_char_next + * + * @param[in] part The part name + * @param[in] cur The edje cursor to advance + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_next(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the char above the current cursor position. + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_up(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the char below the current cursor position. + * + * @param[in] part The part name + * @param[in] cur The edje cursor to work on + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_down(Edje_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Copies the cursor to another cursor. + * + * @param[in] part The part name + * @param[in] src The cursor to copy from + * @param[in] dst The cursor to copy to + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_copy(Edje_Object *obj, const char *part, Edje_Cursor src, Edje_Cursor dst); + +/** + * @brief Returns the content (char) at the cursor position. @ref + * evas_textblock_cursor_content_get + * + * You must free the return (if not @c null) after you are done with it. + * + * @param[in] part The part name + * @param[in] cur The cursor to use + * + * @return The character string pointed to (may be a multi-byte utf8 sequence) + * terminated by a null byte. + * + * @ingroup Edje_Object + */ +EAPI char *edje_object_part_text_cursor_content_get(const Edje_Object *obj, const char * part, Edje_Cursor cur); + +/** + * @brief Returns the cursor geometry of the part relative to the edje object. + * + * @param[in] part The part name + * @param[out] x Cursor X position + * @param[out] y Cursor Y position + * @param[out] w Cursor width + * @param[out] h Cursor height + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_cursor_geometry_get(const Edje_Object *obj, const char * part, int *x, int *y, int *w, int *h); + +/** + * @brief Hides visible last character for password mode. + * + * @param[in] part The part name + * + * @return @c true if the visible character is hidden. @c false if there is no + * visible character or the object is not set for password mode. + * + * @since 1.18.0 + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_hide_visible_password(Edje_Object *obj, const char *part); + +/** + * @brief Returns whether the cursor points to a format. @ref + * evas_textblock_cursor_is_format + * + * @param[in] part The part name + * @param[in] cur The cursor to adjust. + * + * @return @c true if the cursor points to a format, @c false otherwise. + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_is_format_get(Edje_Object *obj, const char * part, Edje_Cursor cur); + +/** + * @brief Returns @c true if the cursor points to a visible format For example + * \\t, \\n, item and etc. @ref evas_textblock_cursor_format_is_visible_get + * + * @param[in] part The part name + * @param[in] cur The cursor to adjust. + * + * @return @c true if the cursor points to a visible format, @c false + * otherwise. + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_cursor_is_visible_format_get(Edje_Object *obj, const char * part, Edje_Cursor cur); + +/** + * @brief Returns a list of Evas_Textblock_Rectangle anchor rectangles. + * + * This function return a list of Evas_Textblock_Rectangle anchor rectangles. + * + * @param[in] part The part name + * @param[in] anchor The anchor name + * + * @return The list of anchor rects (const Evas_Textblock_Rectangle *), do not + * modify! Geometry is relative to entry part. + * + * @ingroup Edje_Object + */ +EAPI const Eina_List *edje_object_part_text_anchor_geometry_get(Edje_Object *obj, const char * part, const char * anchor); + +/** + * @brief Returns a list of char anchor names. + * + * This function returns a list of char anchor names. + * + * @param[in] part The part name + * + * @return The list of anchors (const char *), do not modify! + * + * @ingroup Edje_Object + */ +EAPI const Eina_List *edje_object_part_text_anchor_list_get(Edje_Object *obj, const char * part); + +/** + * @brief Returns the text of the object part. + * + * This function returns the style associated with the textblock part. + * + * @param[in] part The part name + * + * @return The text string + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI const char *edje_object_part_text_style_user_peek(const Edje_Object *obj, const char *part); + +/** + * @brief Sets the style of the + * + * This function sets the style associated with the textblock part. + * + * @param[in] part The part name + * @param[in] style The style to set (textblock conventions). + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_style_user_push(Edje_Object *obj, const char *part, const char *style); + +/** + * @brief Deletes the top style form the user style stack. + * + * @param[in] part The part name + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_style_user_pop(Edje_Object *obj, const char *part); + +/** + * @brief Returns item geometry. + * + * This function return a list of Evas_Textblock_Rectangle item rectangles. + * + * @param[in] part The part name + * @param[in] item The item name + * @param[out] cx Item x return (relative to entry part) + * @param[out] cy Item y return (relative to entry part) + * @param[out] cw Item width return + * @param[out] ch Item height return + * + * @return $1 if item exists, $0 if not + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_item_geometry_get(const Edje_Object *obj, const char * part, const char * item, int *cx, int *cy, int *cw, int *ch); + +/** + * @brief Returns a list of char item names. + * + * This function returns a list of char item names. + * + * @param[in] part The part name + * + * @return The list of items (const char *), do not modify! + * + * @ingroup Edje_Object + */ +EAPI const Eina_List *edje_object_part_text_item_list_get(const Edje_Object *obj, const char * part); + +/** + * @brief Adds a filter function for newly inserted text. + * + * Whenever text is inserted (not the same as set) into the given part, the + * list of filter functions will be called to decide if and how the new text + * will be accepted. There are three types of filters, EDJE_TEXT_FILTER_TEXT, + * EDJE_TEXT_FILTER_FORMAT and EDJE_TEXT_FILTER_MARKUP. The text parameter in + * the func filter can be modified by the user and it's up to him to free the + * one passed if he's to change the pointer. If doing so, the newly set text + * should be malloc'ed, as once all the filters are called Edje will free it. + * If the text is to be rejected, freeing it and setting the pointer to @c null + * will make Edje break out of the filter cycle and reject the inserted text. + * + * @warning This function will be deprecated because of difficulty in use. The + * type(format, text, or markup) of text should be always checked in the filter + * function for correct filtering. Please use + * edje_object_text_markup_filter_callback_add() instead. There is no need to + * check the type of text in the filter function because the text is always + * markup. Warning: If you use this function with + * edje_object_text_markup_filter_callback_add() together, all + * Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions will be + * executed, and then filtered text will be inserted. + * + * See also @ref edje_object_text_insert_filter_callback_del, + * @ref edje_object_text_insert_filter_callback_del_full and + * @ref edje_object_text_markup_filter_callback_add + * + * @param[in] part The part name + * @param[in] func The callback function that will act as filter + * @param[in] data User provided data to pass to the filter function + * + * @ingroup Edje_Object + */ +EAPI void edje_object_text_insert_filter_callback_add(Edje_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); + +/** + * @brief Deletes a function from the filter list. + * + * Delete the given func filter from the list in part. Returns the user data + * pointer given when added. + * + * See also @ref edje_object_text_insert_filter_callback_add and + * @ref edje_object_text_insert_filter_callback_del_full + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * + * @return The user data pointer if successful, or @c null otherwise + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_insert_filter_callback_del(Edje_Object *obj, const char *part, Edje_Text_Filter_Cb func); + +/** + * @brief Deletes a function and matching user data from the filter list. + * + * Delete the given func filter and data user data from the list in part. + * Returns the user data pointer given when added. + * + * See also @ref edje_object_text_insert_filter_callback_add and + * @ref edje_object_text_insert_filter_callback_del + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * @param[in] data The data passed to the callback function + * + * @return The same data pointer if successful, or @c null otherwise + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_insert_filter_callback_del_full(Edje_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); + +/** + * @brief Adds a markup filter function for newly inserted text. + * + * Whenever text is inserted (not the same as set) into the given part, the + * list of markup filter functions will be called to decide if and how the new + * text will be accepted. The text parameter in the func filter is always + * markup. It can be modified by the user and it's up to him to free the one + * passed if he's to change the pointer. If doing so, the newly set text should + * be malloc'ed, as once all the filters are called Edje will free it. If the + * text is to be rejected, freeing it and setting the pointer to @c null will + * make Edje break out of the filter cycle and reject the inserted text. This + * function is different from edje_object_text_insert_filter_callback_add() in + * that the text parameter in the fucn filter is always markup. + * + * @warning If you use this function with + * edje_object_text_insert_filter_callback_add() togehter, all + * Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions will be + * executed, and then filtered text will be inserted. + * + * See also @ref edje_object_text_markup_filter_callback_del, + * @ref edje_object_text_markup_filter_callback_del_full and + * @ref edje_object_text_insert_filter_callback_add + * + * @param[in] part The part name + * @param[in] func The callback function that will act as markup filter + * @param[in] data User provided data to pass to the filter function + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_text_markup_filter_callback_add(Edje_Object *obj, const char *part, Edje_Markup_Filter_Cb func, void *data); + +/** + * @brief Deletes a function from the markup filter list. + * + * Delete the given func filter from the list in part. Returns the user data + * pointer given when added. + * + * See also @ref edje_object_text_markup_filter_callback_add and + * @ref edje_object_text_markup_filter_callback_del_full + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * + * @return The user data pointer if successful, or @c null otherwise + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_markup_filter_callback_del(Edje_Object *obj, const char *part, Edje_Markup_Filter_Cb func); + +/** + * @brief Deletes a function and matching user data from the markup filter + * list. + * + * Delete the given func filter and data user data from the list in part. + * Returns the user data pointer given when added. + * + * See also @ref edje_object_text_markup_filter_callback_add and + * @ref edje_object_text_markup_filter_callback_del + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * @param[in] data The data passed to the callback function + * + * @return The same data pointer if successful, or @c null otherwise + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_markup_filter_callback_del_full(Edje_Object *obj, const char *part, Edje_Markup_Filter_Cb func, void *data); + +/** + * @brief This function inserts text as if the user has inserted it. + * + * This means it actually registers as a change and emits signals, triggers + * callbacks as appropriate. + * + * @param[in] part The part name + * @param[in] text The text string + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_user_insert(const Edje_Object *obj, const char *part, const char *text); + +/** + * @brief Inserts text for an object part. + * + * This function inserts the text for an object part at the end; It does not + * move the cursor. + * + * @param[in] part The part name + * @param[in] text The text string + * + * @since 1.1 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_append(Edje_Object *obj, const char *part, const char *text); + +/** + * @brief Sets the text for an object part, but converts HTML escapes to UTF8 + * + * This converts the given string text to UTF8 assuming it contains HTML style + * escapes like "&" and "©" etc. IF the part is of type TEXT, as + * opposed to TEXTBLOCK. + * + * @param[in] part The part name + * @param[in] text The text string + * + * @return @c true on success, @c false otherwise + * + * @since 1.2 + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_escaped_set(Edje_Object *obj, const char *part, const char *text); + +/** + * @brief Sets the raw (non escaped) text for an object part. + * + * This function will not do escape for you if it is a TEXTBLOCK part, that is, + * if text contain tags, these tags will not be interpreted/parsed by + * TEXTBLOCK. + * + * See also @ref edje_object_part_text_unescaped_get(). + * + * @param[in] part The part name + * @param[in] text_to_escape The text string + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_unescaped_set(Edje_Object *obj, const char * part, const char *text_to_escape); + +/** + * @brief Returns the text of the object part, without escaping. + * + * This function is the counterpart of + * @ref edje_object_part_text_unescaped_set(). Please notice that the result is + * newly allocated memory and should be released with free() when done. + * + * See also @ref edje_object_part_text_unescaped_set(). + * + * @param[in] part The part name + * + * @return The text string + * + * @ingroup Edje_Object + */ +EAPI char *edje_object_part_text_unescaped_get(const Edje_Object *obj, const char * part); + +/** + * @brief Inserts text for an object part. + * + * This function inserts the text for an object part just before the cursor + * position. + * + * @param[in] part The part name + * @param[in] text The text string + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_insert(Edje_Object *obj, const char *part, const char *text); + /** * @} */ diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index 74d93c8e68..7a28d25288 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -4006,10 +4006,9 @@ _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur) } Eina_Bool -_edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_text_cursor_next(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); if ((rp->type != EDJE_RP_TYPE_TEXT) || (!rp->typedata.text)) return EINA_FALSE; @@ -4033,10 +4032,17 @@ _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) } Eina_Bool -_edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + return _edje_text_cursor_next(rp, c); +} + + +Eina_Bool +_edje_text_cursor_prev(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); if ((rp->type != EDJE_RP_TYPE_TEXT) || (!rp->typedata.text)) return EINA_FALSE; @@ -4062,10 +4068,16 @@ ok: } Eina_Bool -_edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + return _edje_text_cursor_prev(rp, c); +} + +Eina_Bool +_edje_text_cursor_up(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; int ln; @@ -4096,10 +4108,16 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) } Eina_Bool -_edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + return _edje_text_cursor_up(rp, c); +} + +Eina_Bool +_edje_text_cursor_down(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; int ln; @@ -4128,11 +4146,17 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) return EINA_TRUE; } +Eina_Bool +_edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + return _edje_text_cursor_down(rp, c); +} + void -_edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_text_cursor_begin(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); int old_cur_pos; if ((rp->type != EDJE_RP_TYPE_TEXT) || @@ -4157,10 +4181,17 @@ _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) } void -_edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + _edje_text_cursor_begin(rp, c); + +} + +void +_edje_text_cursor_end(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); int old_cur_pos; if ((rp->type != EDJE_RP_TYPE_TEXT) || @@ -4184,22 +4215,22 @@ _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) _edje_emit(en->ed, "cursor,changed", rp->part->name); _edje_entry_real_part_configure(en->ed, rp); } +void +_edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + _edje_text_cursor_end(rp, c); +} void -_edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) +_edje_text_cursor_copy(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *d, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c; - Evas_Textblock_Cursor *d; if ((rp->type != EDJE_RP_TYPE_TEXT) || (!rp->typedata.text)) return; en = rp->typedata.text->entry_data; if (!en) return; - c = _cursor_get(rp, cur); - if (!c) return; - d = _cursor_get(rp, dst); - if (!d) return; evas_textblock_cursor_copy(c, d); _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data); @@ -4210,10 +4241,21 @@ _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) } void -_edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) +{ + Evas_Textblock_Cursor *c; + Evas_Textblock_Cursor *d; + c = _cursor_get(rp, cur); + if (!c) return; + d = _cursor_get(rp, dst); + if (!d) return; + _edje_text_cursor_copy(rp, d, c); +} + +void +_edje_text_cursor_line_begin(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); int old_cur_pos; if ((rp->type != EDJE_RP_TYPE_TEXT) || @@ -4238,10 +4280,16 @@ _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) } void -_edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur) +_edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + _edje_text_cursor_line_begin(rp, c); +} + +void +_edje_text_cursor_line_end(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c) { Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); int old_cur_pos; if ((rp->type != EDJE_RP_TYPE_TEXT) || @@ -4264,15 +4312,20 @@ _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur) _edje_entry_real_part_configure(en->ed, rp); } -Eina_Bool -_edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, - Evas_Coord x, Evas_Coord y) +void +_edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur) { Evas_Textblock_Cursor *c = _cursor_get(rp, cur); - if (!c) return EINA_FALSE; + _edje_text_cursor_line_end(rp, c); +} + +Eina_Bool +_edje_text_cursor_coord_set(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c, + Evas_Coord x, Evas_Coord y) +{ Entry *en = rp->typedata.text->entry_data; - if ((cur == EDJE_CURSOR_SELECTION_BEGIN) || - (cur == EDJE_CURSOR_SELECTION_END)) + if ((c == _cursor_get(rp, EDJE_CURSOR_SELECTION_BEGIN)) || + (c == _cursor_get(rp, EDJE_CURSOR_SELECTION_END))) { if (en->have_selection) { @@ -4287,6 +4340,15 @@ _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, return evas_textblock_cursor_char_coord_set(c, x, y); } +Eina_Bool +_edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, + Evas_Coord x, Evas_Coord y) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return EINA_FALSE; + return _edje_text_cursor_coord_set(rp, c, x, y); +} + Eina_Bool _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur) { @@ -4304,6 +4366,12 @@ _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur) return evas_textblock_cursor_format_is_visible_get(c); } +char * +_edje_text_cursor_content_get(Edje_Real_Part *rp EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *c) +{ + return evas_textblock_cursor_content_get(c); +} + char * _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur) { @@ -4311,18 +4379,15 @@ _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur) if (!c) return NULL; - return evas_textblock_cursor_content_get(c); + return _edje_text_cursor_content_get(rp, c); } void -_edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) +_edje_text_cursor_pos_set(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *c, int pos) { - Entry *en; - Evas_Textblock_Cursor *c = _cursor_get(rp, cur); - if ((rp->type != EDJE_RP_TYPE_TEXT) || (!rp->typedata.text)) return; - en = rp->typedata.text->entry_data; + Entry *en = rp->typedata.text->entry_data; if (!en) return; if (!c) return; /* Abort if cursor position didn't really change */ @@ -4338,12 +4403,26 @@ _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) _edje_entry_real_part_configure(en->ed, rp); } +void +_edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + _edje_text_cursor_pos_set(rp, c, pos); +} + +int +_edje_text_cursor_pos_get(Edje_Real_Part *rp EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *c) +{ + return evas_textblock_cursor_pos_get(c); +} + int _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur) { Evas_Textblock_Cursor *c = _cursor_get(rp, cur); if (!c) return 0; - return evas_textblock_cursor_pos_get(c); + return _edje_text_cursor_pos_get(rp, c); } void @@ -4933,4 +5012,10 @@ _edje_entry_imf_retrieve_selection_cb(void *data, Ecore_IMF_Context *ctx EINA_UN #endif +Evas_Textblock_Cursor * +_edje_text_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + return _cursor_get(rp, cur); +} + /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c index 5a4694d69e..3fcedcec7f 100644 --- a/src/lib/edje/edje_legacy.c +++ b/src/lib/edje/edje_legacy.c @@ -194,3 +194,821 @@ edje_object_part_drag_page(Evas_Object *obj, const char *part, double dx, double { return efl_ui_drag_page_move(efl_part(obj, part), dx, dy); } + +EAPI void +edje_object_part_text_cursor_begin_set(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_paragraph_first(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); +} + +EAPI void +edje_object_part_text_cursor_end_set(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_paragraph_last(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); +} + +EAPI void +edje_object_part_text_cursor_pos_set(Edje_Object *obj, const char * part, Edje_Cursor cur, int pos) +{ + efl_text_cursor_position_set(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur), pos); +} + +EAPI int +edje_object_part_text_cursor_pos_get(const Edje_Object *obj, const char * part, Edje_Cursor cur) +{ + return efl_text_cursor_position_get(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); + +} + +EAPI Eina_Bool +edje_object_part_text_cursor_coord_set(Edje_Object *obj, const char *part, Edje_Cursor cur, int x, int y) +{ + efl_text_cursor_coord_set(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur), x, y); + return EINA_TRUE; +} + +EAPI void +edje_object_part_text_cursor_line_begin_set(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_line_char_first(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); +} + +EAPI void +edje_object_part_text_cursor_line_end_set(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_line_char_last(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); +} + +EAPI Eina_Bool +edje_object_part_text_cursor_prev(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_char_prev(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_next(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_char_next(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur)); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_down(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_line_jump_by(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur), 1); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_up(Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + efl_text_cursor_line_jump_by(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) cur), -1); + return EINA_TRUE; +} + +EAPI void +edje_object_part_text_cursor_copy(Edje_Object *obj, const char *part, Edje_Cursor cur, Edje_Cursor dst) +{ + efl_text_cursor_copy(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), (int) dst), + efl_text_cursor_get(efl_part(obj, part), (int) cur) + ); +} + +EAPI char * +edje_object_part_text_cursor_content_get(const Edje_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_content_get(rp, cur); + } + + return NULL; +} + +EAPI void +edje_object_part_text_cursor_geometry_get(const Edje_Object *obj, const char * part, int *x, int *y, int *w, int *h) +{ + efl_text_cursor_geometry_get(efl_part(obj, part), + efl_text_cursor_get(efl_part(obj, part), EFL_TEXT_CURSOR_GET_MAIN), + EFL_TEXT_CURSOR_TYPE_BEFORE, + x, y, w, h, NULL, NULL, NULL, NULL + ); +} + +EAPI Eina_Bool +edje_object_part_text_hide_visible_password(Eo *obj, const char *part) +{ + Edje_Real_Part *rp; + Eina_Bool int_ret = EINA_FALSE; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return EINA_FALSE; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) + { + return EINA_FALSE; + } + + if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) + int_ret = _edje_entry_hide_visible_password(ed, rp); + + return int_ret; +} + +EOLIAN Eina_Bool +edje_object_part_text_cursor_is_format_get(Eo *obj, const char *part, Edje_Cursor cur) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_is_format_get(rp, cur); + } + return EINA_FALSE; +} + +EOLIAN Eina_Bool +edje_object_part_text_cursor_is_visible_format_get(Eo *obj EINA_UNUSED, const char *part, Edje_Cursor cur) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_is_visible_format_get(rp, cur); + } + + return EINA_FALSE; +} + +EAPI const Eina_List * +edje_object_part_text_anchor_list_get(Eo *obj EINA_UNUSED, const char *part) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_anchors_list(rp); + + return NULL; +} + +EAPI const Eina_List * +edje_object_part_text_anchor_geometry_get(Eo *obj EINA_UNUSED, const char *part, const char *anchor) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_anchor_geometry_get(rp, anchor); + + return NULL; +} + +EAPI void +edje_object_part_text_style_user_push(Eo *obj EINA_UNUSED, const char *part, const char *style) +{ + Edje_Real_Part *rp; + Evas_Textblock_Style *ts; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part) || (!style)) return; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return; + if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return; + + ts = evas_textblock_style_new(); + evas_textblock_style_set(ts, style); + evas_object_textblock_style_user_push(rp->object, ts); + evas_textblock_style_free(ts); + ed->recalc_hints = EINA_TRUE; +#ifdef EDJE_CALC_CACHE + rp->invalidate = EINA_TRUE; +#endif + _edje_recalc(ed); +} + +EAPI void +edje_object_part_text_style_user_pop(Eo *obj EINA_UNUSED, const char *part) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return; + if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return; + + evas_object_textblock_style_user_pop(rp->object); + ed->recalc_hints = EINA_TRUE; +#ifdef EDJE_CALC_CACHE + rp->invalidate = EINA_TRUE; +#endif + _edje_recalc(ed); +} + +EAPI const char * +edje_object_part_text_style_user_peek(const Eo *obj EINA_UNUSED, const char *part) +{ + Edje_Real_Part *rp; + const Evas_Textblock_Style *ts; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return NULL; + if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return NULL; + + ts = evas_object_textblock_style_user_peek(rp->object); + if (ts) + return evas_textblock_style_get(ts); + + return NULL; +} + +EAPI const Eina_List * +edje_object_part_text_item_list_get(const Eo *obj EINA_UNUSED, const char *part) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_items_list(rp); + + return NULL; +} + +EAPI Eina_Bool +edje_object_part_text_item_geometry_get(const Eo *obj EINA_UNUSED, const char *part, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_item_geometry_get(rp, item, cx, cy, cw, ch); + } + + return EINA_FALSE; +} + +EAPI void +edje_object_text_insert_filter_callback_add(Eo *obj EINA_UNUSED, const char *part, Edje_Text_Filter_Cb func, void *data) +{ + Edje_Text_Insert_Filter_Callback *cb; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback)); + cb->part = eina_stringshare_add(part); + cb->func = func; + cb->data = (void *)data; + ed->text_insert_filter_callbacks = + eina_list_append(ed->text_insert_filter_callbacks, cb); +} + +EAPI void * +edje_object_text_insert_filter_callback_del(Eo *obj EINA_UNUSED, const char *part, Edje_Text_Filter_Cb func) +{ + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func)) + { + void *data = cb->data; + ed->text_insert_filter_callbacks = + eina_list_remove_list(ed->text_insert_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return data; + } + } + + return NULL; +} + +EAPI void * +edje_object_text_insert_filter_callback_del_full(Eo *obj EINA_UNUSED, const char *part, Edje_Text_Filter_Cb func, void *data) +{ + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func) && + (cb->data == data)) + { + void *tmp = cb->data; + ed->text_insert_filter_callbacks = + eina_list_remove_list(ed->text_insert_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return tmp; + } + } + + return NULL; +} + +EAPI void +edje_object_text_markup_filter_callback_add(Eo *obj EINA_UNUSED, const char *part, Edje_Markup_Filter_Cb func, void *data) +{ + Edje_Markup_Filter_Callback *cb; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + cb = calloc(1, sizeof(Edje_Markup_Filter_Callback)); + cb->part = eina_stringshare_add(part); + cb->func = func; + cb->data = (void *)data; + ed->markup_filter_callbacks = + eina_list_append(ed->markup_filter_callbacks, cb); +} + +EAPI void * +edje_object_text_markup_filter_callback_del(Eo *obj EINA_UNUSED, const char *part, Edje_Markup_Filter_Cb func) +{ + Edje_Markup_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func)) + { + void *data = cb->data; + ed->markup_filter_callbacks = + eina_list_remove_list(ed->markup_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return data; + } + } + + return NULL; +} + +EAPI void * +edje_object_text_markup_filter_callback_del_full(Eo *obj EINA_UNUSED, const char *part, Edje_Markup_Filter_Cb func, void *data) +{ + Edje_Markup_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func) && + (cb->data == data)) + { + void *tmp = cb->data; + ed->markup_filter_callbacks = + eina_list_remove_list(ed->markup_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return tmp; + } + } + + return NULL; +} + +EAPI void +edje_object_part_text_user_insert(const Eo *obj, const char *part, const char *text) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_user_insert(rp, text); +} + +Eina_Bool +_edje_object_part_text_raw_append(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) +{ + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_TRUE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_text_markup_append(rp, text); + else if (text) + { + if (rp->typedata.text->text) + { + char *new = NULL; + int len_added = strlen(text); + int len_old = strlen(rp->typedata.text->text); + new = malloc(len_old + len_added + 1); + memcpy(new, rp->typedata.text->text, len_old); + memcpy(new + len_old, text, len_added); + new[len_old + len_added] = '\0'; + eina_stringshare_replace(&rp->typedata.text->text, new); + free(new); + } + else + { + eina_stringshare_replace(&rp->typedata.text->text, text); + } + } + ed->dirty = EINA_TRUE; + ed->recalc_call = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = EINA_TRUE; +#endif + _edje_recalc(ed); + if (ed->text_change.func) + ed->text_change.func(ed->text_change.data, obj, part); + return EINA_TRUE; +} + +EAPI void +edje_object_part_text_append(Eo *obj, const char *part, const char *text) +{ + Edje_Real_Part *rp; + + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return; + if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; + _edje_object_part_text_raw_append(ed, obj, rp, part, text); + ed->dirty = EINA_TRUE; + ed->recalc_call = EINA_TRUE; + ed->recalc_hints = EINA_TRUE; +#ifdef EDJE_CALC_CACHE + rp->invalidate = EINA_TRUE; +#endif + _edje_recalc(ed); + if (ed->text_change.func) + ed->text_change.func(ed->text_change.data, obj, part); +} + +EAPI Eina_Bool +edje_object_part_text_escaped_set(Eo *obj, const char *part, const char *text) +{ + Edje_Real_Part *rp; + Eina_Bool int_ret; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK && + rp->part->type != EDJE_PART_TYPE_TEXT) + return EINA_FALSE; + if ((rp->part->type == EDJE_PART_TYPE_TEXT) && (text)) + { + Eina_Strbuf *sbuf; + char *esc_start = NULL, *esc_end = NULL; + char *s, *p; + + sbuf = eina_strbuf_new(); + p = (char *)text; + s = p; + for (;; ) + { + if ((*p == 0) || (esc_end) || (esc_start)) + { + if (esc_end) + { + const char *escape; + + escape = evas_textblock_escape_string_range_get + (esc_start, esc_end + 1); + if (escape) eina_strbuf_append(sbuf, escape); + esc_start = esc_end = NULL; + } + else if (*p == 0) + { + if (!s) s = esc_start; /* This would happen when there is & that isn't escaped */ + eina_strbuf_append_length(sbuf, s, p - s); + s = NULL; + } + if (*p == 0) + break; + } + + if (*p == '&') + { + if (!s) s = esc_start; /* This would happen when there is & that isn't escaped */ + esc_start = p; + esc_end = NULL; + eina_strbuf_append_length(sbuf, s, p - s); + s = NULL; + } + else if (*p == ';') + { + if (esc_start) + { + esc_end = p; + s = p + 1; + } + } + p++; + } + int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, eina_strbuf_string_get(sbuf)); + _edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_ESCAPED); + eina_strbuf_free(sbuf); + return int_ret; + } + int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text); + _edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_ESCAPED); + + return int_ret; +} + +char * +_edje_text_escape(const char *text) +{ + Eina_Strbuf *txt; + char *ret; + const char *text_end; + size_t text_len; + + if (!text) return NULL; + + txt = eina_strbuf_new(); + text_len = strlen(text); + + text_end = text + text_len; + while (text < text_end) + { + int advance; + const char *escaped = evas_textblock_string_escape_get(text, &advance); + if (!escaped) + { + eina_strbuf_append_char(txt, text[0]); + advance = 1; + } + else + eina_strbuf_append(txt, escaped); + + text += advance; + } + + ret = eina_strbuf_string_steal(txt); + eina_strbuf_free(txt); + return ret; +} + +char * +_edje_text_unescape(const char *text) +{ + Eina_Strbuf *txt; + char *ret; + const char *text_end, *last, *escape_start; + size_t text_len; + + if (!text) return NULL; + + txt = eina_strbuf_new(); + text_len = strlen(text); + + text_end = text + text_len; + last = text; + escape_start = NULL; + for (; text < text_end; text++) + { + if (*text == '&') + { + size_t len; + const char *str; + + if (last) + { + len = text - last; + str = last; + } + else + { + len = text - escape_start; + str = escape_start; + } + + if (len > 0) + eina_strbuf_append_n(txt, str, len); + + escape_start = text; + last = NULL; + } + else if ((*text == ';') && (escape_start)) + { + size_t len; + const char *str = evas_textblock_escape_string_range_get(escape_start, text); + + if (str) + len = strlen(str); + else + { + str = escape_start; + len = text + 1 - escape_start; + } + + eina_strbuf_append_n(txt, str, len); + + escape_start = NULL; + last = text + 1; + } + } + + if (!last && escape_start) + last = escape_start; + + if (last && (text > last)) + { + size_t len = text - last; + eina_strbuf_append_n(txt, last, len); + } + + ret = eina_strbuf_string_steal(txt); + eina_strbuf_free(txt); + return ret; +} + +EAPI Eina_Bool +edje_object_part_text_unescaped_set(Eo *obj, const char *part, const char *text_to_escape) +{ + Edje_Real_Part *rp; + Eina_Bool int_ret = EINA_FALSE; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + if (rp->part->type == EDJE_PART_TYPE_TEXT) + int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text_to_escape); + else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + char *text = _edje_text_escape(text_to_escape); + + int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text); + free(text); + } + _edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_UNESCAPED); + + return int_ret; +} + +EAPI char * +edje_object_part_text_unescaped_get(const Eo *obj EINA_UNUSED, const char *part) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return NULL; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + const char *t = _edje_entry_text_get(rp); + return _edje_text_unescape(t); + } + else + { + if (rp->part->type == EDJE_PART_TYPE_TEXT) + { + return strdup(rp->typedata.text->text); + } + if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + const char *t = evas_object_textblock_text_markup_get(rp->object); + return _edje_text_unescape(t); + } + } + + return NULL; +} + +void +_edje_object_part_text_insert(Edje *ed, Edje_Real_Part *rp, const char *text) +{ + if (!rp) return; + if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; + if (rp->part->entry_mode <= EDJE_ENTRY_EDIT_MODE_NONE) return; + _edje_entry_text_markup_insert(rp, text); + ed->dirty = EINA_TRUE; + ed->recalc_call = EINA_TRUE; + ed->recalc_hints = EINA_TRUE; +#ifdef EDJE_CALC_CACHE + rp->invalidate = EINA_TRUE; +#endif + _edje_recalc(ed); +} + +EAPI void +edje_object_part_text_insert(Eo *obj, const char *part, const char *text) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(&ed, part); + _edje_object_part_text_insert(ed, rp, text); + if (ed->text_change.func) + ed->text_change.func(ed->text_change.data, obj, part); +} diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index 6a0860b371..62e6b3b04e 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -780,88 +780,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, data: void_ptr; [[The data associated to the callback function.]] } } - @property part_text_escaped { - set { - [[Sets the text for an object part, but converts HTML escapes to UTF8 - - This converts the given string text to UTF8 assuming it contains HTML - style escapes like "&" and "©" etc. IF the part is of type TEXT, - as opposed to TEXTBLOCK. - - @since 1.2]] - return: bool; [[$true on success, $false otherwise]] - } - values { - part: string; [[The part name]] - text: string; [[The text string]] - } - } - @property part_text_unescaped { - set { - [[Sets the raw (non escaped) text for an object part. - - This function will not do escape for you if it is a TEXTBLOCK part, that is, - if text contain tags, these tags will not be interpreted/parsed by TEXTBLOCK. - - See also @.part_text_unescaped.get().]] - return: bool; [[$true on success, $false otherwise]] - values { - text_to_escape: string; [[The text string]] - } - } - get { - [[Returns the text of the object part, without escaping. - - This function is the counterpart of - @.part_text_unescaped.set(). Please notice that the - result is newly allocated memory and should be released with free() - when done. - - See also @.part_text_unescaped.set().]] - values { - text_to_escape: own(ptr(char)); [[The text string]] - } - } - keys { - part: string; [[The part name]] - } - } - part_text_append { - [[Inserts text for an object part. - - This function inserts the text for an object part at the end; It does not - move the cursor. - - @since 1.1]] - - params { - @in part: string; [[The part name]] - @in text: string; [[The text string]] - } - } - part_text_insert { - [[Inserts text for an object part. - - This function inserts the text for an object part just before the - cursor position.]] - - params { - @in part: string; [[The part name]] - @in text: string; [[The text string]] - } - } - part_text_user_insert @const { - [[This function inserts text as if the user has inserted it. - - This means it actually registers as a change and emits signals, triggers - callbacks as appropriate. - - @since 1.2.0]] - params { - @in part: string; [[The part name]] - @in text: string; [[The text string]] - } - } @property part_text_autocapital_type { set { [[Sets the autocapitalization type on the immodule. @@ -898,187 +816,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, prediction: bool; [[If $true, the prediction feature is allowed.]] } } - part_text_hide_visible_password { - [[Hides visible last character for password mode. - - @since 1.18.0]] - params { - @in part: string; [[The part name]] - } - return: bool; [[$true if the visible character is hidden. $false if there is no visible character or the object is not set for password mode.]] - } - @property part_text_cursor_begin { - set { - [[Moves the cursor to the beginning of the text part - \@ref evas_textblock_cursor_paragraph_first]] - } - values { - part: string; [[The part name]] - cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - @property part_text_cursor_end { - set { - [[Moves the cursor to the end of the text part. - \@ref evas_textblock_cursor_paragraph_last]] - } - values { - part: string; [[The part name]] - cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - @property part_text_cursor_line_begin { - set { - [[Moves the cursor to the beginning of the line. - \@ref evas_textblock_cursor_line_char_first]] - } - values { - part: string; [[The part name]] - cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - @property part_text_cursor_line_end { - set { - [[Moves the cursor to the end of the line. - \@ref evas_textblock_cursor_line_char_last]] - } - values { - part: string; [[The part name]] - cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - part_text_cursor_prev { - [[Moves the cursor to the previous char - \@ref evas_textblock_cursor_char_prev]] - - return: bool; [[$true on success, $false otherwise]] - params { - @in part: string; [[The part name]] - @in cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - part_text_cursor_next { - [[Advances the cursor to the next cursor position. - \@ref evas_textblock_cursor_char_next]] - - return: bool; [[$true on success, $false otherwise]] - params { - @in part: string; [[The part name]] - @in cur: Edje.Cursor; [[The edje cursor to advance]] - } - } - part_text_cursor_up { - [[Moves the cursor to the char above the current cursor position.]] - - return: bool; [[$true on success, $false otherwise]] - params { - @in part: string; [[The part name]] - @in cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - part_text_cursor_down { - [[Moves the cursor to the char below the current cursor position.]] - - return: bool; [[$true on success, $false otherwise]] - params { - @in part: string; [[The part name]] - @in cur: Edje.Cursor; [[The edje cursor to work on]] - } - } - @property part_text_cursor_geometry { - get { - [[Returns the cursor geometry of the part relative to the edje - object.]] - } - keys { - part: string; [[The part name]] - } - values { - x: int; [[Cursor X position]] - y: int; [[Cursor Y position]] - w: int; [[Cursor width]] - h: int; [[Cursor height]] - } - } - @property part_text_cursor_coord { - set { - [[Position the given cursor to a X,Y position. - - This is frequently used with the user cursor.]] - - return: bool; [[$true on success, $false otherwise]] - } - values { - part: string; [[The part containing the object.]] - cur: Edje.Cursor; [[The cursor to adjust.]] - x: int; [[X Coordinate.]] - y: int; [[Y Coordinate.]] - } - } - @property part_text_cursor_pos { - set { - [[Sets the cursor position to the given value - - @since 1.1.0]] - } - get { - [[Retrieves the current position of the cursor - - @since 1.1.0]] - } - keys { - part: string; [[The part name]] - cur: Edje.Cursor; [[The cursor to move]] - } - values { - pos: int; [[The position of the cursor]] - } - } - part_text_cursor_copy { - [[Copies the cursor to another cursor.]] - - params { - @in part: string; [[The part name]] - @in src: Edje.Cursor; [[The cursor to copy from]] - @in dst: Edje.Cursor; [[The cursor to copy to]] - } - } - @property part_text_cursor_content { - get { - [[Returns the content (char) at the cursor position. - \@ref evas_textblock_cursor_content_get - - You must free the return (if not $null) after you are done with it.]] - return: own(ptr(char)); [[The character string pointed to (may be a multi-byte utf8 sequence) terminated by a null byte.]] - } - keys { - part: string; [[The part name]] - cur: Edje.Cursor; [[The cursor to use]] - } - } - @property part_text_cursor_is_format { - get { - [[Returns whether the cursor points to a format. - \@ref evas_textblock_cursor_is_format]] - return: bool; [[$true if the cursor points to a format, $false otherwise.]] - } - keys { - part: string; [[The part name]] - cur: Edje.Cursor; [[The cursor to adjust.]] - } - } - @property part_text_cursor_is_visible_format { - get { - [[Returns $true if the cursor points to a visible format - For example \\t, \\n, item and etc. - \@ref evas_textblock_cursor_format_is_visible_get]] - return: bool; [[$true if the cursor points to a visible format, $false otherwise.]] - } - keys { - part: string; [[The part name]] - cur: Edje.Cursor; [[The cursor to adjust.]] - } - } @property item_provider { set { [[Sets the function that provides item objects for named items in an edje entry text @@ -1179,38 +916,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, @in part: string; [[The part name]] } } - part_text_style_user_peek @const { - [[Returns the text of the object part. - - This function returns the style associated with the textblock part. - - @since 1.2.0]] - return: string; [[The text string]] - params { - @in part: string; [[The part name]] - } - } - part_text_style_user_push { - [[Sets the style of the - - This function sets the style associated with the textblock part. - - @since 1.2.0]] - - params { - @in part: string; [[The part name]] - @in style: string; [[The style to set (textblock conventions).]] - } - } - part_text_style_user_pop { - [[Deletes the top style form the user style stack. - - @since 1.2.0]] - - params { - @in part: string; [[The part name]] - } - } @property part_text_input_hint { set { [[Sets the input hint which allows input methods to fine-tune their behavior. @@ -1430,193 +1135,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, ondemand: bool; [[If $true, the input panel will be shown in case of only Mouse up event. (Focus event will be ignored.)]] } } - @property part_text_anchor_geometry { - get { - [[Returns a list of Evas_Textblock_Rectangle anchor rectangles. - - This function return a list of Evas_Textblock_Rectangle anchor - rectangles.]] - return: const(list); [[The list of anchor rects (const Evas_Textblock_Rectangle - *), do not modify! Geometry is relative to entry part.]] - } - keys { - part: string; [[The part name]] - anchor: string; [[The anchor name]] - } - } - @property part_text_anchor_list { - get { - [[Returns a list of char anchor names. - - This function returns a list of char anchor names.]] - return: const(list); [[The list of anchors (const char *), do not modify!]] - } - keys { - part: string; [[The part name]] - } - } - text_insert_filter_callback_add { - [[Adds a filter function for newly inserted text. - - Whenever text is inserted (not the same as set) into the given part, - the list of filter functions will be called to decide if and how the new - text will be accepted. - There are three types of filters, EDJE_TEXT_FILTER_TEXT, - EDJE_TEXT_FILTER_FORMAT and EDJE_TEXT_FILTER_MARKUP. - The text parameter in the func filter can be modified by the user and - it's up to him to free the one passed if he's to change the pointer. If - doing so, the newly set text should be malloc'ed, as once all the filters - are called Edje will free it. - If the text is to be rejected, freeing it and setting the pointer to $null - will make Edje break out of the filter cycle and reject the inserted - text. - - Warning: This function will be deprecated because of difficulty in use. - The type(format, text, or markup) of text should be always - checked in the filter function for correct filtering. - Please use edje_object_text_markup_filter_callback_add() instead. There - is no need to check the type of text in the filter function - because the text is always markup. - Warning: If you use this function with - edje_object_text_markup_filter_callback_add() together, all - Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions - will be executed, and then filtered text will be inserted. - - See also @.text_insert_filter_callback_del, @.text_insert_filter_callback_del_full - and @.text_markup_filter_callback_add]] - - params { - @in part: string; [[The part name]] - @in func: Edje.Text.Filter_Cb; [[The callback function that will act as filter]] - @in data: void_ptr; [[User provided data to pass to the filter function]] - } - } - text_insert_filter_callback_del { - [[Deletes a function from the filter list. - - Delete the given func filter from the list in part. Returns - the user data pointer given when added. - - See also @.text_insert_filter_callback_add and @.text_insert_filter_callback_del_full]] - - return: void_ptr; [[The user data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Text.Filter_Cb; [[The function callback to remove]] - } - } - text_insert_filter_callback_del_full { - [[Deletes a function and matching user data from the filter list. - - Delete the given func filter and data user data from the list - in part. - Returns the user data pointer given when added. - - See also @.text_insert_filter_callback_add and @.text_insert_filter_callback_del]] - - return: void_ptr; [[The same data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Text.Filter_Cb; [[The function callback to remove]] - @in data: void_ptr; [[The data passed to the callback function]] - } - } - text_markup_filter_callback_add { - [[Adds a markup filter function for newly inserted text. - - Whenever text is inserted (not the same as set) into the given part, - the list of markup filter functions will be called to decide if and how - the new text will be accepted. - The text parameter in the func filter is always markup. It can be - modified by the user and it's up to him to free the one passed if he's to - change the pointer. If doing so, the newly set text should be malloc'ed, - as once all the filters are called Edje will free it. - If the text is to be rejected, freeing it and setting the pointer to $null - will make Edje break out of the filter cycle and reject the inserted - text. - This function is different from edje_object_text_insert_filter_callback_add() - in that the text parameter in the fucn filter is always markup. - - Warning: If you use this function with - edje_object_text_insert_filter_callback_add() togehter, all - Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions - will be executed, and then filtered text will be inserted. - - See also @.text_markup_filter_callback_del, @.text_markup_filter_callback_del_full - and @.text_insert_filter_callback_add - - @since 1.2.0]] - - params { - @in part: string; [[The part name]] - @in func: Edje.Markup_Filter_Cb; [[The callback function that will act as markup filter]] - @in data: void_ptr; [[User provided data to pass to the filter function]] - } - } - text_markup_filter_callback_del { - [[Deletes a function from the markup filter list. - - Delete the given func filter from the list in part. Returns - the user data pointer given when added. - - See also @.text_markup_filter_callback_add and @.text_markup_filter_callback_del_full - - @since 1.2.0]] - - return: void_ptr; [[The user data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Markup_Filter_Cb; [[The function callback to remove]] - } - } - text_markup_filter_callback_del_full { - [[Deletes a function and matching user data from the markup filter list. - - Delete the given func filter and data user data from the list - in part. - Returns the user data pointer given when added. - - See also @.text_markup_filter_callback_add and @.text_markup_filter_callback_del - - @since 1.2.0]] - - return: void_ptr; [[The same data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Markup_Filter_Cb; [[The function callback to remove]] - @in data: void_ptr; [[The data passed to the callback function]] - } - } - @property part_text_item_geometry { - get { - [[Returns item geometry. - - This function return a list of Evas_Textblock_Rectangle item - rectangles.]] - return: bool; [[$1 if item exists, $0 if not]] - } - keys { - part: string; [[The part name]] - item: string; [[The item name]] - } - values { - cx: int; [[Item x return (relative to entry part)]] - cy: int; [[Item y return (relative to entry part)]] - cw: int; [[Item width return]] - ch: int; [[Item height return]] - } - } - @property part_text_item_list { - get { - [[Returns a list of char item names. - - This function returns a list of char item names.]] - return: const(list); [[The list of items (const char *), do not modify!]] - } - keys { - part: string; [[The part name]] - } - } /* TEXT PART APIS END ------------------------------------------------ */ @property seat { diff --git a/src/lib/edje/edje_part_text.c b/src/lib/edje/edje_part_text.c index f591b5ae6a..67ed591d85 100644 --- a/src/lib/edje/edje_part_text.c +++ b/src/lib/edje/edje_part_text.c @@ -22,5 +22,169 @@ _efl_canvas_layout_internal_text_efl_text_text_get(Eo *obj, RETURN_VAL(_edje_efl_text_get(obj, pd->ed, pd->part)); } +EOLIAN static Efl_Text_Cursor_Cursor_Data * +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_get(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Get_Type get_type) +{ + PROXY_DATA_GET(obj, pd); + RETURN_VAL(_edje_text_cursor_get(pd->rp, (int) get_type)); +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_paragraph_first(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_begin(pd->rp, cur); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_paragraph_last(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_end(pd->rp, cur); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_position_set(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur, int pos) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_pos_set(pd->rp, cur, pos); + RETURN_VOID; +} + +EOLIAN static int +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_position_get(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + RETURN_VAL(_edje_text_cursor_pos_get(pd->rp, cur)); +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_coord_set(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur, + int x, int y) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_coord_set(pd->rp, cur, x, y); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_line_char_first(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_line_begin(pd->rp, cur); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_line_char_last(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_line_end(pd->rp, cur); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_char_prev(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_prev(pd->rp, cur); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_char_next(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_next(pd->rp, cur); + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_line_jump_by(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur, int by) +{ + PROXY_DATA_GET(obj, pd); + if (by == 1) + { + _edje_text_cursor_down(pd->rp, cur); + } + else if (by == -1) + { + _edje_text_cursor_up(pd->rp, cur); + } + RETURN_VOID; +} + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_copy(Eo *obj, + void *_pd EINA_UNUSED, + Efl_Text_Cursor_Cursor_Data *dst, + const Efl_Text_Cursor_Cursor_Data *cur) +{ + PROXY_DATA_GET(obj, pd); + _edje_text_cursor_copy(pd->rp, (Efl_Text_Cursor_Cursor_Data *) cur, dst); + RETURN_VOID; +} + +EOLIAN static Eina_Unicode +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_content_get(Eo *obj, + void *_pd EINA_UNUSED, + const Efl_Text_Cursor_Cursor_Data *cur) +{ + Eina_Unicode *ustr; + Eina_Unicode uc; + char *c; + int len; + + PROXY_DATA_GET(obj, pd); + c = _edje_text_cursor_content_get(pd->rp, (Efl_Text_Cursor_Cursor_Data *) cur); + ustr = eina_unicode_utf8_to_unicode(c, &len); + free(c); + if (ustr) + { + uc = *ustr; + free(ustr); + } + RETURN_VAL(uc); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_geometry_get(Eo *obj, + void *_pd EINA_UNUSED, + const Efl_Text_Cursor_Cursor_Data *cur EINA_UNUSED, + Efl_Text_Cursor_Cursor_Type ctype EINA_UNUSED, + Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, + Evas_Coord *cx2 EINA_UNUSED, Evas_Coord *cy2 EINA_UNUSED, + Evas_Coord *cw2 EINA_UNUSED, Evas_Coord *ch2 EINA_UNUSED) +{ + PROXY_DATA_GET(obj, pd); + _edje_entry_cursor_geometry_get(pd->rp, cx, cy, cw, ch, NULL); + RETURN_VAL(EINA_FALSE); +} + +EOLIAN static int +_efl_canvas_layout_internal_text_efl_text_cursor_cursor_text_insert(Eo *obj, + void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Data *cur EINA_UNUSED, + const char *text) +{ + PROXY_DATA_GET(obj, pd); + // Ignoring cursor type and always inserting with main cursor + _edje_object_part_text_insert(pd->ed, pd->rp, text); + // FIXME: entry should report the length of inserted text (after filtering) + RETURN_VAL(0); +} + #include "efl_canvas_layout_internal_text.eo.c" diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index efd6cc9074..22194c53ff 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2589,6 +2589,7 @@ void _edje_real_part_table_clear(Edje *ed, Edje_Real_Part *rp, Eina Evas_Object *_edje_children_get(Edje_Real_Part *rp, const char *partid); Eina_Bool _edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text); +void _edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type); char *_edje_text_escape(const char *text); char *_edje_text_unescape(const char *text); @@ -3150,6 +3151,21 @@ Evas_Object *_edje_object_part_external_content_get(Edje *ed, const char *part, Eo *_edje_text_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp); Eina_Bool _edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text); const char *_edje_efl_text_get(Eo *obj, Edje *ed, const char *part); +Evas_Textblock_Cursor *_edje_text_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_text_cursor_begin(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +void _edje_text_cursor_end(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +void _edje_text_cursor_pos_set(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur, int pos); +int _edje_text_cursor_pos_get(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +Eina_Bool _edje_text_cursor_coord_set(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur, int x, int y); +void _edje_text_cursor_line_begin(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +void _edje_text_cursor_line_end(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +Eina_Bool _edje_text_cursor_next(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +Eina_Bool _edje_text_cursor_prev(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +Eina_Bool _edje_text_cursor_up(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +Eina_Bool _edje_text_cursor_down(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +void _edje_text_cursor_copy(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *dst, Efl_Text_Cursor_Cursor_Data *cur); +char * _edje_text_cursor_content_get(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor_Data *cur); +void _edje_object_part_text_insert(Edje *ed, Edje_Real_Part *rp, const char *text); void _edje_internal_proxy_shutdown(void); diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index 594469e567..c200bb4350 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -1882,102 +1882,7 @@ _edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, c return EINA_TRUE; } -Eina_Bool -_edje_object_part_text_raw_append(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) -{ - if ((rp->type != EDJE_RP_TYPE_TEXT) || - (!rp->typedata.text)) return EINA_TRUE; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - _edje_entry_text_markup_append(rp, text); - else if (text) - { - if (rp->typedata.text->text) - { - char *new = NULL; - int len_added = strlen(text); - int len_old = strlen(rp->typedata.text->text); - new = malloc(len_old + len_added + 1); - memcpy(new, rp->typedata.text->text, len_old); - memcpy(new + len_old, text, len_added); - new[len_old + len_added] = '\0'; - eina_stringshare_replace(&rp->typedata.text->text, new); - free(new); - } - else - { - eina_stringshare_replace(&rp->typedata.text->text, text); - } - } - ed->dirty = EINA_TRUE; - ed->recalc_call = 1; -#ifdef EDJE_CALC_CACHE - rp->invalidate = EINA_TRUE; -#endif - _edje_recalc(ed); - if (ed->text_change.func) - ed->text_change.func(ed->text_change.data, obj, part); - return EINA_TRUE; -} - -EOLIAN void -_edje_object_part_text_style_user_push(Eo *obj EINA_UNUSED, Edje *ed, const char *part, const char *style) -{ - Edje_Real_Part *rp; - Evas_Textblock_Style *ts; - - if ((!ed) || (!part) || (!style)) return; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return; - if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return; - - ts = evas_textblock_style_new(); - evas_textblock_style_set(ts, style); - evas_object_textblock_style_user_push(rp->object, ts); - evas_textblock_style_free(ts); - ed->recalc_hints = EINA_TRUE; -#ifdef EDJE_CALC_CACHE - rp->invalidate = EINA_TRUE; -#endif - _edje_recalc(ed); -} - -EOLIAN void -_edje_object_part_text_style_user_pop(Eo *obj EINA_UNUSED, Edje *ed, const char *part) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return; - if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return; - - evas_object_textblock_style_user_pop(rp->object); - ed->recalc_hints = EINA_TRUE; -#ifdef EDJE_CALC_CACHE - rp->invalidate = EINA_TRUE; -#endif - _edje_recalc(ed); -} - -EOLIAN const char * -_edje_object_part_text_style_user_peek(Eo *obj EINA_UNUSED, Edje *ed, const char *part) -{ - Edje_Real_Part *rp; - const Evas_Textblock_Style *ts; - - if ((!ed) || (!part)) return NULL; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return NULL; - if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return NULL; - - ts = evas_object_textblock_style_user_peek(rp->object); - if (ts) - return evas_textblock_style_get(ts); - - return NULL; -} - -static void +void _edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type) { /* NOTE: This one is tricky, text is referenced in rp->typedata.text->text for the life of the @@ -2069,249 +1974,6 @@ _edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) return NULL; } -EOLIAN Eina_Bool -_edje_object_part_text_escaped_set(Eo *obj, Edje *ed, const char *part, const char *text) -{ - Edje_Real_Part *rp; - Eina_Bool int_ret; - - if ((!ed) || (!part)) return EINA_FALSE; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return EINA_FALSE; - if ((rp->type != EDJE_RP_TYPE_TEXT) || - (!rp->typedata.text)) return EINA_FALSE; - if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK && - rp->part->type != EDJE_PART_TYPE_TEXT) - return EINA_FALSE; - if ((rp->part->type == EDJE_PART_TYPE_TEXT) && (text)) - { - Eina_Strbuf *sbuf; - char *esc_start = NULL, *esc_end = NULL; - char *s, *p; - - sbuf = eina_strbuf_new(); - p = (char *)text; - s = p; - for (;; ) - { - if ((*p == 0) || (esc_end) || (esc_start)) - { - if (esc_end) - { - const char *escape; - - escape = evas_textblock_escape_string_range_get - (esc_start, esc_end + 1); - if (escape) eina_strbuf_append(sbuf, escape); - esc_start = esc_end = NULL; - } - else if (*p == 0) - { - if (!s) s = esc_start; /* This would happen when there is & that isn't escaped */ - eina_strbuf_append_length(sbuf, s, p - s); - s = NULL; - } - if (*p == 0) - break; - } - - if (*p == '&') - { - if (!s) s = esc_start; /* This would happen when there is & that isn't escaped */ - esc_start = p; - esc_end = NULL; - eina_strbuf_append_length(sbuf, s, p - s); - s = NULL; - } - else if (*p == ';') - { - if (esc_start) - { - esc_end = p; - s = p + 1; - } - } - p++; - } - int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, eina_strbuf_string_get(sbuf)); - _edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_ESCAPED); - eina_strbuf_free(sbuf); - return int_ret; - } - int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text); - _edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_ESCAPED); - - return int_ret; -} - -char * -_edje_text_escape(const char *text) -{ - Eina_Strbuf *txt; - char *ret; - const char *text_end; - size_t text_len; - - if (!text) return NULL; - - txt = eina_strbuf_new(); - text_len = strlen(text); - - text_end = text + text_len; - while (text < text_end) - { - int advance; - const char *escaped = evas_textblock_string_escape_get(text, &advance); - if (!escaped) - { - eina_strbuf_append_char(txt, text[0]); - advance = 1; - } - else - eina_strbuf_append(txt, escaped); - - text += advance; - } - - ret = eina_strbuf_string_steal(txt); - eina_strbuf_free(txt); - return ret; -} - -char * -_edje_text_unescape(const char *text) -{ - Eina_Strbuf *txt; - char *ret; - const char *text_end, *last, *escape_start; - size_t text_len; - - if (!text) return NULL; - - txt = eina_strbuf_new(); - text_len = strlen(text); - - text_end = text + text_len; - last = text; - escape_start = NULL; - for (; text < text_end; text++) - { - if (*text == '&') - { - size_t len; - const char *str; - - if (last) - { - len = text - last; - str = last; - } - else - { - len = text - escape_start; - str = escape_start; - } - - if (len > 0) - eina_strbuf_append_n(txt, str, len); - - escape_start = text; - last = NULL; - } - else if ((*text == ';') && (escape_start)) - { - size_t len; - const char *str = evas_textblock_escape_string_range_get(escape_start, text); - - if (str) - len = strlen(str); - else - { - str = escape_start; - len = text + 1 - escape_start; - } - - eina_strbuf_append_n(txt, str, len); - - escape_start = NULL; - last = text + 1; - } - } - - if (!last && escape_start) - last = escape_start; - - if (last && (text > last)) - { - size_t len = text - last; - eina_strbuf_append_n(txt, last, len); - } - - ret = eina_strbuf_string_steal(txt); - eina_strbuf_free(txt); - return ret; -} - -EOLIAN Eina_Bool -_edje_object_part_text_unescaped_set(Eo *obj, Edje *ed, const char *part, const char *text_to_escape) -{ - Edje_Real_Part *rp; - Eina_Bool int_ret = EINA_FALSE; - - if ((!ed) || (!part)) return EINA_FALSE; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return EINA_FALSE; - if ((rp->type != EDJE_RP_TYPE_TEXT) || - (!rp->typedata.text)) return EINA_FALSE; - if (rp->part->type == EDJE_PART_TYPE_TEXT) - int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text_to_escape); - else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) - { - char *text = _edje_text_escape(text_to_escape); - - int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text); - free(text); - } - _edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_UNESCAPED); - - return int_ret; -} - -EOLIAN char * -_edje_object_part_text_unescaped_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return NULL; - - /* Need to recalc before providing the object. */ - _edje_recalc_do(ed); - - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return NULL; - if ((rp->type != EDJE_RP_TYPE_TEXT) || - (!rp->typedata.text)) return NULL; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - { - const char *t = _edje_entry_text_get(rp); - return _edje_text_unescape(t); - } - else - { - if (rp->part->type == EDJE_PART_TYPE_TEXT) - { - return strdup(rp->typedata.text->text); - } - if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) - { - const char *t = evas_object_textblock_text_markup_get(rp->object); - return _edje_text_unescape(t); - } - } - - return NULL; -} - EOLIAN const char * _edje_object_part_text_selection_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) { @@ -2350,107 +2012,6 @@ _edje_object_part_text_select_all(Eo *obj EINA_UNUSED, Edje *ed, const char *par _edje_entry_select_all(rp); } -EOLIAN void -_edje_object_part_text_insert(Eo *obj, Edje *ed, const char *part, const char *text) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return; - if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; - if (rp->part->entry_mode <= EDJE_ENTRY_EDIT_MODE_NONE) return; - _edje_entry_text_markup_insert(rp, text); - ed->dirty = EINA_TRUE; - ed->recalc_call = EINA_TRUE; - ed->recalc_hints = EINA_TRUE; -#ifdef EDJE_CALC_CACHE - rp->invalidate = EINA_TRUE; -#endif - _edje_recalc(ed); - if (ed->text_change.func) - ed->text_change.func(ed->text_change.data, obj, part); -} - -EOLIAN void -_edje_object_part_text_append(Eo *obj, Edje *ed, const char *part, const char *text) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return; - if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; - _edje_object_part_text_raw_append(ed, obj, rp, part, text); - ed->dirty = EINA_TRUE; - ed->recalc_call = EINA_TRUE; - ed->recalc_hints = EINA_TRUE; -#ifdef EDJE_CALC_CACHE - rp->invalidate = EINA_TRUE; -#endif - _edje_recalc(ed); - if (ed->text_change.func) - ed->text_change.func(ed->text_change.data, obj, part); -} - -EOLIAN const Eina_List * -_edje_object_part_text_anchor_list_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return NULL; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return NULL; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - return _edje_entry_anchors_list(rp); - - return NULL; -} - -EOLIAN const Eina_List * -_edje_object_part_text_anchor_geometry_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, const char *anchor) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return NULL; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return NULL; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - return _edje_entry_anchor_geometry_get(rp, anchor); - - return NULL; -} - -EOLIAN const Eina_List * -_edje_object_part_text_item_list_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return NULL; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return NULL; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - return _edje_entry_items_list(rp); - - return NULL; -} - -EOLIAN Eina_Bool -_edje_object_part_text_item_geometry_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return EINA_FALSE; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return EINA_FALSE; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - { - return _edje_entry_item_geometry_get(rp, item, cx, cy, cw, ch); - } - - return EINA_FALSE; -} - EOLIAN void _edje_object_part_text_cursor_geometry_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { @@ -2471,18 +2032,6 @@ _edje_object_part_text_cursor_geometry_get(Eo *obj EINA_UNUSED, Edje *ed, const } } -EOLIAN void -_edje_object_part_text_user_insert(Eo *obj EINA_UNUSED, Edje *ed, const char *part, const char *text) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - _edje_entry_user_insert(rp, text); -} - EAPI void edje_object_part_text_select_allow_set(const Evas_Object *obj, const char *part, Eina_Bool allow) { @@ -2704,53 +2253,6 @@ _edje_object_part_text_cursor_coord_set(Eo *obj EINA_UNUSED, Edje *ed, const cha return EINA_FALSE; } -EOLIAN Eina_Bool -_edje_object_part_text_cursor_is_format_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Cursor cur) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return EINA_FALSE; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return EINA_FALSE; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - { - return _edje_entry_cursor_is_format_get(rp, cur); - } - return EINA_FALSE; -} - -EOLIAN Eina_Bool -_edje_object_part_text_cursor_is_visible_format_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Cursor cur) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return EINA_FALSE; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return EINA_FALSE; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - { - return _edje_entry_cursor_is_visible_format_get(rp, cur); - } - - return EINA_FALSE; -} - -EOLIAN char * -_edje_object_part_text_cursor_content_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Cursor cur) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return NULL; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return NULL; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - { - return _edje_entry_cursor_content_get(rp, cur); - } - - return NULL; -} - EOLIAN void _edje_object_part_text_cursor_pos_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Cursor cur, int pos) { @@ -3166,128 +2668,6 @@ _edje_object_part_text_input_panel_show_on_demand_get(Eo *obj EINA_UNUSED, Edje return ret; } -EOLIAN void -_edje_object_text_insert_filter_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Text_Filter_Cb func, void *data) -{ - Edje_Text_Insert_Filter_Callback *cb; - - if ((!ed) || (!part)) return; - cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback)); - cb->part = eina_stringshare_add(part); - cb->func = func; - cb->data = (void *)data; - ed->text_insert_filter_callbacks = - eina_list_append(ed->text_insert_filter_callbacks, cb); -} - -EOLIAN void * -_edje_object_text_insert_filter_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Text_Filter_Cb func) -{ - Edje_Text_Insert_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func)) - { - void *data = cb->data; - ed->text_insert_filter_callbacks = - eina_list_remove_list(ed->text_insert_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return data; - } - } - - return NULL; -} - -EOLIAN void * -_edje_object_text_insert_filter_callback_del_full(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Text_Filter_Cb func, void *data) -{ - Edje_Text_Insert_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func) && - (cb->data == data)) - { - void *tmp = cb->data; - ed->text_insert_filter_callbacks = - eina_list_remove_list(ed->text_insert_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return tmp; - } - } - - return NULL; -} - -EOLIAN void -_edje_object_text_markup_filter_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Markup_Filter_Cb func, void *data) -{ - Edje_Markup_Filter_Callback *cb; - - if ((!ed) || (!part)) return; - cb = calloc(1, sizeof(Edje_Markup_Filter_Callback)); - cb->part = eina_stringshare_add(part); - cb->func = func; - cb->data = (void *)data; - ed->markup_filter_callbacks = - eina_list_append(ed->markup_filter_callbacks, cb); -} - -EOLIAN void * -_edje_object_text_markup_filter_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Markup_Filter_Cb func) -{ - Edje_Markup_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func)) - { - void *data = cb->data; - ed->markup_filter_callbacks = - eina_list_remove_list(ed->markup_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return data; - } - } - - return NULL; -} - -EOLIAN void * -_edje_object_text_markup_filter_callback_del_full(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Markup_Filter_Cb func, void *data) -{ - Edje_Markup_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func) && - (cb->data == data)) - { - void *tmp = cb->data; - ed->markup_filter_callbacks = - eina_list_remove_list(ed->markup_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return tmp; - } - } - - return NULL; -} - Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow) { @@ -5486,28 +4866,6 @@ _edje_real_part_text_text_source_description_get(Edje_Real_Part *ep, Edje_Real_P return et; } -EOLIAN Eina_Bool -_edje_object_part_text_hide_visible_password(Eo *obj EINA_UNUSED, Edje *ed, const char *part) -{ - Edje_Real_Part *rp; - Eina_Bool int_ret = EINA_FALSE; - - if ((!ed) || (!part)) return EINA_FALSE; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return EINA_FALSE; - if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return EINA_FALSE; - if ((rp->type != EDJE_RP_TYPE_TEXT) || - (!rp->typedata.text)) - { - return EINA_FALSE; - } - - if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) - int_ret = _edje_entry_hide_visible_password(ed, rp); - - return int_ret; -} - Edje_Real_Part * _edje_real_part_recursive_get(Edje **ed, const char *part) { diff --git a/src/lib/edje/efl_canvas_layout_internal_text.eo b/src/lib/edje/efl_canvas_layout_internal_text.eo index fc11015d6a..58ca552d2a 100644 --- a/src/lib/edje/efl_canvas_layout_internal_text.eo +++ b/src/lib/edje/efl_canvas_layout_internal_text.eo @@ -1,4 +1,5 @@ -class Efl.Canvas.Layout_Internal.Text (Efl.Canvas.Layout_Internal, Efl.Text) +class Efl.Canvas.Layout_Internal.Text (Efl.Canvas.Layout_Internal, Efl.Text, + Efl.Text.Cursor) { [[Represents a TEXT part of a layout @@ -8,5 +9,19 @@ class Efl.Canvas.Layout_Internal.Text (Efl.Canvas.Layout_Internal, Efl.Text) data: null; implements { Efl.Text.text { set; get; } + Efl.Text.Cursor.cursor { get; } + Efl.Text.Cursor.cursor_paragraph_first; + Efl.Text.Cursor.cursor_paragraph_last; + Efl.Text.Cursor.cursor_position { set; get; } + Efl.Text.Cursor.cursor_coord_set; + Efl.Text.Cursor.cursor_line_char_first; + Efl.Text.Cursor.cursor_line_char_last; + Efl.Text.Cursor.cursor_char_next; + Efl.Text.Cursor.cursor_char_prev; + Efl.Text.Cursor.cursor_line_jump_by; + Efl.Text.Cursor.cursor_copy; + Efl.Text.Cursor.cursor_content { get; } + Efl.Text.Cursor.cursor_geometry { get; } + Efl.Text.Cursor.cursor_text_insert; } } diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index c10bf580c6..9368bc8305 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -853,7 +853,7 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) evas_event_freeze(evas_object_evas_get(obj)); - edje_obj_part_text_hide_visible_password(sd->entry_edje, "elm.text"); + edje_object_part_text_hide_visible_password(sd->entry_edje, "elm.text"); edje_object_mirrored_set (wd->resize_obj, elm_widget_mirrored_get(obj)); @@ -864,7 +864,7 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) _mirrored_set(obj, elm_widget_mirrored_get(obj)); - stl_user = eina_stringshare_add(edje_obj_part_text_style_user_peek(sd->entry_edje, "elm.text")); + stl_user = eina_stringshare_add(edje_object_part_text_style_user_peek(sd->entry_edje, "elm.text")); t = eina_stringshare_add(elm_object_text_get(obj)); elm_widget_theme_object_set @@ -877,7 +877,7 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) edje_obj_part_text_select_allow_set (sd->entry_edje, "elm.text", EINA_FALSE); - edje_obj_part_text_style_user_push(sd->entry_edje, "elm.text", stl_user); + edje_object_part_text_style_user_push(sd->entry_edje, "elm.text", stl_user); eina_stringshare_del(stl_user); elm_object_text_set(obj, t);