forked from enlightenment/efl
entry: add elm_entry_select_region_get() API
Summary: Already, there is a way to set a selection region: elm_entry_select_region_set() The get() API also useful and there is needs for this inside of elm_entry.c. Add the API and replace codes in atspi_text_selection_get with the API. @feature Test Plan: 1. Run "elementary_test -to entry3" 2. Make a selection on text. 3. Press "Sel" button. Reviewers: tasn, herdsman, cedric, woohyun, Jaehyun, Hermet Subscribers: Hermet Differential Revision: https://phab.enlightenment.org/D3639
This commit is contained in:
parent
e1a0dc5518
commit
b01d3c9e1b
|
@ -35,6 +35,9 @@ my_entry_bt_3(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
{
|
||||
Evas_Object *en = data;
|
||||
const char *s = elm_entry_selection_get(en);
|
||||
int start = 0, end = 0;
|
||||
elm_entry_select_region_get(en, &start, &end);
|
||||
printf("SELECTION REGION: %d - %d\n", start, end);
|
||||
printf("SELECTION:\n");
|
||||
if (s) printf("%s\n", s);
|
||||
printf("SELECTION PLAIN UTF8:\n");
|
||||
|
@ -256,6 +259,9 @@ my_scrolled_entry_bt_3(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf
|
|||
{
|
||||
Evas_Object *en = data;
|
||||
const char *s = elm_entry_selection_get(en);
|
||||
int start = 0, end = 0;
|
||||
elm_entry_select_region_get(en, &start, &end);
|
||||
printf("SELECTION REGION: %d - %d\n", start, end);
|
||||
printf("SELECTION:\n");
|
||||
if (s) printf("%s\n", s);
|
||||
printf("SELECTION PLAIN UTF8:\n");
|
||||
|
@ -685,6 +691,9 @@ my_ent_bt_sel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
{
|
||||
Evas_Object *en = data;
|
||||
const char *s = elm_entry_selection_get(en);
|
||||
int start = 0, end = 0;
|
||||
elm_entry_select_region_get(en, &start, &end);
|
||||
printf("SELECTION REGION: %d - %d\n", start, end);
|
||||
printf("SELECTION:\n");
|
||||
if (s) printf("%s\n", s);
|
||||
printf("SELECTION PLAIN UTF8:\n");
|
||||
|
|
|
@ -4176,6 +4176,22 @@ _elm_entry_select_region_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, int start,
|
|||
edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_entry_select_region_get(Eo *obj, Elm_Entry_Data *sd, int *start, int *end)
|
||||
{
|
||||
if (!elm_entry_selection_get(obj))
|
||||
{
|
||||
if (start) *start = -1;
|
||||
if (end) *end = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (start)
|
||||
*start = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_BEGIN);
|
||||
if (end)
|
||||
*end = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_END);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_entry_cursor_geometry_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
||||
{
|
||||
|
@ -5428,12 +5444,9 @@ _elm_entry_elm_interface_atspi_text_selections_count_get(Eo *obj, Elm_Entry_Data
|
|||
EOLIAN static void
|
||||
_elm_entry_elm_interface_atspi_text_selection_get(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, int selection_number, int *start_offset, int *end_offset)
|
||||
{
|
||||
*start_offset = *end_offset = -1;
|
||||
if (!elm_entry_selection_get(obj)) return;
|
||||
if (selection_number != 0) return;
|
||||
|
||||
*start_offset = edje_object_part_text_cursor_pos_get(_pd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_BEGIN);
|
||||
*end_offset = edje_object_part_text_cursor_pos_get(_pd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_END);
|
||||
eo_do(obj, elm_obj_entry_select_region_get(start_offset, end_offset));
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
|
|
|
@ -493,6 +493,12 @@ class Elm.Entry (Elm.Layout, Elm.Interface_Scrollable, Evas.Clickable_Interface,
|
|||
@since 1.9
|
||||
]]
|
||||
}
|
||||
get {
|
||||
[[Get the current position of the selection cursors in the entry.
|
||||
|
||||
@since 1.18
|
||||
]]
|
||||
}
|
||||
values {
|
||||
start: int; [[The starting position.]]
|
||||
end: int; [[The end position.]]
|
||||
|
|
Loading…
Reference in New Issue