summaryrefslogtreecommitdiff
path: root/src/bin/elementary
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2019-11-22 17:35:54 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2019-11-22 17:35:54 +0900
commitd7352f4db41dc8975eaeb3f79dff326338a5a63c (patch)
treebe0fc63995e40f4c3a764f2ffdb66716dfcc6c38 /src/bin/elementary
parent17ba8515f1c9534ebd47a71adda71db2eff6799a (diff)
Efl.Text.Cursor
Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
Diffstat (limited to 'src/bin/elementary')
-rw-r--r--src/bin/elementary/test_efl_ui_text.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/bin/elementary/test_efl_ui_text.c b/src/bin/elementary/test_efl_ui_text.c
index e7e909b..d56fddb 100644
--- a/src/bin/elementary/test_efl_ui_text.c
+++ b/src/bin/elementary/test_efl_ui_text.c
@@ -8,18 +8,18 @@
8static void 8static void
9_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style) 9_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style)
10{ 10{
11 Efl_Text_Cursor_Cursor *start, *end; 11 Efl_Text_Cursor *start, *end;
12 12
13 start = efl_text_cursor_new(obj); 13 start = efl_ui_text_cursor_create(obj);
14 end = efl_text_cursor_new(obj); 14 end = efl_ui_text_cursor_create(obj);
15 15
16 efl_text_cursor_position_set(obj, start, start_pos); 16 efl_text_cursor_position_set(start, start_pos);
17 efl_text_cursor_position_set(obj, end, end_pos); 17 efl_text_cursor_position_set(end, end_pos);
18 18
19 efl_text_annotation_insert(obj, start, end, style); 19 efl_text_annotation_insert(obj, efl_text_cursor_handle_get(start), efl_text_cursor_handle_get(end), style);
20 20
21 efl_text_cursor_free(obj, start); 21 efl_del(start);
22 efl_text_cursor_free(obj, end); 22 efl_del(end);
23} 23}
24 24
25static Eo * 25static Eo *
@@ -98,15 +98,15 @@ typedef struct
98static void 98static void
99_on_bt3_clicked(void *data, const Efl_Event *event EINA_UNUSED) 99_on_bt3_clicked(void *data, const Efl_Event *event EINA_UNUSED)
100{ 100{
101 Efl_Text_Cursor_Cursor *sel_start, *sel_end; 101 Efl_Text_Cursor *sel_start, *sel_end;
102 Eo *en = data; 102 Eo *en = data;
103 103
104 efl_text_interactive_selection_cursors_get(data, &sel_start, &sel_end); 104 efl_text_interactive_selection_cursors_get(en, &sel_start, &sel_end);
105 const char *s = efl_canvas_text_range_text_get(data, sel_start, sel_end); 105 const char *s = efl_text_cursor_range_text_get(sel_start, sel_end);
106 106
107 printf("SELECTION REGION: %d - %d\n", 107 printf("SELECTION REGION: %d - %d\n",
108 efl_text_cursor_position_get(en, sel_start), 108 efl_text_cursor_position_get( sel_start),
109 efl_text_cursor_position_get(en, sel_end)); 109 efl_text_cursor_position_get(sel_end));
110 printf("SELECTION:\n"); 110 printf("SELECTION:\n");
111 if (s) printf("%s\n", s); 111 if (s) printf("%s\n", s);
112} 112}
@@ -248,9 +248,9 @@ _on_factory_bt_image_clicked(void *data, const Efl_Event *event EINA_UNUSED)
248 static int image_idx = 0; 248 static int image_idx = 0;
249 249
250 image_idx = (image_idx + 1) % IMAGES_SZ; 250 image_idx = (image_idx + 1) % IMAGES_SZ;
251 efl_text_cursor_item_insert(en, 251
252 efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_TYPE_MAIN), 252 efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(efl_text_interactive_main_cursor_get(en)),
253 images[image_idx], "size=32x32"); 253 images[image_idx], "size=32x32");
254 printf("Inserted image: key = %s\n", images[image_idx]); 254 printf("Inserted image: key = %s\n", images[image_idx]);
255} 255}
256 256
@@ -258,8 +258,8 @@ static void
258_on_factory_bt_emoticon_clicked(void *data, const Efl_Event *event EINA_UNUSED) 258_on_factory_bt_emoticon_clicked(void *data, const Efl_Event *event EINA_UNUSED)
259{ 259{
260 Evas_Object *en = data; 260 Evas_Object *en = data;
261 efl_text_cursor_item_insert(en, efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_TYPE_MAIN), 261 efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(efl_text_interactive_main_cursor_get(en)),
262 "emoticon/evil-laugh", "size=32x32"); 262 "emoticon/evil-laugh", "size=32x32");
263} 263}
264 264
265static struct 265static struct
@@ -287,7 +287,7 @@ void
287test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 287test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
288{ 288{
289 Evas_Object *win, *bx, *bx2, *bt, *en; 289 Evas_Object *win, *bx, *bx2, *bt, *en;
290 Efl_Text_Cursor_Cursor *main_cur, *cur; 290 Efl_Text_Cursor *main_cur, *cur;
291 char buf[128]; 291 char buf[128];
292 Eina_File *f; 292 Eina_File *f;
293 293
@@ -350,16 +350,16 @@ test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
350 efl_text_font_set(en, "Sans", 14); 350 efl_text_font_set(en, "Sans", 14);
351 efl_text_normal_color_set(en, 255, 255, 255, 255); 351 efl_text_normal_color_set(en, 255, 255, 255, 255);
352 352
353 main_cur = efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_TYPE_MAIN); 353 main_cur = efl_text_interactive_main_cursor_get(en);
354 cur = efl_text_cursor_new(en); 354 cur = efl_ui_text_cursor_create(en);
355 355
356 efl_text_cursor_position_set(en, cur, 2); 356 efl_text_cursor_position_set(cur, 2);
357 efl_text_cursor_item_insert(en, cur, "emoticon/happy", "size=32x32"); 357 efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(cur), "emoticon/happy", "size=32x32");
358 efl_text_cursor_position_set(en, cur, 50); 358 efl_text_cursor_position_set(cur, 50);
359 359
360 snprintf(buf, sizeof(buf), "file://%s/images/sky_01.jpg", elm_app_data_dir_get()); 360 snprintf(buf, sizeof(buf), "file://%s/images/sky_01.jpg", elm_app_data_dir_get());
361 efl_text_cursor_item_insert(en, cur, buf, "size=32x32"); 361 efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(cur), buf, "size=32x32");
362 efl_text_cursor_position_set(en, main_cur, 5); 362 efl_text_cursor_position_set(main_cur, 5);
363 363
364 efl_text_interactive_editable_set(en, EINA_TRUE); 364 efl_text_interactive_editable_set(en, EINA_TRUE);
365 efl_ui_text_scrollable_set(en, EINA_TRUE); 365 efl_ui_text_scrollable_set(en, EINA_TRUE);