summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-01-21 07:39:14 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-01-21 07:39:15 +0900
commit09f0d66d90e4db5f879f4c998e8a07b26fa749fc (patch)
tree3be90d3e0efc1abbf748eb0c5d13c999ca2e6ff2
parent292f4bc0da8bf2432c344f03797f70b89267db26 (diff)
efl_text_interactive: selection enhancment
Summary: 1- Implement setting selection range programmatically by modifying selection cursors from **efl_text_interactive_selection_cursors_get** 2- Add setter with **efl_text_interactive_selection_cursors_set** to set the range at once (modify start and end) Reviewers: woohyun, segfaultxavi, zmike, bu5hm4n Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8521, T8522 Differential Revision: https://phab.enlightenment.org/D10968
-rw-r--r--src/lib/elementary/efl_text_interactive.eo14
-rw-r--r--src/lib/elementary/efl_ui_internal_text_interactive.c172
-rw-r--r--src/lib/elementary/efl_ui_internal_text_interactive.eo2
-rw-r--r--src/tests/elementary/efl_ui_test_text.c39
4 files changed, 167 insertions, 60 deletions
diff --git a/src/lib/elementary/efl_text_interactive.eo b/src/lib/elementary/efl_text_interactive.eo
index 933aad0cb1..2f16ce89d8 100644
--- a/src/lib/elementary/efl_text_interactive.eo
+++ b/src/lib/elementary/efl_text_interactive.eo
@@ -25,13 +25,17 @@ interface @beta Efl.Text_Interactive extends Efl.Text, Efl.Text_Font_Properties,
25 } 25 }
26 @property selection_cursors { 26 @property selection_cursors {
27 [[The cursors used for selection handling. 27 [[The cursors used for selection handling.
28
29 If the cursors are equal there's no selection. 28 If the cursors are equal there's no selection.
30
31 You are allowed to retain and modify them. Modifying them modifies
32 the selection of the object.
33 ]] 29 ]]
34 get {} 30 get {
31 [[You are allowed to retain and modify them. Modifying them modifies
32 the selection of the object (recommended to extend selection range).]]
33 }
34 set {
35 [[The positions of passed cursors will be used to set selection cursors positions.
36 Further modification for passed @Efl.Text.Cursor objects, will not affect selection.
37 Setter is recommended to set new range for selection.]]
38 }
35 values { 39 values {
36 start: Efl.Text.Cursor; [[The start of the selection.]] 40 start: Efl.Text.Cursor; [[The start of the selection.]]
37 end: Efl.Text.Cursor; [[The end of the selection.]] 41 end: Efl.Text.Cursor; [[The end of the selection.]]
diff --git a/src/lib/elementary/efl_ui_internal_text_interactive.c b/src/lib/elementary/efl_ui_internal_text_interactive.c
index 8c39ed6287..42d3bdb8bb 100644
--- a/src/lib/elementary/efl_ui_internal_text_interactive.c
+++ b/src/lib/elementary/efl_ui_internal_text_interactive.c
@@ -14,6 +14,7 @@
14typedef struct _Efl_Ui_Internal_Text_Interactive_Data 14typedef struct _Efl_Ui_Internal_Text_Interactive_Data
15{ 15{
16 Efl_Text_Cursor *sel_start, *sel_end; 16 Efl_Text_Cursor *sel_start, *sel_end;
17 int sel_start_pos, sel_end_pos;
17 Efl_Text_Cursor *main_cursor; 18 Efl_Text_Cursor *main_cursor;
18 Efl_Text_Cursor *preedit_start, *preedit_end; 19 Efl_Text_Cursor *preedit_start, *preedit_end;
19 Ecore_Timer *pw_timer; 20 Ecore_Timer *pw_timer;
@@ -44,10 +45,11 @@ typedef struct _Efl_Ui_Internal_Text_Interactive_Data
44} Efl_Ui_Internal_Text_Interactive_Data; 45} Efl_Ui_Internal_Text_Interactive_Data;
45 46
46static void _sel_range_del_emit(Evas_Object *obj, Efl_Ui_Internal_Text_Interactive_Data *en); 47static void _sel_range_del_emit(Evas_Object *obj, Efl_Ui_Internal_Text_Interactive_Data *en);
47static void _sel_init(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive_Data *en); 48static void _sel_init(Efl_Text_Cursor *c, Efl_Ui_Internal_Text_Interactive_Data *en);
48static void _sel_enable(Efl_Text_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en); 49static void _sel_enable(Evas_Object *o,Efl_Ui_Internal_Text_Interactive_Data *en, Eina_Bool emit_event);
49static void _sel_extend(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive_Data *en); 50static void _sel_extend(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive_Data *en, Eina_Bool emit_event);
50static void _sel_clear(Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en); 51static void _sel_clear(Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en, Eina_Bool emit_event);
52static void _emit_sel_state( Eo *o, Efl_Ui_Internal_Text_Interactive_Data *en);
51static const char *_entry_selection_get(Efl_Ui_Internal_Text_Interactive *obj, Efl_Ui_Internal_Text_Interactive_Data *en); 53static const char *_entry_selection_get(Efl_Ui_Internal_Text_Interactive *obj, Efl_Ui_Internal_Text_Interactive_Data *en);
52static void _entry_imf_cursor_info_set(Efl_Ui_Internal_Text_Interactive_Data *en); 54static void _entry_imf_cursor_info_set(Efl_Ui_Internal_Text_Interactive_Data *en);
53 55
@@ -201,7 +203,7 @@ _entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void
201 { 203 {
202 /* delete selected characters */ 204 /* delete selected characters */
203 _sel_range_del_emit(obj, en); 205 _sel_range_del_emit(obj, en);
204 _sel_clear(obj, en); 206 _sel_clear(obj, en, EINA_TRUE);
205 } 207 }
206 } 208 }
207 209
@@ -626,12 +628,12 @@ _entry_imf_event_selection_set_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED
626 } 628 }
627 else 629 else
628 { 630 {
629 _sel_clear(obj, en); 631 _sel_clear(obj, en, EINA_TRUE);
630 efl_text_cursor_position_set(cur, ev->start); 632 efl_text_cursor_position_set(cur, ev->start);
631 _sel_enable(cur, obj, en); 633 _sel_enable(obj, en, EINA_TRUE);
632 _sel_init(cur, obj, en); 634 _sel_init(cur, en);
633 efl_text_cursor_position_set(cur, ev->end); 635 efl_text_cursor_position_set(cur, ev->end);
634 _sel_extend(cur, obj, en); 636 _sel_extend(cur, obj, en, EINA_TRUE);
635 } 637 }
636} 638}
637 639
@@ -747,18 +749,64 @@ _entry_selection_get(Efl_Ui_Internal_Text_Interactive *obj EINA_UNUSED, Efl_Ui_I
747} 749}
748 750
749static void 751static void
752_sel_reset(Eo *obj, Efl_Ui_Internal_Text_Interactive_Data *en){
753 if (!en->have_selection && efl_text_cursor_equal(en->sel_start, en->sel_end))
754 return;
755
756 if ( en->sel_start_pos == efl_text_cursor_position_get(en->sel_start) &&
757 en->sel_end_pos == efl_text_cursor_position_get(en->sel_end))
758 return;
759
760 if (en->have_selection)
761 {
762 if (efl_text_cursor_equal(en->sel_start, en->sel_end))
763 {
764 _sel_clear(obj, en, EINA_TRUE);
765 }
766 else
767 {
768 _entry_imf_cursor_info_set(en);
769 if (en->selection)
770 {
771 free(en->selection);
772 en->selection = NULL;
773 }
774 _emit_sel_state(obj, en);
775 }
776 }
777 else
778 {
779 if (!efl_text_cursor_equal(en->sel_start, en->sel_end))
780 {
781 _sel_enable(obj, en, EINA_TRUE);
782 _entry_imf_cursor_info_set(en);
783 if (en->selection)
784 {
785 free(en->selection);
786 en->selection = NULL;
787 }
788 _emit_sel_state(obj, en);
789 }
790 }
791}
792
793static void
750_sel_cursor_changed(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 794_sel_cursor_changed(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
751{ 795{
752// Eo *obj = data; 796 Efl_Ui_Internal_Text_Interactive *obj = data;
797 Efl_Ui_Internal_Text_Interactive_Data *en = efl_data_scope_get(obj, MY_CLASS);
798 _sel_reset(obj, en);
753} 799}
754 800
755static void 801static void
756_sel_init(Efl_Text_Cursor *c, Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en) 802_sel_init(Efl_Text_Cursor *c, Efl_Ui_Internal_Text_Interactive_Data *en)
757{ 803{
758 if (en->have_selection) 804 if (en->have_selection)
759 return; 805 return;
760 806
807 en->sel_start_pos = efl_text_cursor_position_get(c);
761 _cur_pos_copy(c, en->sel_start); 808 _cur_pos_copy(c, en->sel_start);
809 en->sel_end_pos = efl_text_cursor_position_get(c);
762 _cur_pos_copy(c, en->sel_end); 810 _cur_pos_copy(c, en->sel_end);
763 811
764 en->have_selection = EINA_FALSE; 812 en->have_selection = EINA_FALSE;
@@ -770,8 +818,7 @@ _sel_init(Efl_Text_Cursor *c, Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_I
770} 818}
771 819
772static void 820static void
773_sel_enable(Efl_Text_Cursor *c EINA_UNUSED, 821_sel_enable(Eo *o, Efl_Ui_Internal_Text_Interactive_Data *en, Eina_Bool emit_event)
774 Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en)
775{ 822{
776 if (en->have_selection) return; 823 if (en->have_selection) return;
777 en->have_selection = EINA_TRUE; 824 en->have_selection = EINA_TRUE;
@@ -781,8 +828,11 @@ _sel_enable(Efl_Text_Cursor *c EINA_UNUSED,
781 en->selection = NULL; 828 en->selection = NULL;
782 } 829 }
783 830
784 Eina_Bool b_value = EINA_TRUE; 831 if (emit_event)
785 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value); 832 {
833 Eina_Bool b_value = EINA_TRUE;
834 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value);
835 }
786 _entry_imf_context_reset(en); 836 _entry_imf_context_reset(en);
787} 837}
788 838
@@ -791,8 +841,7 @@ _emit_sel_state( Eo *o, Efl_Ui_Internal_Text_Interactive_Data *en)
791{ 841{
792 if (!efl_text_cursor_compare(en->sel_start, en->sel_end)) 842 if (!efl_text_cursor_compare(en->sel_start, en->sel_end))
793 { 843 {
794 Eina_Bool b_value = EINA_FALSE; 844 _sel_clear(o, en, EINA_TRUE);
795 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value);
796 } 845 }
797 else 846 else
798 { 847 {
@@ -804,12 +853,12 @@ _emit_sel_state( Eo *o, Efl_Ui_Internal_Text_Interactive_Data *en)
804} 853}
805 854
806static void 855static void
807_sel_extend(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive_Data *en) 856_sel_extend(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive_Data *en, Eina_Bool emit_event)
808{ 857{
809 if (!en->sel_end) return; 858 _sel_enable(o, en, emit_event);
810 _sel_enable(c, o, en);
811 if (efl_text_cursor_equal(c, en->sel_end)) return; 859 if (efl_text_cursor_equal(c, en->sel_end)) return;
812 860
861 en->sel_end_pos = efl_text_cursor_position_get(c);
813 _cur_pos_copy(c, en->sel_end); 862 _cur_pos_copy(c, en->sel_end);
814 863
815 _entry_imf_cursor_info_set(en); 864 _entry_imf_cursor_info_set(en);
@@ -824,7 +873,7 @@ _sel_extend(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive
824} 873}
825 874
826static void 875static void
827_sel_clear(Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en) 876_sel_clear(Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en, Eina_Bool emit_change)
828{ 877{
829 en->had_sel = EINA_FALSE; 878 en->had_sel = EINA_FALSE;
830 if (en->selection) 879 if (en->selection)
@@ -836,8 +885,10 @@ _sel_clear(Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en
836 { 885 {
837 en->have_selection = EINA_FALSE; 886 en->have_selection = EINA_FALSE;
838 Eina_Bool b_value = en->have_selection; 887 Eina_Bool b_value = en->have_selection;
888 en->sel_start_pos = en->sel_end_pos = efl_text_cursor_position_get(en->sel_start);
839 _cur_pos_copy(en->sel_start, en->sel_end); 889 _cur_pos_copy(en->sel_start, en->sel_end);
840 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value); 890 if (emit_change)
891 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value);
841 } 892 }
842} 893}
843 894
@@ -845,32 +896,32 @@ EOLIAN static void
845_efl_ui_internal_text_interactive_efl_text_interactive_all_unselect( 896_efl_ui_internal_text_interactive_efl_text_interactive_all_unselect(
846 Eo *obj, Efl_Ui_Internal_Text_Interactive_Data *en) 897 Eo *obj, Efl_Ui_Internal_Text_Interactive_Data *en)
847{ 898{
848 _sel_clear(obj, en); 899 _sel_clear(obj, en, EINA_TRUE);
849} 900}
850 901
851EOLIAN static Eina_Bool 902EOLIAN static Eina_Bool
852_efl_ui_internal_text_interactive_efl_text_interactive_have_selection_get( 903_efl_ui_internal_text_interactive_efl_text_interactive_have_selection_get(
853 const Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en) 904 const Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en)
854{ 905{
906 if (!en->have_selection) return en->have_selection;
855 return !efl_text_cursor_equal(en->sel_start, en->sel_end); 907 return !efl_text_cursor_equal(en->sel_start, en->sel_end);
856} 908}
857 909
858 910
859EOLIAN static void 911EOLIAN static void
860_efl_ui_internal_text_interactive_efl_text_interactive_all_select( 912_efl_ui_internal_text_interactive_efl_text_interactive_all_select(
861 Eo *obj, Efl_Ui_Internal_Text_Interactive_Data *en) 913 Eo *obj, Efl_Ui_Internal_Text_Interactive_Data *en EINA_UNUSED)
862{ 914{
863 if (!efl_text_interactive_selection_allowed_get(obj)) 915 if (!efl_text_interactive_selection_allowed_get(obj))
864 return; 916 return;
865 917
866 Efl_Text_Cursor *cur = efl_text_interactive_main_cursor_get(obj); 918 Eo *c1 = efl_canvas_textblock_cursor_create(obj);
867 _entry_imf_context_reset(en); 919 Eo *c2 = efl_canvas_textblock_cursor_create(obj);
868 920
869 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_FIRST); 921 efl_text_cursor_move(c1, EFL_TEXT_CURSOR_MOVE_TYPE_FIRST);
870 _entry_imf_context_reset(en); 922 efl_text_cursor_move(c2, EFL_TEXT_CURSOR_MOVE_TYPE_LAST);
871 _sel_init(cur, obj, en); 923
872 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LAST); 924 efl_text_interactive_selection_cursors_set(obj, c1, c2);
873 _sel_extend(cur, obj, en);
874} 925}
875 926
876 927
@@ -903,7 +954,7 @@ static void
903_sel_range_del_emit(Evas_Object *obj, Efl_Ui_Internal_Text_Interactive_Data *en) 954_sel_range_del_emit(Evas_Object *obj, Efl_Ui_Internal_Text_Interactive_Data *en)
904{ 955{
905 _range_del_emit(obj, en->sel_start, en->sel_end); 956 _range_del_emit(obj, en->sel_start, en->sel_end);
906 _sel_clear(obj, en); 957 _sel_clear(obj, en, EINA_TRUE);
907} 958}
908 959
909static void 960static void
@@ -1024,7 +1075,7 @@ _key_down_sel_pre(Efl_Ui_Internal_Text_Interactive *obj, Efl_Text_Cursor *cur, E
1024 { 1075 {
1025 if (shift) 1076 if (shift)
1026 { 1077 {
1027 _sel_init(cur, obj, en); 1078 _sel_init(cur, en);
1028 } 1079 }
1029 else if (en->have_selection) 1080 else if (en->have_selection)
1030 { 1081 {
@@ -1032,8 +1083,9 @@ _key_down_sel_pre(Efl_Ui_Internal_Text_Interactive *obj, Efl_Text_Cursor *cur, E
1032 if ((sel_forward && movement_forward) || (!sel_forward && !movement_forward)) 1083 if ((sel_forward && movement_forward) || (!sel_forward && !movement_forward))
1033 _cur_pos_copy(en->sel_end, cur); 1084 _cur_pos_copy(en->sel_end, cur);
1034 else 1085 else
1035 _cur_pos_copy(en->sel_start, cur); 1086
1036 _sel_clear(obj, en); 1087 _cur_pos_copy(en->sel_start, cur);
1088 _sel_clear(obj, en, EINA_TRUE);
1037 } 1089 }
1038 } 1090 }
1039} 1091}
@@ -1043,8 +1095,8 @@ _key_down_sel_post(Efl_Ui_Internal_Text_Interactive *obj, Efl_Text_Cursor *cur,
1043{ 1095{
1044 if (en->select_allow) 1096 if (en->select_allow)
1045 { 1097 {
1046 if (shift) _sel_extend(cur, obj, en); 1098 if (shift) _sel_extend(cur, obj, en, EINA_TRUE);
1047 else _sel_clear(obj, en); 1099 else _sel_clear(obj, en, EINA_TRUE);
1048 } 1100 }
1049} 1101}
1050 1102
@@ -1237,7 +1289,7 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1237 _delete_emit(obj, cur, en, old_cur_pos, EINA_TRUE); 1289 _delete_emit(obj, cur, en, old_cur_pos, EINA_TRUE);
1238 } 1290 }
1239 } 1291 }
1240 _sel_clear(obj, en); 1292 _sel_clear(obj, en, EINA_TRUE);
1241 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1293 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1242 } 1294 }
1243 else if (!strcmp(ev->key, "Delete") || 1295 else if (!strcmp(ev->key, "Delete") ||
@@ -1273,7 +1325,7 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1273 _delete_emit(obj, cur, en, old_cur_pos, EINA_FALSE); 1325 _delete_emit(obj, cur, en, old_cur_pos, EINA_FALSE);
1274 } 1326 }
1275 } 1327 }
1276 _sel_clear(obj, en); 1328 _sel_clear(obj, en, EINA_TRUE);
1277 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1329 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1278 } 1330 }
1279 else if ((!alt) && 1331 else if ((!alt) &&
@@ -1561,19 +1613,19 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1561 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START); 1613 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START);
1562 else 1614 else
1563 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END); 1615 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END);
1564 _sel_extend(cur, obj, en); 1616 _sel_extend(cur, obj, en, EINA_TRUE);
1565 } 1617 }
1566 else 1618 else
1567 { 1619 {
1568 en->have_selection = EINA_FALSE; 1620 en->have_selection = EINA_FALSE;
1569 en->selecting = EINA_FALSE; 1621 en->selecting = EINA_FALSE;
1570 _sel_clear(obj, en); 1622 _sel_clear(obj, en, EINA_TRUE);
1571 tc = efl_canvas_textblock_cursor_create(obj); 1623 tc = efl_canvas_textblock_cursor_create(obj);
1572 _cur_pos_copy(cur, tc); 1624 _cur_pos_copy(cur, tc);
1573 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START); 1625 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START);
1574 _sel_init(cur, obj, en); 1626 _sel_init(cur, en);
1575 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END); 1627 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END);
1576 _sel_extend(cur, obj, en); 1628 _sel_extend(cur, obj, en, EINA_TRUE);
1577 } 1629 }
1578 goto end; 1630 goto end;
1579 } 1631 }
@@ -1590,20 +1642,20 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1590 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END); 1642 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END);
1591 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT); 1643 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT);
1592 } 1644 }
1593 _sel_extend(cur, obj, en); 1645 _sel_extend(cur, obj, en, EINA_TRUE);
1594 } 1646 }
1595 else 1647 else
1596 { 1648 {
1597 en->have_selection = EINA_FALSE; 1649 en->have_selection = EINA_FALSE;
1598 en->selecting = EINA_FALSE; 1650 en->selecting = EINA_FALSE;
1599 _sel_clear(obj, en); 1651 _sel_clear(obj, en, EINA_TRUE);
1600 tc = efl_canvas_textblock_cursor_create(obj); 1652 tc = efl_canvas_textblock_cursor_create(obj);
1601 _cur_pos_copy(cur, tc); 1653 _cur_pos_copy(cur, tc);
1602 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START); 1654 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START);
1603 _sel_init(cur, obj, en); 1655 _sel_init(cur, en);
1604 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END); 1656 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END);
1605 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT); 1657 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT);
1606 _sel_extend(cur, obj, en); 1658 _sel_extend(cur, obj, en, EINA_TRUE);
1607 } 1659 }
1608 goto end; 1660 goto end;
1609 } 1661 }
@@ -1614,13 +1666,13 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1614 { 1666 {
1615 if ((en->have_selection) && (shift)) 1667 if ((en->have_selection) && (shift))
1616 { 1668 {
1617 _sel_extend(cur, obj, en); 1669 _sel_extend(cur, obj, en, EINA_TRUE);
1618 } 1670 }
1619 else 1671 else
1620 { 1672 {
1621 en->selecting = EINA_TRUE; 1673 en->selecting = EINA_TRUE;
1622 _sel_clear(obj, en); 1674 _sel_clear(obj, en, EINA_TRUE);
1623 _sel_init(cur, obj, en); 1675 _sel_init(cur, en);
1624 } 1676 }
1625 } 1677 }
1626 1678
@@ -1716,10 +1768,10 @@ _mouse_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, vo
1716 1768
1717 if (en->select_allow) 1769 if (en->select_allow)
1718 { 1770 {
1719 _sel_extend(cur, obj, en); 1771 _sel_extend(cur, obj, en, EINA_TRUE);
1720 1772
1721 if (!efl_text_cursor_equal(en->sel_start, en->sel_end)) 1773 if (!efl_text_cursor_equal(en->sel_start, en->sel_end))
1722 _sel_enable(cur, obj, en); 1774 _sel_enable(obj, en, EINA_TRUE);
1723 } 1775 }
1724 efl_del(tc); 1776 efl_del(tc);
1725 } 1777 }
@@ -1754,7 +1806,9 @@ _efl_ui_internal_text_interactive_efl_object_finalize(Eo *obj, Efl_Ui_Internal_T
1754 en->sel_start = efl_canvas_textblock_cursor_create(obj); 1806 en->sel_start = efl_canvas_textblock_cursor_create(obj);
1755 en->sel_end = efl_canvas_textblock_cursor_create(obj); 1807 en->sel_end = efl_canvas_textblock_cursor_create(obj);
1756 1808
1757 efl_event_callback_add(efl_text_interactive_main_cursor_get(obj), EFL_TEXT_CURSOR_EVENT_CHANGED, 1809 efl_event_callback_add(en->sel_start, EFL_TEXT_CURSOR_EVENT_CHANGED,
1810 _sel_cursor_changed, obj);
1811 efl_event_callback_add(en->sel_end, EFL_TEXT_CURSOR_EVENT_CHANGED,
1758 _sel_cursor_changed, obj); 1812 _sel_cursor_changed, obj);
1759 1813
1760#ifdef HAVE_ECORE_IMF 1814#ifdef HAVE_ECORE_IMF
@@ -1847,7 +1901,7 @@ _efl_ui_internal_text_interactive_efl_text_interactive_selection_allowed_set(Eo
1847 pd->select_allow = allowed; 1901 pd->select_allow = allowed;
1848 if (!allowed) 1902 if (!allowed)
1849 { 1903 {
1850 _sel_clear(obj, pd); 1904 _sel_clear(obj, pd, EINA_TRUE);
1851 } 1905 }
1852} 1906}
1853 1907
@@ -1874,6 +1928,16 @@ _efl_ui_internal_text_interactive_efl_text_interactive_selection_cursors_get(con
1874} 1928}
1875 1929
1876EOLIAN static void 1930EOLIAN static void
1931_efl_ui_internal_text_interactive_efl_text_interactive_selection_cursors_set(Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en, Efl_Text_Cursor *start, Efl_Text_Cursor *end)
1932{
1933 en->sel_start_pos = efl_text_cursor_position_get(start);
1934 en->sel_end_pos = efl_text_cursor_position_get(en->sel_end);
1935 efl_text_cursor_position_set(en->sel_start, en->sel_start_pos);
1936 en->sel_end_pos = -1;
1937 efl_text_cursor_position_set(en->sel_end, efl_text_cursor_position_get(end));
1938}
1939
1940EOLIAN static void
1877_efl_ui_internal_text_interactive_efl_text_interactive_editable_set(Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *sd, Eina_Bool editable) 1941_efl_ui_internal_text_interactive_efl_text_interactive_editable_set(Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *sd, Eina_Bool editable)
1878{ 1942{
1879 sd->editable = editable; 1943 sd->editable = editable;
diff --git a/src/lib/elementary/efl_ui_internal_text_interactive.eo b/src/lib/elementary/efl_ui_internal_text_interactive.eo
index 448f7a0c6c..0688334500 100644
--- a/src/lib/elementary/efl_ui_internal_text_interactive.eo
+++ b/src/lib/elementary/efl_ui_internal_text_interactive.eo
@@ -9,7 +9,7 @@ class @beta Efl.Ui.Internal.Text.Interactive extends Efl.Canvas.Textblock implem
9 Efl.Object.finalize; 9 Efl.Object.finalize;
10 Efl.Text_Interactive.main_cursor { get; } 10 Efl.Text_Interactive.main_cursor { get; }
11 Efl.Text_Interactive.selection_allowed { get; set; } 11 Efl.Text_Interactive.selection_allowed { get; set; }
12 Efl.Text_Interactive.selection_cursors { get; } 12 Efl.Text_Interactive.selection_cursors { get; set; }
13 Efl.Text_Interactive.editable { get; set; } 13 Efl.Text_Interactive.editable { get; set; }
14 Efl.Text_Interactive.all_unselect; 14 Efl.Text_Interactive.all_unselect;
15 Efl.Text_Interactive.all_select; 15 Efl.Text_Interactive.all_select;
diff --git a/src/tests/elementary/efl_ui_test_text.c b/src/tests/elementary/efl_ui_test_text.c
index a49c7e7cc9..b7886544f1 100644
--- a/src/tests/elementary/efl_ui_test_text.c
+++ b/src/tests/elementary/efl_ui_test_text.c
@@ -72,6 +72,45 @@ EFL_START_TEST(text_all_select_all_unselect)
72 ecore_main_loop_iterate(); 72 ecore_main_loop_iterate();
73 ck_assert_int_eq(i_have_selection, 2); 73 ck_assert_int_eq(i_have_selection, 2);
74 ck_assert_int_eq(i_selection, 1); 74 ck_assert_int_eq(i_selection, 1);
75
76 /*Partial select, the select all*/
77 Eo *sel1, *sel2;
78 i_selection = 0;
79 efl_text_interactive_selection_cursors_get(txt, &sel1, &sel2);
80 efl_text_cursor_position_set(sel1, 1);
81 efl_text_cursor_position_set(sel2, 2);
82 ck_assert_int_eq(i_selection, 2);
83 efl_text_interactive_all_select(txt);
84 ck_assert_int_eq(i_selection, 3);
85 ck_assert_int_eq(efl_text_cursor_position_get(sel1), 0);
86 ck_assert_int_eq(efl_text_cursor_position_get(sel2), 5);
87
88 Eo *cur1 = efl_ui_textbox_cursor_create(txt);
89 Eo *cur2 = efl_ui_textbox_cursor_create(txt);
90 efl_text_cursor_position_set(cur1, 1);
91 efl_text_cursor_position_set(cur2, 2);
92 efl_text_interactive_selection_cursors_set(txt, cur1, cur2);
93 ck_assert_int_eq(i_selection, 4);
94 efl_text_interactive_selection_cursors_get(txt, &sel1, &sel2);
95 ck_assert_int_eq(efl_text_cursor_position_get(sel1),1);
96 ck_assert_int_eq(efl_text_cursor_position_get(sel2),2);
97
98
99 /*Select part then select all*/
100 efl_text_interactive_all_unselect(txt);
101 i_have_selection = 0, i_selection = 0;
102 efl_text_cursor_position_set(cur1, 1);
103 efl_text_cursor_position_set(cur2, 2);
104 efl_text_interactive_selection_cursors_set(txt, cur1, cur2);
105 ck_assert_int_eq(i_selection, 1);
106 ck_assert_int_eq(i_have_selection, 1);
107 efl_text_interactive_all_select(txt);
108 ck_assert_int_eq(i_selection, 2);
109 ck_assert_int_eq(i_have_selection, 1);
110 efl_text_interactive_all_unselect(txt);
111 ck_assert_int_eq(i_have_selection, 2);
112
113
75 efl_del(txt); 114 efl_del(txt);
76 efl_del(win); 115 efl_del(win);
77} 116}