forked from enlightenment/efl
Evas textblock: Correct word start/end moving at new line or line begins with spaces
Summary: Word start/end works incorrectly when it goes to new line or line begins with spaces. Ex: In elementary_test/Entry, place cursor at the end of line, press ctrl + right arrow keys: cursor moves to begin of next line. In this case, cursor should move to end of 1st word in next line. Ex2: In elementary_test/Entry, add some spaces to begin of 2nd line (" uses markup"), place cursor at the first word ("uses"), press ctrl + left arrow keys twice, cursor moves to begin of 2nd line. In this case, cursor should move to begin of last word in 1st line. This patch provides a fix by considerring next/previous text node to move cursor to correct place. @fix Reviewers: woohyun, raster, tasn Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1140
This commit is contained in:
parent
8c677a1f0e
commit
104f04eda1
|
@ -7349,7 +7349,23 @@ evas_textblock_cursor_word_start(Evas_Textblock_Cursor *cur)
|
|||
|
||||
for (i = cur->pos ; _is_white(text[i]) && BREAK_AFTER(i) ; i--)
|
||||
{
|
||||
if (i == 0) break;
|
||||
if (i == 0)
|
||||
{
|
||||
Evas_Object_Textblock_Node_Text *pnode;
|
||||
pnode = _NODE_TEXT(EINA_INLIST_GET(cur->node)->prev);
|
||||
if (pnode)
|
||||
{
|
||||
cur->node = pnode;
|
||||
len = eina_ustrbuf_length_get(cur->node->unicode);
|
||||
cur->pos = len - 1;
|
||||
free(breaks);
|
||||
return evas_textblock_cursor_word_start(cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( ; i > 0 ; i--)
|
||||
|
@ -7390,6 +7406,18 @@ evas_textblock_cursor_word_end(Evas_Textblock_Cursor *cur)
|
|||
}
|
||||
|
||||
for (i = cur->pos; text[i] && _is_white(text[i]) && (BREAK_AFTER(i)) ; i++);
|
||||
if (i == len)
|
||||
{
|
||||
Evas_Object_Textblock_Node_Text *nnode;
|
||||
nnode = _NODE_TEXT(EINA_INLIST_GET(cur->node)->next);
|
||||
if (nnode)
|
||||
{
|
||||
cur->node = nnode;
|
||||
cur->pos = 0;
|
||||
free(breaks);
|
||||
return evas_textblock_cursor_word_end(cur);
|
||||
}
|
||||
}
|
||||
|
||||
for ( ; text[i] ; i++)
|
||||
{
|
||||
|
|
|
@ -637,6 +637,18 @@ START_TEST(evas_textblock_cursor)
|
|||
|
||||
evas_textblock_cursor_word_end(cur);
|
||||
ck_assert_int_eq(5, evas_textblock_cursor_pos_get(cur));
|
||||
|
||||
/* moving across paragraphs */
|
||||
evas_object_textblock_text_markup_set(tb,
|
||||
"test<ps/>"
|
||||
" case");
|
||||
evas_textblock_cursor_pos_set(cur, 4);
|
||||
evas_textblock_cursor_word_end(cur);
|
||||
ck_assert_int_eq(10, evas_textblock_cursor_pos_get(cur));
|
||||
|
||||
evas_textblock_cursor_pos_set(cur, 6);
|
||||
evas_textblock_cursor_word_start(cur);
|
||||
ck_assert_int_eq(0, evas_textblock_cursor_pos_get(cur));
|
||||
}
|
||||
|
||||
/* Make sure coords are correct for ligatures */
|
||||
|
|
Loading…
Reference in New Issue