summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_object_textblock.c
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2019-09-05 14:52:51 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2019-09-05 14:52:51 +0900
commit7a05d8d76997399bb55893d4b456b24e65a223cc (patch)
tree8a52ec05e312f0189608ce7134254a86cd62440d /src/lib/evas/canvas/evas_object_textblock.c
parent8dcd638829ce0089f969bd7f6914683cb747b624 (diff)
elm_entry: handle cursor delete/backspace with clusters consist of one or multible glyphs
Summary: Cluster consist of one glyph, expected to be removed on backspace or delete key. Cluster consist of multible glyph, expectd to remove part of on backspace or delete key. This is behaviour founded in Android. (our current way of handling similar to Qt) **New Behaviour** {F3750386} **Old Behaviour** {F3750387} Test Plan: Auto Testing is challenging because there are no easy way to emulate keyboard down on elm_entry ``` #include <Elementary.h> EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win,*box,*entry; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("", ""); elm_win_autodel_set(win, EINA_TRUE); box = elm_box_add(win); entry = elm_entry_add(box); evas_object_size_hint_weight_set(box,EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(box,EVAS_HINT_FILL,EVAS_HINT_FILL); elm_entry_entry_set(entry,"<font=NotoColorEmoji wrap=mixed >🇧🇬อั🇧🇬อั&#x1F600;&#x1F600;&#x1F600;&#x1F600;&#x1F600;อั</font>"); evas_object_size_hint_weight_set(entry,EVAS_HINT_EXPAND,0.9); evas_object_size_hint_align_set(entry,EVAS_HINT_FILL,EVAS_HINT_FILL); evas_object_show(entry); evas_object_show(box); elm_box_pack_end(box,entry); elm_win_resize_object_add(win,box); evas_object_resize(win,320,480); evas_object_size_hint_weight_set(entry,EVAS_HINT_EXPAND,0.1); evas_object_size_hint_align_set(entry,EVAS_HINT_FILL,EVAS_HINT_FILL); evas_object_show(win); elm_run(); return 0; } ELM_MAIN() ``` Reviewers: tasn, woohyun, bowonryu Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9628
Diffstat (limited to 'src/lib/evas/canvas/evas_object_textblock.c')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c76
1 files changed, 73 insertions, 3 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 5f8ae17..90561f4 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -9662,7 +9662,7 @@ _evas_textblock_grapheme_breaks_new(Evas_Object_Textblock_Item *it, size_t len)
9662} 9662}
9663 9663
9664static size_t 9664static size_t
9665_evas_textblock_cursor_cluster_pos_get(Evas_Textblock_Cursor *cur, Eina_Bool inc) 9665_evas_textblock_cursor_cluster_pos_get(Evas_Textblock_Cursor *cur, Eina_Bool inc, Eina_Bool *is_single_glyph)
9666{ 9666{
9667 Evas_Object_Textblock_Paragraph *par; 9667 Evas_Object_Textblock_Paragraph *par;
9668 Efl_Canvas_Text_Data *o; 9668 Efl_Canvas_Text_Data *o;
@@ -9728,6 +9728,64 @@ _evas_textblock_cursor_cluster_pos_get(Evas_Textblock_Cursor *cur, Eina_Bool inc
9728 9728
9729 free(grapheme_breaks); 9729 free(grapheme_breaks);
9730 } 9730 }
9731
9732 if (is_single_glyph)
9733 {
9734 Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(last_it);
9735 Evas_Text_Props_Info *info = ti->text_props.info;
9736 int it_index = ((inc) ? cur->pos : ret) - last_it->text_pos;
9737
9738 Evas_Font_OT_Info ot;
9739 if (ti->text_props.len != ti->text_props.text_len)/*if code point count same as glyph count skip it*/
9740 {
9741 Evas_BiDi_Direction itdir = ti->text_props.bidi_dir;
9742 int i = 0;
9743 if (itdir == EFL_TEXT_BIDIRECTIONAL_TYPE_RTL)
9744 {
9745 for (i = ti->text_props.len-1 ; i >= 0; i--)
9746 {
9747 ot = info->ot[i];
9748 if (ot.source_cluster >= (size_t)it_index)
9749 break;
9750 }
9751 if (i <= 0)
9752 {
9753 if (ti->text_props.text_len - ot.source_cluster >= 2)
9754 *is_single_glyph = EINA_TRUE;
9755 }
9756 else
9757 {
9758 Evas_Font_OT_Info ot_next = info->ot[i - 1];
9759 if (ot_next.source_cluster - ot.source_cluster >= 2)
9760 *is_single_glyph = EINA_TRUE;
9761 }
9762 }
9763 else
9764 {
9765 for (i = 0; i < (int) ti->text_props.len; i++)
9766 {
9767 ot = info->ot[i];
9768 if ((int)ot.source_cluster >= it_index)
9769 break;
9770 }
9771 if ((i + 1) >= (int) ti->text_props.len)
9772 {
9773 if (ti->text_props.text_len - ot.source_cluster >= 2)
9774 *is_single_glyph = EINA_TRUE;
9775 }
9776 else
9777 {
9778 Evas_Font_OT_Info ot_next = info->ot[i + 1];
9779 if (ot_next.source_cluster - ot.source_cluster >= 2)
9780 *is_single_glyph = EINA_TRUE;
9781 }
9782 }
9783 }
9784 else
9785 {
9786 is_single_glyph = EINA_FALSE;
9787 }
9788 }
9731 } 9789 }
9732 } 9790 }
9733 } 9791 }
@@ -9735,6 +9793,18 @@ _evas_textblock_cursor_cluster_pos_get(Evas_Textblock_Cursor *cur, Eina_Bool inc
9735 return ret; 9793 return ret;
9736} 9794}
9737 9795
9796EAPI Eina_Bool evas_textblock_cursor_at_cluster_as_single_glyph(Evas_Textblock_Cursor *cur,Eina_Bool forward)
9797{
9798 Eina_Bool is_single_glyph = EINA_FALSE;
9799 size_t ret = _evas_textblock_cursor_cluster_pos_get(cur, forward, &is_single_glyph);
9800
9801 if ((abs(ret-cur->pos) > 1) && is_single_glyph)
9802 {
9803 return EINA_TRUE;
9804 }
9805 return EINA_FALSE;
9806}
9807
9738static Eina_Bool 9808static Eina_Bool
9739_evas_textblock_cursor_next(Evas_Textblock_Cursor *cur, Eina_Bool per_cluster) 9809_evas_textblock_cursor_next(Evas_Textblock_Cursor *cur, Eina_Bool per_cluster)
9740{ 9810{
@@ -9754,7 +9824,7 @@ _evas_textblock_cursor_next(Evas_Textblock_Cursor *cur, Eina_Bool per_cluster)
9754 if (text[ind]) 9824 if (text[ind])
9755 { 9825 {
9756 if (per_cluster) 9826 if (per_cluster)
9757 ind = _evas_textblock_cursor_cluster_pos_get(cur, EINA_TRUE); 9827 ind = _evas_textblock_cursor_cluster_pos_get(cur, EINA_TRUE, NULL);
9758 9828
9759 if (ind <= (int)cur->pos) 9829 if (ind <= (int)cur->pos)
9760 ind = cur->pos + 1; 9830 ind = cur->pos + 1;
@@ -9801,7 +9871,7 @@ _evas_textblock_cursor_prev(Evas_Textblock_Cursor *cur, Eina_Bool per_cluster)
9801 { 9871 {
9802 if (per_cluster) 9872 if (per_cluster)
9803 { 9873 {
9804 size_t ret = _evas_textblock_cursor_cluster_pos_get(cur, EINA_FALSE); 9874 size_t ret = _evas_textblock_cursor_cluster_pos_get(cur, EINA_FALSE, NULL);
9805 9875
9806 if (ret != cur->pos) 9876 if (ret != cur->pos)
9807 { 9877 {