Edje: Add have_selection check to avoid unnecessary function calls

Summary:
Check for have_selection flag when left/arrow keys are pressed to jump
across the selected text, to avoid unnecessary function calls of
comparision, copy of sel_start and sel_end pointers.

Test Plan: Press left and right arrow keys on selected and normal text.

Reviewers: herdsman, tasn

Subscribers: SubodhKumar, navnbeet, cedric

Differential Revision: https://phab.enlightenment.org/D2621
This commit is contained in:
shilpa.singh 2015-06-03 16:39:42 +01:00 committed by Tom Hacohen
parent a88aebe8cc
commit a867caf260
1 changed files with 16 additions and 10 deletions

View File

@ -1502,11 +1502,14 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
} }
else else
{ {
if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0) if (en->have_selection)
evas_textblock_cursor_copy(en->sel_start, en->cursor); {
else if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
evas_textblock_cursor_copy(en->sel_end, en->cursor); evas_textblock_cursor_copy(en->sel_start, en->cursor);
_sel_clear(ed, en->cursor, rp->object, en); else
evas_textblock_cursor_copy(en->sel_end, en->cursor);
_sel_clear(ed, en->cursor, rp->object, en);
}
} }
} }
if (evas_textblock_cursor_char_prev(en->cursor)) if (evas_textblock_cursor_char_prev(en->cursor))
@ -1537,11 +1540,14 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
} }
else else
{ {
if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0) if (en->have_selection)
evas_textblock_cursor_copy(en->sel_end, en->cursor); {
else if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
evas_textblock_cursor_copy(en->sel_start, en->cursor); evas_textblock_cursor_copy(en->sel_end, en->cursor);
_sel_clear(ed, en->cursor, rp->object, en); else
evas_textblock_cursor_copy(en->sel_start, en->cursor);
_sel_clear(ed, en->cursor, rp->object, en);
}
} }
} }
/* If control is pressed, go to the end of the word */ /* If control is pressed, go to the end of the word */