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, "☪️"); 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
This commit is contained in:
parent
abc146f37f
commit
e3e3d0cfe4
|
@ -13342,21 +13342,26 @@ _evas_textblock_cursor_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, Evas_
|
|||
* try to move cursor to a nearest breakable position. */
|
||||
if (grapheme_breaks && (grapheme_breaks[pos + it->text_pos - 1] != GRAPHEMEBREAK_BREAK))
|
||||
{
|
||||
size_t left_index = pos + it->text_pos - 1;
|
||||
int left_index = pos + it->text_pos - 1;
|
||||
size_t right_index = pos + it->text_pos - 1;
|
||||
int temp_index;
|
||||
int lx, rx;
|
||||
|
||||
/* To the left */
|
||||
while ((left_index > 0) &&
|
||||
while ((left_index >= 0) &&
|
||||
(grapheme_breaks[left_index] != GRAPHEMEBREAK_BREAK))
|
||||
{
|
||||
left_index--;
|
||||
}
|
||||
|
||||
temp_index = left_index - it->text_pos + 1;
|
||||
if (temp_index < 0)
|
||||
temp_index = 0;
|
||||
|
||||
ENFN->font_pen_coords_get(ENC,
|
||||
ti->parent.format->font.font,
|
||||
&ti->text_props,
|
||||
left_index - it->text_pos + 1,
|
||||
temp_index,
|
||||
&lx, NULL, NULL, NULL);
|
||||
|
||||
/* To the right */
|
||||
|
|
|
@ -1003,6 +1003,20 @@ EFL_START_TEST(evas_textblock_cursor)
|
|||
while (evas_textblock_cursor_char_prev(cur2)) j++;
|
||||
ck_assert_int_eq(j, 4);
|
||||
|
||||
//make sure if we have cluster at line start we return to pos 0
|
||||
Evas_Coord x_coord, y_coord;
|
||||
int pos;
|
||||
|
||||
cur2 = evas_object_textblock_cursor_new(tb);
|
||||
evas_object_textblock_text_markup_set(tb, "☪️");
|
||||
|
||||
evas_textblock_cursor_char_next(cur2);
|
||||
evas_textblock_cursor_pen_geometry_get(cur2, &x_coord, &y_coord, NULL, NULL);
|
||||
evas_textblock_cursor_cluster_coord_set(cur, x_coord, y_coord);
|
||||
pos = evas_textblock_cursor_pos_get(cur);
|
||||
|
||||
ck_assert_int_eq(pos, 0);
|
||||
|
||||
END_TB_TEST();
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
|
Loading…
Reference in New Issue