forked from enlightenment/efl
efl_text_cursor: movement word start/end
Summary: This patch will make **efl_text_cursor_move** method, when it is working with **WORD_START** or **WORD_END** If no actual movement happened then return false, and do not fire CHANGE event for example if cursor at word start, and we call efl_text_cursor_move(cursor, word_start); 1- this call should return false because no actual movement happened. If no actual movement happened then return false 2- this call should not fire CHANGE event for cursor.and do not fire CHANGE event Reviewers: woohyun, segfaultxavi, cedric, zmike Reviewed By: woohyun Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8454 Differential Revision: https://phab.enlightenment.org/D10949
This commit is contained in:
parent
84685df233
commit
a239fc4a1a
|
@ -9954,6 +9954,7 @@ evas_textblock_cursor_word_start(Efl_Text_Cursor_Handle *cur)
|
|||
const Eina_Unicode *text;
|
||||
size_t i;
|
||||
char *breaks;
|
||||
size_t old_cursor_pos = cur->pos;
|
||||
|
||||
Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, EFL_CANVAS_OBJECT_CLASS);
|
||||
evas_object_async_block(obj);
|
||||
|
@ -10004,8 +10005,12 @@ evas_textblock_cursor_word_start(Efl_Text_Cursor_Handle *cur)
|
|||
cur->pos = i;
|
||||
|
||||
free(breaks);
|
||||
if (cur->pos != old_cursor_pos)
|
||||
{
|
||||
_evas_textblock_cursor_object_changed(cur);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
|
@ -10015,6 +10020,7 @@ evas_textblock_cursor_word_end(Efl_Text_Cursor_Handle *cur)
|
|||
const Eina_Unicode *text;
|
||||
size_t i;
|
||||
char *breaks;
|
||||
size_t old_cursor_pos = cur->pos;
|
||||
|
||||
Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, EFL_CANVAS_OBJECT_CLASS);
|
||||
evas_object_async_block(obj);
|
||||
|
@ -10022,8 +10028,9 @@ evas_textblock_cursor_word_end(Efl_Text_Cursor_Handle *cur)
|
|||
|
||||
size_t len = eina_ustrbuf_length_get(cur->node->unicode);
|
||||
|
||||
// No movement happend, return false
|
||||
if (cur->pos == len)
|
||||
return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
|
||||
text = eina_ustrbuf_string_get(cur->node->unicode);
|
||||
|
||||
|
@ -10059,8 +10066,12 @@ evas_textblock_cursor_word_end(Efl_Text_Cursor_Handle *cur)
|
|||
cur->pos = i;
|
||||
|
||||
free(breaks);
|
||||
if (cur->pos != old_cursor_pos)
|
||||
{
|
||||
_evas_textblock_cursor_object_changed(cur);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
|
@ -4513,7 +4513,6 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
|
|||
efl_text_set(txt, "");
|
||||
efl_text_set(txt, "");
|
||||
efl_text_cursor_text_insert(cursor1, "aa");
|
||||
|
||||
ck_assert_int_eq(changed_emit, 3);
|
||||
|
||||
Eo *cursor_temp = efl_add(EFL_TEXT_CURSOR_CLASS, txt);
|
||||
|
@ -4528,6 +4527,21 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
|
|||
efl_text_cursor_line_jump_by(cur_obj, -1);
|
||||
ck_assert_int_eq(efl_text_cursor_position_get(cur_obj), 0);
|
||||
|
||||
efl_text_set(txt, "Word");
|
||||
efl_text_cursor_position_set(cur_obj, 1);
|
||||
changed_emit = 0;
|
||||
efl_event_callback_add(cur_obj, EFL_TEXT_CURSOR_EVENT_CHANGED, _increment_int_changed, &changed_emit);
|
||||
ck_assert(efl_text_cursor_move(cur_obj, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START));
|
||||
ck_assert_int_eq(changed_emit, 1);
|
||||
|
||||
ck_assert(!efl_text_cursor_move(cur_obj, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START));
|
||||
ck_assert_int_eq(changed_emit, 1);
|
||||
|
||||
ck_assert(efl_text_cursor_move(cur_obj, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END));
|
||||
ck_assert_int_eq(changed_emit, 2);
|
||||
|
||||
ck_assert(!efl_text_cursor_move(cur_obj, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END));
|
||||
ck_assert_int_eq(changed_emit, 2);
|
||||
|
||||
END_EFL_CANVAS_TEXTBLOCK_TEST();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue