summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdullehGhujeh <abdullahhasan10@gmail.com>2020-06-22 16:31:53 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-06-22 16:31:54 +0900
commite3e3d0cfe4d753782d0adc81a68e5cd7ca27c5b9 (patch)
treeca6c31ac83652cfd0d62d8f1eb132f18119a740a
parentabc146f37f87200142d44d0feab8986dd219e1fd (diff)
Textblock : Fix cursor cluster movement when emoji at the line start
Summary: if we have emoji only or emoji at line start we can move cursor using mouse click to be inside the emoji. {F3868502} this should fix T8664 Test Plan: #include <Elementary.h> EAPI_MAIN int elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) { Evas_Object *win; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("emoji-test", "emoji-test"); elm_win_autodel_set(win, EINA_TRUE); /* and now just resize the window to a size you want. normally widgets * will determine the initial size though */ evas_object_resize(win, 320, 320); Evas_Object *box; box = elm_box_add(win); 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_win_resize_object_add(win, box); Evas_Object *entry; entry = elm_entry_add(box); elm_entry_entry_set(entry, "&#x262a;&#xfe0f;"); evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_box_pack_end(box, entry); evas_object_show(entry); evas_object_show(box); /* and show the window */ evas_object_show(win); elm_run(); /* and run the program now, starting to handle all * events, etc. */ /* exit code */ return 0; } ELM_MAIN() Reviewers: ali.alzyod, woohyun, bowonryu, zmike, bu5hm4n Reviewed By: ali.alzyod Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8664 Differential Revision: https://phab.enlightenment.org/D11732
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c11
-rw-r--r--src/tests/evas/evas_test_textblock.c14
2 files changed, 22 insertions, 3 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index fe6552d4ac..0889de197d 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -13342,21 +13342,26 @@ _evas_textblock_cursor_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, Evas_
13342 * try to move cursor to a nearest breakable position. */ 13342 * try to move cursor to a nearest breakable position. */
13343 if (grapheme_breaks && (grapheme_breaks[pos + it->text_pos - 1] != GRAPHEMEBREAK_BREAK)) 13343 if (grapheme_breaks && (grapheme_breaks[pos + it->text_pos - 1] != GRAPHEMEBREAK_BREAK))
13344 { 13344 {
13345 size_t left_index = pos + it->text_pos - 1; 13345 int left_index = pos + it->text_pos - 1;
13346 size_t right_index = pos + it->text_pos - 1; 13346 size_t right_index = pos + it->text_pos - 1;
13347 int temp_index;
13347 int lx, rx; 13348 int lx, rx;
13348 13349
13349 /* To the left */ 13350 /* To the left */
13350 while ((left_index > 0) && 13351 while ((left_index >= 0) &&
13351 (grapheme_breaks[left_index] != GRAPHEMEBREAK_BREAK)) 13352 (grapheme_breaks[left_index] != GRAPHEMEBREAK_BREAK))
13352 { 13353 {
13353 left_index--; 13354 left_index--;
13354 } 13355 }
13355 13356
13357 temp_index = left_index - it->text_pos + 1;
13358 if (temp_index < 0)
13359 temp_index = 0;
13360
13356 ENFN->font_pen_coords_get(ENC, 13361 ENFN->font_pen_coords_get(ENC,
13357 ti->parent.format->font.font, 13362 ti->parent.format->font.font,
13358 &ti->text_props, 13363 &ti->text_props,
13359 left_index - it->text_pos + 1, 13364 temp_index,
13360 &lx, NULL, NULL, NULL); 13365 &lx, NULL, NULL, NULL);
13361 13366
13362 /* To the right */ 13367 /* To the right */
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index a0b68ac90a..e56b1d3912 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -1003,6 +1003,20 @@ EFL_START_TEST(evas_textblock_cursor)
1003 while (evas_textblock_cursor_char_prev(cur2)) j++; 1003 while (evas_textblock_cursor_char_prev(cur2)) j++;
1004 ck_assert_int_eq(j, 4); 1004 ck_assert_int_eq(j, 4);
1005 1005
1006 //make sure if we have cluster at line start we return to pos 0
1007 Evas_Coord x_coord, y_coord;
1008 int pos;
1009
1010 cur2 = evas_object_textblock_cursor_new(tb);
1011 evas_object_textblock_text_markup_set(tb, "&#x262a;&#xfe0f;");
1012
1013 evas_textblock_cursor_char_next(cur2);
1014 evas_textblock_cursor_pen_geometry_get(cur2, &x_coord, &y_coord, NULL, NULL);
1015 evas_textblock_cursor_cluster_coord_set(cur, x_coord, y_coord);
1016 pos = evas_textblock_cursor_pos_get(cur);
1017
1018 ck_assert_int_eq(pos, 0);
1019
1006 END_TB_TEST(); 1020 END_TB_TEST();
1007} 1021}
1008EFL_END_TEST 1022EFL_END_TEST