summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2016-02-12 20:18:05 +0900
committerHermet Park <hermet@hermet.pe.kr>2016-02-12 20:18:05 +0900
commitc0a0d801953593e51cfbf93faae98156cd55f3e4 (patch)
tree05e418f5af060f3c03decea8478f1cf02a716ba9
parent5bca505bddd7619a652985d57f25a70b7f003419 (diff)
downloadelementary-c0a0d801953593e51cfbf93faae98156cd55f3e4.tar.gz
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
-rw-r--r--src/bin/test_entry.c9
-rw-r--r--src/lib/elm_entry.c21
-rw-r--r--src/lib/elm_entry.eo6
3 files changed, 32 insertions, 4 deletions
diff --git a/src/bin/test_entry.c b/src/bin/test_entry.c
index b679f3a58..f79505e81 100644
--- a/src/bin/test_entry.c
+++ b/src/bin/test_entry.c
@@ -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");
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index b6df9c8f7..70cc5ae96 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -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
diff --git a/src/lib/elm_entry.eo b/src/lib/elm_entry.eo
index 1609cb3ed..166c6c75b 100644
--- a/src/lib/elm_entry.eo
+++ b/src/lib/elm_entry.eo
@@ -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.]]