summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_entry.c
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2018-08-20 07:21:53 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-20 10:29:32 -0400
commit517018e00897f61136418861563a49144a5fe39a (patch)
tree694c299402631380a10a7ad6ddbebfbb774e7e91 /src/lib/edje/edje_entry.c
parent8da56ac873d5bb083b7cfe08aeefdaa2ad9a4b99 (diff)
evas textblock: add/apply cursor cluster APIs based on grapheme cluster
Summary: Add a feature for moving cursor over a grapheme cluster. It is applied to edje_entry.c and elm_entry.c for improving cursor handling just like other modern text editors. ex) gedit The patch on Evas needs to update libunibreak library. So, the patch will update libunibreak, too. @feature Test Plan: 1. Put "ഹലോ" in your entry. 2. Your cursor can reach at the end of text from the beginning only in 2 right key event with this feature. Reviewers: raster, cedric, jpeg, herdsman, zmike, devilhorns Reviewed By: herdsman, zmike Subscribers: #reviewers, #committers, zmike, bowonryu, woohyun Tags: #efl Differential Revision: https://phab.enlightenment.org/D5490
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_entry.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index 6c1f8960ff..1ad3c30b65 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -536,7 +536,7 @@ _curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
536 536
537 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh)) 537 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
538 return EINA_FALSE; 538 return EINA_FALSE;
539 if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2))) 539 if (evas_textblock_cursor_cluster_coord_set(c, cx, ly + (lh / 2)))
540 return EINA_TRUE; 540 return EINA_TRUE;
541 evas_textblock_cursor_line_set(c, ln); 541 evas_textblock_cursor_line_set(c, ln);
542 if (cx < (lx + (lw / 2))) 542 if (cx < (lx + (lw / 2)))
@@ -1607,24 +1607,33 @@ _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1607 ERR("Running very low on memory"); 1607 ERR("Running very low on memory");
1608 return; 1608 return;
1609 } 1609 }
1610 char *tmp = evas_textblock_cursor_content_get(c); 1610 char *tmp = NULL;
1611 1611
1612 info->insert = EINA_FALSE; 1612 info->insert = EINA_FALSE;
1613 if (backspace) 1613 if (backspace)
1614 { 1614 {
1615 info->change.del.start = pos - 1; 1615 info->change.del.start = pos - 1;
1616 info->change.del.end = pos; 1616 info->change.del.end = pos;
1617 tmp = evas_textblock_cursor_content_get(c);
1618 evas_textblock_cursor_char_delete(c);
1617 } 1619 }
1618 else 1620 else
1619 { 1621 {
1620 info->change.del.start = pos + 1; 1622 Evas_Textblock_Cursor *cc = evas_object_textblock_cursor_new(en->rp->object);
1623 evas_textblock_cursor_copy(c, cc);
1624 evas_textblock_cursor_cluster_next(cc);
1625
1626 info->change.del.start = evas_textblock_cursor_pos_get(cc);
1621 info->change.del.end = pos; 1627 info->change.del.end = pos;
1628
1629 tmp = evas_textblock_cursor_range_text_get(c, cc, EVAS_TEXTBLOCK_TEXT_MARKUP);
1630 evas_textblock_cursor_range_delete(c, cc);
1631 evas_textblock_cursor_free(cc);
1622 } 1632 }
1623 1633
1624 info->change.del.content = eina_stringshare_add(tmp); 1634 info->change.del.content = eina_stringshare_add(tmp);
1625 if (tmp) free(tmp); 1635 if (tmp) free(tmp);
1626 1636
1627 evas_textblock_cursor_char_delete(c);
1628 _edje_emit(ed, "entry,changed", en->rp->part->name); 1637 _edje_emit(ed, "entry,changed", en->rp->part->name);
1629 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, 1638 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1630 info, _free_entry_change_info); 1639 info, _free_entry_change_info);
@@ -1855,7 +1864,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1855 } 1864 }
1856 } 1865 }
1857 } 1866 }
1858 if (evas_textblock_cursor_char_prev(en->cursor)) 1867 if (evas_textblock_cursor_cluster_prev(en->cursor))
1859 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1868 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1860#if defined(__APPLE__) && defined(__MACH__) 1869#if defined(__APPLE__) && defined(__MACH__)
1861 if (altgr) evas_textblock_cursor_word_start(en->cursor); 1870 if (altgr) evas_textblock_cursor_word_start(en->cursor);
@@ -1903,7 +1912,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1903#else 1912#else
1904 if (control) evas_textblock_cursor_word_end(en->cursor); 1913 if (control) evas_textblock_cursor_word_end(en->cursor);
1905#endif 1914#endif
1906 if (evas_textblock_cursor_char_next(en->cursor)) 1915 if (evas_textblock_cursor_cluster_next(en->cursor))
1907 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1916 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1908 if (en->select_allow) 1917 if (en->select_allow)
1909 { 1918 {
@@ -1921,7 +1930,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1921 // del to start of previous word 1930 // del to start of previous word
1922 _sel_start(en->cursor, rp->object, en); 1931 _sel_start(en->cursor, rp->object, en);
1923 1932
1924 evas_textblock_cursor_char_prev(en->cursor); 1933 evas_textblock_cursor_cluster_prev(en->cursor);
1925 evas_textblock_cursor_word_start(en->cursor); 1934 evas_textblock_cursor_word_start(en->cursor);
1926 1935
1927 _sel_preextend(ed, en->cursor, rp->object, en); 1936 _sel_preextend(ed, en->cursor, rp->object, en);
@@ -1961,7 +1970,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1961 _sel_start(en->cursor, rp->object, en); 1970 _sel_start(en->cursor, rp->object, en);
1962 1971
1963 evas_textblock_cursor_word_end(en->cursor); 1972 evas_textblock_cursor_word_end(en->cursor);
1964 evas_textblock_cursor_char_next(en->cursor); 1973 evas_textblock_cursor_cluster_next(en->cursor);
1965 1974
1966 _sel_extend(ed, en->cursor, rp->object, en); 1975 _sel_extend(ed, en->cursor, rp->object, en);
1967 1976
@@ -2400,7 +2409,7 @@ _edje_key_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
2400} 2409}
2401 2410
2402static Evas_Textblock_Cursor * 2411static Evas_Textblock_Cursor *
2403_edje_cursor_char_coord_set(Edje_Real_Part *rp, Evas_Coord canvasx, Evas_Coord canvasy, Evas_Coord *cx, Evas_Coord *cy) 2412_edje_cursor_cluster_coord_set(Edje_Real_Part *rp, Evas_Coord canvasx, Evas_Coord canvasy, Evas_Coord *cx, Evas_Coord *cy)
2404{ 2413{
2405 Entry *en; 2414 Entry *en;
2406 Evas_Coord x, y, lh = 0, cly = 0; 2415 Evas_Coord x, y, lh = 0, cly = 0;
@@ -2432,7 +2441,7 @@ _edje_cursor_char_coord_set(Edje_Real_Part *rp, Evas_Coord canvasx, Evas_Coord c
2432 evas_textblock_cursor_free(line_cur); 2441 evas_textblock_cursor_free(line_cur);
2433 /* No need to check return value if not able to set the char coord Textblock 2442 /* No need to check return value if not able to set the char coord Textblock
2434 * will take care */ 2443 * will take care */
2435 evas_textblock_cursor_char_coord_set(en->cursor, *cx, *cy); 2444 evas_textblock_cursor_cluster_coord_set(en->cursor, *cx, *cy);
2436 2445
2437 return tc; 2446 return tc;
2438} 2447}
@@ -2530,7 +2539,7 @@ _edje_part_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
2530 else 2539 else
2531 { 2540 {
2532 evas_textblock_cursor_word_end(en->cursor); 2541 evas_textblock_cursor_word_end(en->cursor);
2533 evas_textblock_cursor_char_next(en->cursor); 2542 evas_textblock_cursor_cluster_next(en->cursor);
2534 } 2543 }
2535 _sel_extend(en->ed, en->cursor, rp->object, en); 2544 _sel_extend(en->ed, en->cursor, rp->object, en);
2536 } 2545 }
@@ -2544,13 +2553,13 @@ _edje_part_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
2544 evas_textblock_cursor_word_start(en->cursor); 2553 evas_textblock_cursor_word_start(en->cursor);
2545 _sel_start(en->cursor, rp->object, en); 2554 _sel_start(en->cursor, rp->object, en);
2546 evas_textblock_cursor_word_end(en->cursor); 2555 evas_textblock_cursor_word_end(en->cursor);
2547 evas_textblock_cursor_char_next(en->cursor); 2556 evas_textblock_cursor_cluster_next(en->cursor);
2548 _sel_extend(en->ed, en->cursor, rp->object, en); 2557 _sel_extend(en->ed, en->cursor, rp->object, en);
2549 } 2558 }
2550 goto end; 2559 goto end;
2551 } 2560 }
2552 } 2561 }
2553 tc = _edje_cursor_char_coord_set(rp, ev->canvas.x, ev->canvas.y, &cx, &cy); 2562 tc = _edje_cursor_cluster_coord_set(rp, ev->canvas.x, ev->canvas.y, &cx, &cy);
2554 2563
2555 if (dosel) 2564 if (dosel)
2556 { 2565 {
@@ -2670,7 +2679,7 @@ _edje_part_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
2670#endif 2679#endif
2671 2680
2672 /* cx cy are unused but needed in mouse down, please bear with it */ 2681 /* cx cy are unused but needed in mouse down, please bear with it */
2673 tc = _edje_cursor_char_coord_set(rp, ev->canvas.x, ev->canvas.y, &cx, &cy); 2682 tc = _edje_cursor_cluster_coord_set(rp, ev->canvas.x, ev->canvas.y, &cx, &cy);
2674 2683
2675 if (en->select_allow) 2684 if (en->select_allow)
2676 { 2685 {
@@ -2748,7 +2757,7 @@ _edje_part_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
2748 evas_object_geometry_get(rp->object, &x, &y, &w, &h); 2757 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2749 cx = ev->cur.canvas.x - x; 2758 cx = ev->cur.canvas.x - x;
2750 cy = ev->cur.canvas.y - y; 2759 cy = ev->cur.canvas.y - y;
2751 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy)) 2760 if (!evas_textblock_cursor_cluster_coord_set(en->cursor, cx, cy))
2752 { 2761 {
2753 Evas_Coord lx, ly, lw, lh; 2762 Evas_Coord lx, ly, lw, lh;
2754 2763
@@ -2760,7 +2769,7 @@ _edje_part_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
2760 { 2769 {
2761 evas_textblock_cursor_paragraph_first(en->cursor); 2770 evas_textblock_cursor_paragraph_first(en->cursor);
2762 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); 2771 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2763 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2))) 2772 if (!evas_textblock_cursor_cluster_coord_set(en->cursor, cx, ly + (lh / 2)))
2764 _curs_end(en->cursor, rp->object, en); 2773 _curs_end(en->cursor, rp->object, en);
2765 } 2774 }
2766 } 2775 }
@@ -4029,7 +4038,7 @@ _edje_text_cursor_next(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *c)
4029 4038
4030 _edje_entry_imf_context_reset(rp); 4039 _edje_entry_imf_context_reset(rp);
4031 4040
4032 if (!evas_textblock_cursor_char_next(c)) 4041 if (!evas_textblock_cursor_cluster_next(c))
4033 { 4042 {
4034 return EINA_FALSE; 4043 return EINA_FALSE;
4035 } 4044 }
@@ -4062,7 +4071,7 @@ _edje_text_cursor_prev(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *c)
4062 4071
4063 _edje_entry_imf_context_reset(rp); 4072 _edje_entry_imf_context_reset(rp);
4064 4073
4065 if (!evas_textblock_cursor_char_prev(c)) 4074 if (!evas_textblock_cursor_cluster_prev(c))
4066 { 4075 {
4067 if (evas_textblock_cursor_paragraph_prev(c)) goto ok; 4076 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
4068 else return EINA_FALSE; 4077 else return EINA_FALSE;
@@ -4106,7 +4115,7 @@ _edje_text_cursor_up(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *c)
4106 &lx, &ly, &lw, &lh)) 4115 &lx, &ly, &lw, &lh))
4107 return EINA_FALSE; 4116 return EINA_FALSE;
4108 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch); 4117 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
4109 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2))) 4118 if (!evas_textblock_cursor_cluster_coord_set(c, cx, ly + (lh / 2)))
4110 evas_textblock_cursor_line_char_last(c); 4119 evas_textblock_cursor_line_char_last(c);
4111 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data); 4120 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
4112 4121
@@ -4145,7 +4154,7 @@ _edje_text_cursor_down(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *c)
4145 &lx, &ly, &lw, &lh)) 4154 &lx, &ly, &lw, &lh))
4146 return EINA_FALSE; 4155 return EINA_FALSE;
4147 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch); 4156 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
4148 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2))) 4157 if (!evas_textblock_cursor_cluster_coord_set(c, cx, ly + (lh / 2)))
4149 evas_textblock_cursor_line_char_last(c); 4158 evas_textblock_cursor_line_char_last(c);
4150 4159
4151 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data); 4160 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
@@ -4347,7 +4356,7 @@ _edje_text_cursor_coord_set(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *c,
4347 _edje_emit(en->ed, "selection,changed", rp->part->name); 4356 _edje_emit(en->ed, "selection,changed", rp->part->name);
4348 } 4357 }
4349 } 4358 }
4350 return evas_textblock_cursor_char_coord_set(c, x, y); 4359 return evas_textblock_cursor_cluster_coord_set(c, x, y);
4351} 4360}
4352 4361
4353Eina_Bool 4362Eina_Bool