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)
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
35{ 35{
36 Evas_Object *en = data; 36 Evas_Object *en = data;
37 const char *s = elm_entry_selection_get(en); 37 const char *s = elm_entry_selection_get(en);
38 int start = 0, end = 0;
39 elm_entry_select_region_get(en, &start, &end);
40 printf("SELECTION REGION: %d - %d\n", start, end);
38 printf("SELECTION:\n"); 41 printf("SELECTION:\n");
39 if (s) printf("%s\n", s); 42 if (s) printf("%s\n", s);
40 printf("SELECTION PLAIN UTF8:\n"); 43 printf("SELECTION PLAIN UTF8:\n");
@@ -256,6 +259,9 @@ my_scrolled_entry_bt_3(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf
256{ 259{
257 Evas_Object *en = data; 260 Evas_Object *en = data;
258 const char *s = elm_entry_selection_get(en); 261 const char *s = elm_entry_selection_get(en);
262 int start = 0, end = 0;
263 elm_entry_select_region_get(en, &start, &end);
264 printf("SELECTION REGION: %d - %d\n", start, end);
259 printf("SELECTION:\n"); 265 printf("SELECTION:\n");
260 if (s) printf("%s\n", s); 266 if (s) printf("%s\n", s);
261 printf("SELECTION PLAIN UTF8:\n"); 267 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
685{ 691{
686 Evas_Object *en = data; 692 Evas_Object *en = data;
687 const char *s = elm_entry_selection_get(en); 693 const char *s = elm_entry_selection_get(en);
694 int start = 0, end = 0;
695 elm_entry_select_region_get(en, &start, &end);
696 printf("SELECTION REGION: %d - %d\n", start, end);
688 printf("SELECTION:\n"); 697 printf("SELECTION:\n");
689 if (s) printf("%s\n", s); 698 if (s) printf("%s\n", s);
690 printf("SELECTION PLAIN UTF8:\n"); 699 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,
4176 edje_object_part_text_select_extend(sd->entry_edje, "elm.text"); 4176 edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
4177} 4177}
4178 4178
4179EOLIAN static void
4180_elm_entry_select_region_get(Eo *obj, Elm_Entry_Data *sd, int *start, int *end)
4181{
4182 if (!elm_entry_selection_get(obj))
4183 {
4184 if (start) *start = -1;
4185 if (end) *end = -1;
4186 return;
4187 }
4188
4189 if (start)
4190 *start = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_BEGIN);
4191 if (end)
4192 *end = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_END);
4193}
4194
4179EOLIAN static Eina_Bool 4195EOLIAN static Eina_Bool
4180_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) 4196_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)
4181{ 4197{
@@ -5428,12 +5444,9 @@ _elm_entry_elm_interface_atspi_text_selections_count_get(Eo *obj, Elm_Entry_Data
5428EOLIAN static void 5444EOLIAN static void
5429_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) 5445_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)
5430{ 5446{
5431 *start_offset = *end_offset = -1;
5432 if (!elm_entry_selection_get(obj)) return;
5433 if (selection_number != 0) return; 5447 if (selection_number != 0) return;
5434 5448
5435 *start_offset = edje_object_part_text_cursor_pos_get(_pd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_BEGIN); 5449 eo_do(obj, elm_obj_entry_select_region_get(start_offset, end_offset));
5436 *end_offset = edje_object_part_text_cursor_pos_get(_pd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_END);
5437} 5450}
5438 5451
5439EOLIAN static Eina_Bool 5452EOLIAN 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,
493 @since 1.9 493 @since 1.9
494 ]] 494 ]]
495 } 495 }
496 get {
497 [[Get the current position of the selection cursors in the entry.
498
499 @since 1.18
500 ]]
501 }
496 values { 502 values {
497 start: int; [[The starting position.]] 503 start: int; [[The starting position.]]
498 end: int; [[The end position.]] 504 end: int; [[The end position.]]