summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-01-09 22:33:07 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-01-09 22:33:07 +0900
commit1a02745a88eb863cad307f0ba9fd386594ce4e82 (patch)
tree229ed0c86d342e7d65027311fc3dffbc7aa95621
parent7b0a44dd3316d32e8150d9c800e00d923fc3a684 (diff)
efl.text.cursor: change to abstract class
Summary: 1- Change cursor to abstract class 2- Remove copy method from cursor 3- remove cursor_Add method from efl.canvas.textblock and efl.ui.textbox Reviewers: woohyun, segfaultxavi, bu5hm4n Reviewed By: bu5hm4n Subscribers: lauromoura, YOhoho, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8299, T8454 Differential Revision: https://phab.enlightenment.org/D11034
-rw-r--r--src/lib/elementary/efl_ui_internal_text_interactive.c40
-rw-r--r--src/lib/elementary/efl_ui_textbox.c8
-rw-r--r--src/lib/elementary/efl_ui_textbox.eo7
-rw-r--r--src/lib/evas/canvas/efl_canvas_textblock.eo9
-rw-r--r--src/lib/evas/canvas/efl_canvas_textblock_internal.h8
-rw-r--r--src/lib/evas/canvas/efl_text_cursor.c20
-rw-r--r--src/lib/evas/canvas/efl_text_cursor.eo9
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c8
-rw-r--r--src/tests/evas/evas_test_textblock.c21
9 files changed, 59 insertions, 71 deletions
diff --git a/src/lib/elementary/efl_ui_internal_text_interactive.c b/src/lib/elementary/efl_ui_internal_text_interactive.c
index 3212632532..54b29f2712 100644
--- a/src/lib/elementary/efl_ui_internal_text_interactive.c
+++ b/src/lib/elementary/efl_ui_internal_text_interactive.c
@@ -76,6 +76,12 @@ _text_filter_markup_prepend(Efl_Canvas_Textblock *obj, Efl_Ui_Internal_Text_Inte
76 const char *fmtpre, const char *fmtpost, 76 const char *fmtpre, const char *fmtpost,
77 Eina_Bool clearsel, Eina_Bool changeinfo); 77 Eina_Bool clearsel, Eina_Bool changeinfo);
78 78
79static void
80_cur_pos_copy(Efl_Text_Cursor *src, Efl_Text_Cursor *dest)
81{
82 efl_text_cursor_position_set(dest, efl_text_cursor_position_get(src));
83}
84
79#ifdef HAVE_ECORE_IMF 85#ifdef HAVE_ECORE_IMF
80static void 86static void
81_preedit_clear(Efl_Ui_Internal_Text_Interactive_Data *en) 87_preedit_clear(Efl_Ui_Internal_Text_Interactive_Data *en)
@@ -523,12 +529,12 @@ _entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUS
523 /* set preedit start cursor */ 529 /* set preedit start cursor */
524 if (!en->preedit_start) 530 if (!en->preedit_start)
525 en->preedit_start = efl_canvas_textblock_cursor_create(obj); 531 en->preedit_start = efl_canvas_textblock_cursor_create(obj);
526 efl_text_cursor_copy(cur, en->preedit_start); 532 _cur_pos_copy(cur, en->preedit_start);
527 533
528 /* set preedit end cursor */ 534 /* set preedit end cursor */
529 if (!en->preedit_end) 535 if (!en->preedit_end)
530 en->preedit_end = efl_canvas_textblock_cursor_create(obj); 536 en->preedit_end = efl_canvas_textblock_cursor_create(obj);
531 efl_text_cursor_copy(cur, en->preedit_end); 537 _cur_pos_copy(cur, en->preedit_end);
532 538
533 preedit_end_pos = efl_text_cursor_position_get(cur); 539 preedit_end_pos = efl_text_cursor_position_get(cur);
534 540
@@ -752,8 +758,8 @@ _sel_init(Efl_Text_Cursor *c, Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_I
752 if (en->have_selection) 758 if (en->have_selection)
753 return; 759 return;
754 760
755 efl_text_cursor_copy(c, en->sel_start); 761 _cur_pos_copy(c, en->sel_start);
756 efl_text_cursor_copy(c, en->sel_end); 762 _cur_pos_copy(c, en->sel_end);
757 763
758 en->have_selection = EINA_FALSE; 764 en->have_selection = EINA_FALSE;
759 if (en->selection) 765 if (en->selection)
@@ -804,7 +810,7 @@ _sel_extend(Efl_Text_Cursor *c, Evas_Object *o, Efl_Ui_Internal_Text_Interactive
804 _sel_enable(c, o, en); 810 _sel_enable(c, o, en);
805 if (efl_text_cursor_equal(c, en->sel_end)) return; 811 if (efl_text_cursor_equal(c, en->sel_end)) return;
806 812
807 efl_text_cursor_copy(c, en->sel_end); 813 _cur_pos_copy(c, en->sel_end);
808 814
809 _entry_imf_cursor_info_set(en); 815 _entry_imf_cursor_info_set(en);
810 816
@@ -830,7 +836,7 @@ _sel_clear(Evas_Object *o EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *en
830 { 836 {
831 en->have_selection = EINA_FALSE; 837 en->have_selection = EINA_FALSE;
832 Eina_Bool b_value = en->have_selection; 838 Eina_Bool b_value = en->have_selection;
833 efl_text_cursor_copy(en->sel_start, en->sel_end); 839 _cur_pos_copy(en->sel_start, en->sel_end);
834 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value); 840 efl_event_callback_call(o, EFL_TEXT_INTERACTIVE_EVENT_HAVE_SELECTION_CHANGED, &b_value);
835 } 841 }
836} 842}
@@ -1024,9 +1030,9 @@ _key_down_sel_pre(Efl_Ui_Internal_Text_Interactive *obj, Efl_Text_Cursor *cur, E
1024 { 1030 {
1025 Eina_Bool sel_forward = efl_text_cursor_compare(en->sel_start, en->sel_end); 1031 Eina_Bool sel_forward = efl_text_cursor_compare(en->sel_start, en->sel_end);
1026 if ((sel_forward && movement_forward) || (!sel_forward && !movement_forward)) 1032 if ((sel_forward && movement_forward) || (!sel_forward && !movement_forward))
1027 efl_text_cursor_copy(en->sel_end, cur); 1033 _cur_pos_copy(en->sel_end, cur);
1028 else 1034 else
1029 efl_text_cursor_copy(en->sel_start, cur); 1035 _cur_pos_copy(en->sel_start, cur);
1030 _sel_clear(obj, en); 1036 _sel_clear(obj, en);
1031 } 1037 }
1032 } 1038 }
@@ -1207,7 +1213,7 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1207 // del to start of previous word 1213 // del to start of previous word
1208 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj); 1214 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj);
1209 1215
1210 efl_text_cursor_copy(tc, cur); 1216 _cur_pos_copy(tc, cur);
1211 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_PREV); 1217 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_PREV);
1212 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START); 1218 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START);
1213 1219
@@ -1242,7 +1248,7 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1242 // del to end of next word 1248 // del to end of next word
1243 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj); 1249 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj);
1244 1250
1245 efl_text_cursor_copy(tc, cur); 1251 _cur_pos_copy(tc, cur);
1246 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END); 1252 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END);
1247 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_NEXT); 1253 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_NEXT);
1248 1254
@@ -1484,7 +1490,7 @@ _cursor_char_coord_set(Efl_Canvas_Textblock *obj, Efl_Text_Cursor *cur, Evas_Coo
1484 Efl_Text_Cursor *tc; 1490 Efl_Text_Cursor *tc;
1485 1491
1486 tc = efl_canvas_textblock_cursor_create(obj); 1492 tc = efl_canvas_textblock_cursor_create(obj);
1487 efl_text_cursor_copy(cur, tc); 1493 _cur_pos_copy(cur, tc);
1488 evas_object_geometry_get(obj, &x, &y, NULL, NULL); 1494 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1489 cx = canvasx - x; 1495 cx = canvasx - x;
1490 cy = canvasy - y; 1496 cy = canvasy - y;
@@ -1549,7 +1555,7 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1549 if (shift) 1555 if (shift)
1550 { 1556 {
1551 tc = efl_canvas_textblock_cursor_create(obj); 1557 tc = efl_canvas_textblock_cursor_create(obj);
1552 efl_text_cursor_copy(cur, tc); 1558 _cur_pos_copy(cur, tc);
1553 if (efl_text_cursor_compare(cur, en->sel_start) < 0) 1559 if (efl_text_cursor_compare(cur, en->sel_start) < 0)
1554 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START); 1560 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START);
1555 else 1561 else
@@ -1562,7 +1568,7 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1562 en->selecting = EINA_FALSE; 1568 en->selecting = EINA_FALSE;
1563 _sel_clear(obj, en); 1569 _sel_clear(obj, en);
1564 tc = efl_canvas_textblock_cursor_create(obj); 1570 tc = efl_canvas_textblock_cursor_create(obj);
1565 efl_text_cursor_copy(cur, tc); 1571 _cur_pos_copy(cur, tc);
1566 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START); 1572 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START);
1567 _sel_init(cur, obj, en); 1573 _sel_init(cur, obj, en);
1568 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END); 1574 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END);
@@ -1575,7 +1581,7 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1575 if (shift) 1581 if (shift)
1576 { 1582 {
1577 tc = efl_canvas_textblock_cursor_create(obj); 1583 tc = efl_canvas_textblock_cursor_create(obj);
1578 efl_text_cursor_copy(cur, tc); 1584 _cur_pos_copy(cur, tc);
1579 if (efl_text_cursor_compare(cur, en->sel_start) < 0) 1585 if (efl_text_cursor_compare(cur, en->sel_start) < 0)
1580 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START); 1586 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START);
1581 else 1587 else
@@ -1591,7 +1597,7 @@ _mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
1591 en->selecting = EINA_FALSE; 1597 en->selecting = EINA_FALSE;
1592 _sel_clear(obj, en); 1598 _sel_clear(obj, en);
1593 tc = efl_canvas_textblock_cursor_create(obj); 1599 tc = efl_canvas_textblock_cursor_create(obj);
1594 efl_text_cursor_copy(cur, tc); 1600 _cur_pos_copy(cur, tc);
1595 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START); 1601 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START);
1596 _sel_init(cur, obj, en); 1602 _sel_init(cur, obj, en);
1597 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END); 1603 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END);
@@ -1650,7 +1656,7 @@ _mouse_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1650 1656
1651 if (en->select_allow) 1657 if (en->select_allow)
1652 { 1658 {
1653 efl_text_cursor_copy(en->sel_end, cur); 1659 _cur_pos_copy(en->sel_end, cur);
1654 } 1660 }
1655 if (en->selecting) 1661 if (en->selecting)
1656 { 1662 {
@@ -1690,7 +1696,7 @@ _mouse_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, vo
1690 if (en->selecting) 1696 if (en->selecting)
1691 { 1697 {
1692 tc = efl_canvas_textblock_cursor_create(obj); 1698 tc = efl_canvas_textblock_cursor_create(obj);
1693 efl_text_cursor_copy(cur, tc); 1699 _cur_pos_copy(cur, tc);
1694 evas_object_geometry_get(obj, &x, &y, &w, &h); 1700 evas_object_geometry_get(obj, &x, &y, &w, &h);
1695 cx = ev->cur.canvas.x - x; 1701 cx = ev->cur.canvas.x - x;
1696 cy = ev->cur.canvas.y - y; 1702 cy = ev->cur.canvas.y - y;
diff --git a/src/lib/elementary/efl_ui_textbox.c b/src/lib/elementary/efl_ui_textbox.c
index 0f545e319f..ea26e3ce0b 100644
--- a/src/lib/elementary/efl_ui_textbox.c
+++ b/src/lib/elementary/efl_ui_textbox.c
@@ -2108,16 +2108,10 @@ _efl_ui_textbox_entry_insert(Eo *obj, Efl_Ui_Textbox_Data *sd, const char *entry
2108 efl_canvas_group_change(obj); 2108 efl_canvas_group_change(obj);
2109} 2109}
2110 2110
2111EOLIAN static void
2112_efl_ui_textbox_cursor_add(Eo *obj, Efl_Ui_Textbox_Data *pd, Efl_Text_Cursor *cursor)
2113{
2114 efl_text_cursor_text_object_set(cursor, pd->text_obj, obj);
2115}
2116
2117EOLIAN static Efl_Text_Cursor * 2111EOLIAN static Efl_Text_Cursor *
2118_efl_ui_textbox_cursor_create(Eo *obj, Efl_Ui_Textbox_Data *pd) 2112_efl_ui_textbox_cursor_create(Eo *obj, Efl_Ui_Textbox_Data *pd)
2119{ 2113{
2120 Eo* cursor = efl_add(EFL_TEXT_CURSOR_CLASS, pd->text_obj); 2114 Eo* cursor = efl_text_cursor_create(pd->text_obj);;
2121 efl_text_cursor_text_object_set(cursor, pd->text_obj, obj); 2115 efl_text_cursor_text_object_set(cursor, pd->text_obj, obj);
2122 return cursor; 2116 return cursor;
2123} 2117}
diff --git a/src/lib/elementary/efl_ui_textbox.eo b/src/lib/elementary/efl_ui_textbox.eo
index 3f8097a90a..aa3a5dd5be 100644
--- a/src/lib/elementary/efl_ui_textbox.eo
+++ b/src/lib/elementary/efl_ui_textbox.eo
@@ -64,13 +64,6 @@ class @beta Efl.Ui.Textbox extends Efl.Ui.Layout_Base implements Efl.Input.Click
64 item_factory: Efl.Canvas.Textblock_Factory; [[Factory to create items]] 64 item_factory: Efl.Canvas.Textblock_Factory; [[Factory to create items]]
65 } 65 }
66 } 66 }
67 cursor_add {
68 [[Add cursor that will manipulate and iterate content of the text object.
69 It is typically more convenient to obtain a cursor directly from the text object using @.cursor_create.]]
70 params {
71 cursor: Efl.Text.Cursor; [[Text cursor.]]
72 }
73 }
74 cursor_create { 67 cursor_create {
75 [[Creates and returns a new cursor for the text.]] 68 [[Creates and returns a new cursor for the text.]]
76 return: Efl.Text.Cursor @move; [[Text cursor.]] 69 return: Efl.Text.Cursor @move; [[Text cursor.]]
diff --git a/src/lib/evas/canvas/efl_canvas_textblock.eo b/src/lib/evas/canvas/efl_canvas_textblock.eo
index c9ed381e95..edc170ba81 100644
--- a/src/lib/evas/canvas/efl_canvas_textblock.eo
+++ b/src/lib/evas/canvas/efl_canvas_textblock.eo
@@ -23,15 +23,6 @@ class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text,
23 is_empty: bool; [[$true if empty.]] 23 is_empty: bool; [[$true if empty.]]
24 } 24 }
25 } 25 }
26 cursor_add {
27 [[Adds an existing cursor to the text object.
28 If the cursor already belonged to another text object it will be reassigned to the new one.
29 It is typically more convenient to obtain a cursor directly from the text object using @.cursor_create.
30 ]]
31 params {
32 cursor: Efl.Text.Cursor; [[The text cursor to use.]]
33 }
34 }
35 cursor_create { 26 cursor_create {
36 [[Creates a new cursor and adds it to the text object. 27 [[Creates a new cursor and adds it to the text object.
37 This cursor can be used to manipulate and iterate the content of the text object. 28 This cursor can be used to manipulate and iterate the content of the text object.
diff --git a/src/lib/evas/canvas/efl_canvas_textblock_internal.h b/src/lib/evas/canvas/efl_canvas_textblock_internal.h
index a4f03fcef8..eb137455ea 100644
--- a/src/lib/evas/canvas/efl_canvas_textblock_internal.h
+++ b/src/lib/evas/canvas/efl_canvas_textblock_internal.h
@@ -294,6 +294,14 @@ EAPI void efl_text_cursor_text_object_set(Eo *cursor, Eo *canvas_text_obj, Eo *t
294 294
295 295
296/** 296/**
297 * Internally create instance of cursor object.
298 *
299 * @param parent the parent of the cursor object.
300 */
301EAPI Eo* efl_text_cursor_create(Eo *parent);
302
303
304/**
297 * Internally sets cursor handle(legacy textblock cursor) into cursor object. 305 * Internally sets cursor handle(legacy textblock cursor) into cursor object.
298 * 306 *
299 * @param obj the cursor object. 307 * @param obj the cursor object.
diff --git a/src/lib/evas/canvas/efl_text_cursor.c b/src/lib/evas/canvas/efl_text_cursor.c
index eb699728b8..c0a6c627d9 100644
--- a/src/lib/evas/canvas/efl_text_cursor.c
+++ b/src/lib/evas/canvas/efl_text_cursor.c
@@ -1,6 +1,7 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "evas_private.h" 2#include "evas_private.h"
3#include "efl_canvas_textblock_internal.h" 3#include "efl_canvas_textblock_internal.h"
4#include "eo_internal.h"
4 5
5#define MY_CLASS EFL_TEXT_CURSOR_CLASS 6#define MY_CLASS EFL_TEXT_CURSOR_CLASS
6#define MY_CLASS_NAME "Efl.Text.Cursor" 7#define MY_CLASS_NAME "Efl.Text.Cursor"
@@ -20,6 +21,8 @@ struct _Evas_Textblock_Selection_Iterator
20 21
21typedef struct _Evas_Textblock_Selection_Iterator Evas_Textblock_Selection_Iterator; 22typedef struct _Evas_Textblock_Selection_Iterator Evas_Textblock_Selection_Iterator;
22 23
24EFL_CLASS_SIMPLE_CLASS(efl_text_cursor, "efl_text_cursor", EFL_TEXT_CURSOR_CLASS)
25
23EOLIAN static void 26EOLIAN static void
24_efl_text_cursor_position_set(Eo *obj EINA_UNUSED, Efl_Text_Cursor_Data *pd, int position) 27_efl_text_cursor_position_set(Eo *obj EINA_UNUSED, Efl_Text_Cursor_Data *pd, int position)
25{ 28{
@@ -102,11 +105,15 @@ _efl_text_cursor_compare(const Eo *obj EINA_UNUSED, Efl_Text_Cursor_Data *pd, co
102 return evas_textblock_cursor_compare(pd->handle, efl_text_cursor_handle_get(dst)); 105 return evas_textblock_cursor_compare(pd->handle, efl_text_cursor_handle_get(dst));
103} 106}
104 107
105EOLIAN static void 108static void
106_efl_text_cursor_copy(const Eo *obj EINA_UNUSED, Efl_Text_Cursor_Data *pd, Efl_Text_Cursor *dst) 109_efl_text_cursor_copy(const Efl_Text_Cursor *obj, Efl_Text_Cursor *dst)
107{ 110{
111 Efl_Text_Cursor_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
112 EINA_SAFETY_ON_NULL_RETURN(pd);
113
108 Efl_Text_Cursor_Data *pd_dest = efl_data_scope_safe_get(dst, MY_CLASS); 114 Efl_Text_Cursor_Data *pd_dest = efl_data_scope_safe_get(dst, MY_CLASS);
109 EINA_SAFETY_ON_NULL_RETURN(pd_dest); 115 EINA_SAFETY_ON_NULL_RETURN(pd_dest);
116
110 if (!pd->handle) return; 117 if (!pd->handle) return;
111 118
112 Efl_Text_Cursor_Handle *handle = evas_object_textblock_cursor_new(pd->handle->obj); 119 Efl_Text_Cursor_Handle *handle = evas_object_textblock_cursor_new(pd->handle->obj);
@@ -119,9 +126,9 @@ _efl_text_cursor_copy(const Eo *obj EINA_UNUSED, Efl_Text_Cursor_Data *pd, Efl_T
119EOLIAN static Efl_Text_Cursor * 126EOLIAN static Efl_Text_Cursor *
120_efl_text_cursor_efl_duplicate_duplicate(const Eo *obj, Efl_Text_Cursor_Data *pd EINA_UNUSED) 127_efl_text_cursor_efl_duplicate_duplicate(const Eo *obj, Efl_Text_Cursor_Data *pd EINA_UNUSED)
121{ 128{
122 Efl_Text_Cursor *dup = efl_new(MY_CLASS); 129 Efl_Text_Cursor *dup = efl_text_cursor_create(efl_parent_get(obj));
123 130
124 efl_text_cursor_copy(obj, dup); 131 _efl_text_cursor_copy(obj, dup);
125 132
126 return dup; 133 return dup;
127} 134}
@@ -436,6 +443,11 @@ efl_text_cursor_handle_get(const Eo *obj)
436 return pd->handle; 443 return pd->handle;
437} 444}
438 445
446Eo* efl_text_cursor_create(Eo *parent)
447{
448 return efl_add(efl_text_cursor_realized_class_get(), parent);
449}
450
439void efl_text_cursor_text_object_set(Eo *cursor, Eo *canvas_text_obj, Eo *text_obj) 451void efl_text_cursor_text_object_set(Eo *cursor, Eo *canvas_text_obj, Eo *text_obj)
440{ 452{
441 Efl_Text_Cursor_Data *pd = efl_data_scope_safe_get(cursor, MY_CLASS); 453 Efl_Text_Cursor_Data *pd = efl_data_scope_safe_get(cursor, MY_CLASS);
diff --git a/src/lib/evas/canvas/efl_text_cursor.eo b/src/lib/evas/canvas/efl_text_cursor.eo
index 70cfdfad21..00dcbd6e63 100644
--- a/src/lib/evas/canvas/efl_text_cursor.eo
+++ b/src/lib/evas/canvas/efl_text_cursor.eo
@@ -26,7 +26,7 @@ enum @beta Efl.Text.Cursor_Move_Type
26 paragraph_prev [[Advances to the end of the previous paragraph.]] 26 paragraph_prev [[Advances to the end of the previous paragraph.]]
27} 27}
28 28
29class @beta Efl.Text.Cursor extends Efl.Object implements Efl.Duplicate{ 29abstract @beta Efl.Text.Cursor extends Efl.Object implements Efl.Duplicate{
30 [[Cursor API.]] 30 [[Cursor API.]]
31 c_prefix: efl_text_cursor; 31 c_prefix: efl_text_cursor;
32 methods { 32 methods {
@@ -112,13 +112,6 @@ class @beta Efl.Text.Cursor extends Efl.Object implements Efl.Duplicate{
112 return: int; [[Difference between cursors.]] 112 return: int; [[Difference between cursors.]]
113 } 113 }
114 114
115 copy @const {
116 [[Copy existing cursor to destination cursor, like position and cursor text object.]]
117 params {
118 dst: Efl.Text.Cursor; [[Destination Cursor.]]
119 }
120 }
121
122 move { 115 move {
123 [[Move the cursor.]] 116 [[Move the cursor.]]
124 params { 117 params {
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 1996134966..f4d6cfb88f 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -8077,16 +8077,10 @@ _efl_canvas_textblock_all_styles_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Te
8077 return o->default_format.default_style_str; 8077 return o->default_format.default_style_str;
8078} 8078}
8079 8079
8080EOLIAN static void
8081_efl_canvas_textblock_cursor_add(Eo *obj, Efl_Canvas_Textblock_Data *pd EINA_UNUSED, Efl_Text_Cursor *cursor)
8082{
8083 efl_text_cursor_text_object_set(cursor, obj, obj);
8084}
8085
8086EOLIAN static Efl_Text_Cursor * 8080EOLIAN static Efl_Text_Cursor *
8087_efl_canvas_textblock_cursor_create(Eo *obj, Efl_Canvas_Textblock_Data *pd EINA_UNUSED) 8081_efl_canvas_textblock_cursor_create(Eo *obj, Efl_Canvas_Textblock_Data *pd EINA_UNUSED)
8088{ 8082{
8089 Eo* cursor = efl_add(EFL_TEXT_CURSOR_CLASS, obj); 8083 Eo* cursor = efl_text_cursor_create(obj);
8090 efl_text_cursor_text_object_set(cursor, obj, obj); 8084 efl_text_cursor_text_object_set(cursor, obj, obj);
8091 return cursor; 8085 return cursor;
8092} 8086}
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index c23eb65caa..b51f149174 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -4515,14 +4515,12 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
4515 efl_text_cursor_line_number_set(cur_obj, 0); 4515 efl_text_cursor_line_number_set(cur_obj, 0);
4516 ck_assert_int_eq(efl_text_cursor_position_get(cur_obj), 0); 4516 ck_assert_int_eq(efl_text_cursor_position_get(cur_obj), 0);
4517 4517
4518 Eo * cursor1 = efl_add(EFL_TEXT_CURSOR_CLASS, txt); 4518 Eo * cursor_temp = efl_duplicate(cur_obj);
4519 pos = efl_text_cursor_position_get(cursor1); 4519 ck_assert_ptr_ne(cursor_temp, NULL);
4520 ck_assert_int_eq(pos, -1); 4520 efl_del(cursor_temp);
4521 efl_text_cursor_position_set(cursor1, 10); 4521 cursor_temp = NULL;
4522 pos = efl_text_cursor_position_get(cursor1);
4523 ck_assert_int_eq(pos, -1);
4524 4522
4525 efl_canvas_textblock_cursor_add(txt, cursor1); 4523 Eo * cursor1 = efl_canvas_textblock_cursor_create(txt);
4526 efl_text_cursor_position_set(cursor1, 1); 4524 efl_text_cursor_position_set(cursor1, 1);
4527 pos = efl_text_cursor_position_get(cursor1); 4525 pos = efl_text_cursor_position_get(cursor1);
4528 ck_assert_int_eq(pos, 1); 4526 ck_assert_int_eq(pos, 1);
@@ -4633,13 +4631,12 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
4633 ck_assert_int_eq(efl_text_cursor_position_get(cur_obj), 0); 4631 ck_assert_int_eq(efl_text_cursor_position_get(cur_obj), 0);
4634#endif 4632#endif
4635 4633
4636 Eo *nCur = efl_add(EFL_TEXT_CURSOR_CLASS, txt), *nCur2 = efl_add(EFL_TEXT_CURSOR_CLASS, txt), *nCur3 = efl_add(EFL_TEXT_CURSOR_CLASS, txt); 4634 Eo *nCur = efl_canvas_textblock_cursor_create(txt);
4635 Eo *nCur2 = efl_canvas_textblock_cursor_create(txt);
4636 Eo *nCur3 = efl_canvas_textblock_cursor_create(txt);
4637 efl_text_markup_set(txt, "Hello World<ps/>This is EFL<br/>Enlightenment"); 4637 efl_text_markup_set(txt, "Hello World<ps/>This is EFL<br/>Enlightenment");
4638 efl_text_cursor_position_set(cur_obj, 0); 4638 efl_text_cursor_position_set(cur_obj, 0);
4639 efl_text_cursor_copy(cur_obj, nCur);
4640 ck_assert_ptr_ne(nCur, NULL); 4639 ck_assert_ptr_ne(nCur, NULL);
4641 efl_text_cursor_copy(cur_obj, nCur2);
4642 efl_text_cursor_copy(cur_obj, nCur3);
4643 ck_assert_ptr_ne(nCur2, NULL); 4640 ck_assert_ptr_ne(nCur2, NULL);
4644 ck_assert_ptr_ne(nCur3, NULL); 4641 ck_assert_ptr_ne(nCur3, NULL);
4645 4642
@@ -4655,7 +4652,7 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
4655 ck_assert(efl_text_cursor_move(nCur, EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_NEXT)); 4652 ck_assert(efl_text_cursor_move(nCur, EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_NEXT));
4656 ck_assert_int_lt(efl_text_cursor_compare(cur_obj, nCur), 0); 4653 ck_assert_int_lt(efl_text_cursor_compare(cur_obj, nCur), 0);
4657 ck_assert_int_gt(efl_text_cursor_compare(nCur, cur_obj), 0); 4654 ck_assert_int_gt(efl_text_cursor_compare(nCur, cur_obj), 0);
4658 efl_text_cursor_copy(nCur, nCur2); 4655 efl_text_cursor_position_set(nCur2, efl_text_cursor_position_get(nCur));
4659 ck_assert_int_lt(efl_text_cursor_compare(cur_obj, nCur2), 0); 4656 ck_assert_int_lt(efl_text_cursor_compare(cur_obj, nCur2), 0);
4660 ck_assert_int_gt(efl_text_cursor_compare(nCur2, cur_obj), 0); 4657 ck_assert_int_gt(efl_text_cursor_compare(nCur2, cur_obj), 0);
4661 ck_assert(!efl_text_cursor_equal(nCur2, nCur3)); 4658 ck_assert(!efl_text_cursor_equal(nCur2, nCur3));