1 #include "edje_private.h"
4 static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
5 static void _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
6 static void _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
7 static void _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event);
8 static void _edje_entry_imf_event_selection_set_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
9 static Eina_Bool _edje_entry_imf_retrieve_selection_cb(void *data, Ecore_IMF_Context *ctx, char **text);
12 typedef struct _Entry Entry;
13 typedef struct _Sel Sel;
14 typedef struct _Anchor Anchor;
16 static void _edje_entry_imf_cursor_location_set(Entry *en);
17 static void _edje_entry_imf_cursor_info_set(Entry *en);
18 static void _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Entry *en);
19 static void _text_filter_format_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c, const char *text);
26 Evas_Object *cursor_bg;
27 Evas_Object *cursor_fg, *cursor_fg2;
28 Evas_Textblock_Cursor *cursor;
29 Evas_Textblock_Cursor *sel_start, *sel_end;
30 Evas_Textblock_Cursor *cursor_user, *cursor_user_extra;
31 Evas_Textblock_Cursor *preedit_start, *preedit_end;
32 Ecore_Timer *pw_timer;
35 Eina_List *anchorlist;
39 Edje_Input_Panel_Lang input_panel_lang;
40 Eina_Bool composing : 1;
41 Eina_Bool selecting : 1;
42 Eina_Bool have_selection : 1;
43 Eina_Bool select_allow : 1;
44 Eina_Bool select_mod_start : 1;
45 Eina_Bool select_mod_end : 1;
46 Eina_Bool had_sel : 1;
47 Eina_Bool input_panel_enable : 1;
48 Eina_Bool prediction_allow : 1;
49 // TIZEN_ONLY(20150716): Add edje_object_part_text_freeze, thaw APIs for freezing cursor movements.
54 Eina_Bool have_preedit : 1;
55 Eina_Bool commit_cancel : 1; // For skipping useless commit
56 Ecore_IMF_Context *imf_context;
62 Evas_Textblock_Rectangle rect;
63 Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
70 Evas_Textblock_Cursor *start, *end;
77 _preedit_clear(Entry *en)
79 if (en->preedit_start)
81 evas_textblock_cursor_free(en->preedit_start);
82 en->preedit_start = NULL;
87 evas_textblock_cursor_free(en->preedit_end);
88 en->preedit_end = NULL;
91 en->have_preedit = EINA_FALSE;
95 _preedit_del(Entry *en)
97 if (!en || !en->have_preedit) return;
98 if (!en->preedit_start || !en->preedit_end) return;
99 if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return;
101 /* delete the preedit characters */
102 evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end);
106 _edje_entry_focus_in_cb(void *data, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
113 if ((!rp) || (rp->type != EDJE_RP_TYPE_TEXT) ||
114 (!rp->typedata.text)) return;
115 if (!rp->typedata.text->entry_data) return;
120 en = rp->typedata.text->entry_data;
121 if (!en || !en->imf_context) return;
123 if (evas_object_focus_get(ed->obj))
125 ecore_imf_context_focus_in(en->imf_context);
126 _edje_entry_imf_cursor_info_set(en);
131 _edje_entry_focus_out_cb(void *data, Evas_Object *o EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
137 if ((!rp) || (rp->type != EDJE_RP_TYPE_TEXT) ||
138 (!rp->typedata.text)) return;
139 if (!rp->typedata.text->entry_data) return;
141 en = rp->typedata.text->entry_data;
142 if (!en || !en->imf_context) return;
144 ecore_imf_context_reset(en->imf_context);
145 ecore_imf_context_focus_out(en->imf_context);
150 _edje_focus_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
153 #ifdef HAVE_ECORE_IMF
158 _edje_emit(ed, "focus,in", "");
159 #ifdef HAVE_ECORE_IMF
160 rp = ed->focused_part;
162 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
163 (!rp->typedata.text)) return;
164 en = rp->typedata.text->entry_data;
165 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
166 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
169 if (!en->imf_context) return;
171 ecore_imf_context_focus_in(en->imf_context);
172 _edje_entry_imf_cursor_info_set(en);
177 _edje_focus_out_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
180 #ifdef HAVE_ECORE_IMF
181 Edje_Real_Part *rp = ed->focused_part;
185 _edje_emit(ed, "focus,out", "");
187 #ifdef HAVE_ECORE_IMF
189 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
190 (!rp->typedata.text)) return;
191 en = rp->typedata.text->entry_data;
192 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
193 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
196 if (!en->imf_context) return;
198 ecore_imf_context_reset(en->imf_context);
199 ecore_imf_context_focus_out(en->imf_context);
203 static Edje_Entry_Change_Info *
204 _text_filter_markup_prepend_internal(Edje *ed, Entry *en, Evas_Textblock_Cursor *c,
206 const char *fmtpre, const char *fmtpost,
207 Eina_Bool clearsel, Eina_Bool changeinfo)
209 Edje_Markup_Filter_Callback *cb;
211 Eina_Bool have_sel = EINA_FALSE;
213 if ((clearsel) && (en->have_selection))
215 _range_del_emit(ed, en->cursor, en->rp->object, en);
219 EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb)
221 if (!strcmp(cb->part, en->rp->part->name))
223 cb->func(cb->data, ed->obj, cb->part, &text);
227 #ifdef HAVE_ECORE_IMF
228 // For skipping useless commit
229 if (en->have_preedit && (!text || !strcmp(text, "")))
230 en->commit_cancel = EINA_TRUE;
232 en->commit_cancel = EINA_FALSE;
236 Edje_Entry_Change_Info *info = NULL;
240 info = calloc(1, sizeof(*info));
243 info->insert = EINA_TRUE;
244 info->change.insert.content = eina_stringshare_add(text);
245 info->change.insert.plain_length =
246 eina_unicode_utf8_get_len(info->change.insert.content);
253 info->merge = EINA_TRUE;
256 if (info) info->change.insert.pos =
257 evas_textblock_cursor_pos_get(en->cursor);
258 if (fmtpre) _text_filter_format_prepend(ed, en, en->cursor, fmtpre);
259 evas_object_textblock_text_markup_prepend(c, text);
261 if (fmtpost) _text_filter_format_prepend(ed, en, en->cursor, fmtpost);
267 static Edje_Entry_Change_Info *
268 _text_filter_text_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c,
270 const char *fmtpre, const char *fmtpost,
271 Eina_Bool clearsel, Eina_Bool changeinfo)
274 Edje_Text_Insert_Filter_Callback *cb;
277 EINA_SAFETY_ON_NULL_RETURN_VAL(text, NULL);
279 if ((clearsel) && (en->have_selection))
281 _range_del_emit(ed, en->cursor, en->rp->object, en);
284 text2 = strdup(text);
285 EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb)
287 if (!strcmp(cb->part, en->rp->part->name))
289 cb->func(cb->data, ed->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2);
296 Edje_Entry_Change_Info *info = NULL;
298 markup_text = evas_textblock_text_utf8_to_markup(NULL, text2);
301 info = _text_filter_markup_prepend_internal(ed, en, c, markup_text,
303 clearsel, changeinfo);
310 _text_filter_format_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c, const char *text)
313 Edje_Text_Insert_Filter_Callback *cb;
316 EINA_SAFETY_ON_NULL_RETURN(text);
317 text2 = strdup(text);
318 EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb)
320 if (!strcmp(cb->part, en->rp->part->name))
322 cb->func(cb->data, ed->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2);
328 char *s, *markup_text;
334 while (*s == ' ') s++;
340 markup_text = (char*) malloc(strlen(s) + 3);
343 *(markup_text) = '<';
344 strncpy((markup_text + 1), s, strlen(s));
345 *(markup_text + strlen(s) + 1) = '>';
346 *(markup_text + strlen(s) + 2) = '\0';
349 else if (s[0] == '-')
352 while (*s == ' ') s++;
358 markup_text = (char*) malloc(strlen(s) + 4);
361 *(markup_text) = '<';
362 *(markup_text + 1) = '/';
363 strncpy((markup_text + 2), s, strlen(s));
364 *(markup_text + strlen(s) + 2) = '>';
365 *(markup_text + strlen(s) + 3) = '\0';
370 markup_text = (char*) malloc(strlen(s) + 4);
373 *(markup_text) = '<';
374 strncpy((markup_text + 1), s, strlen(s));
375 *(markup_text + strlen(s) + 1) = '/';
376 *(markup_text + strlen(s) + 2) = '>';
377 *(markup_text + strlen(s) + 3) = '\0';
382 _text_filter_markup_prepend_internal(ed, en, c, markup_text,
384 EINA_FALSE, EINA_FALSE);
388 static Edje_Entry_Change_Info *
389 _text_filter_markup_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c,
391 const char *fmtpre, const char *fmtpost,
392 Eina_Bool clearsel, Eina_Bool changeinfo)
395 Edje_Text_Insert_Filter_Callback *cb;
398 EINA_SAFETY_ON_NULL_RETURN_VAL(text, NULL);
400 if ((clearsel) && (en->have_selection))
402 _range_del_emit(ed, en->cursor, en->rp->object, en);
405 text2 = strdup(text);
406 EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb)
408 if (!strcmp(cb->part, en->rp->part->name))
410 cb->func(cb->data, ed->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2);
416 Edje_Entry_Change_Info *info;
418 info = _text_filter_markup_prepend_internal(ed, en, c, text2,
420 clearsel, changeinfo);
427 _curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o EINA_UNUSED, Entry *en, Evas_Coord *cx, Evas_Coord *cy)
430 Evas_Textblock_Cursor_Type cur_type;
431 if (c != en->cursor) return;
432 switch (en->rp->part->cursor_mode)
434 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
435 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
437 case EDJE_ENTRY_CURSOR_MODE_UNDER:
438 /* no break for a reason */
440 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
442 evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type);
448 _curs_line_last_get(Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o, Entry *en EINA_UNUSED)
450 Evas_Textblock_Cursor *cc;
453 cc = evas_object_textblock_cursor_new(o);
454 evas_textblock_cursor_paragraph_last(cc);
455 ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL);
456 evas_textblock_cursor_free(cc);
461 _curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o EINA_UNUSED,
462 Entry *en EINA_UNUSED)
464 evas_textblock_cursor_line_char_first(c);
468 _curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o EINA_UNUSED,
469 Entry *en EINA_UNUSED)
471 evas_textblock_cursor_line_char_last(c);
475 _curs_start(Evas_Textblock_Cursor *c, Evas_Object *o EINA_UNUSED,
476 Entry *en EINA_UNUSED)
478 evas_textblock_cursor_paragraph_first(c);
482 _curs_end(Evas_Textblock_Cursor *c, Evas_Object *o EINA_UNUSED, Entry *en EINA_UNUSED)
484 evas_textblock_cursor_paragraph_last(c);
488 _curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
491 Evas_Coord lx, ly, lw, lh;
492 int last = _curs_line_last_get(c, o, en);
494 if (ln < 0) return EINA_FALSE;
495 if (ln > last) return EINA_FALSE;
497 _curs_update_from_curs(c, o, en, &cx, &cy);
499 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
501 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
502 //if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
503 if (evas_textblock_cursor_cluster_coord_set(c, cx, ly + (lh / 2)))
505 evas_textblock_cursor_line_set(c, ln);
506 if (cx < (lx + (lw / 2)))
508 if (ln == last) _curs_end(c, o, en);
509 _curs_lin_start(c, o, en);
516 _curs_lin_end(c, o, en);
522 _curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
526 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
527 return _curs_jump_line(c, o, en, ln);
531 _curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
533 return _curs_jump_line_by(c, o, en, -1);
537 _curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
539 return _curs_jump_line_by(c, o, en, 1);
543 _sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
545 if (en->sel_start) return;
546 en->sel_start = evas_object_textblock_cursor_new(o);
547 evas_textblock_cursor_copy(c, en->sel_start);
548 en->sel_end = evas_object_textblock_cursor_new(o);
549 evas_textblock_cursor_copy(c, en->sel_end);
551 en->have_selection = EINA_FALSE;
555 en->selection = NULL;
560 _sel_enable(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED,
561 Evas_Object *o EINA_UNUSED, Entry *en)
563 if (en->have_selection) return;
564 en->have_selection = EINA_TRUE;
568 en->selection = NULL;
571 _edje_entry_imf_context_reset(en->rp);
572 _edje_emit(ed, "selection,start", en->rp->part->name);
576 _sel_extend(Edje *ed, Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
578 if (!en->sel_end) return;
579 _sel_enable(ed, c, o, en);
580 if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
582 evas_textblock_cursor_copy(c, en->sel_end);
584 _edje_entry_imf_cursor_info_set(en);
589 en->selection = NULL;
591 _edje_emit(ed, "selection,changed", en->rp->part->name);
595 _sel_preextend(Edje *ed, Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
597 if (!en->sel_end) return;
598 _sel_enable(ed, c, o, en);
599 if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
601 evas_textblock_cursor_copy(c, en->sel_start);
603 _edje_entry_imf_cursor_info_set(en);
608 en->selection = NULL;
610 _edje_emit(ed, "selection,changed", en->rp->part->name);
614 _sel_clear(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Entry *en)
616 en->had_sel = EINA_FALSE;
619 evas_textblock_cursor_free(en->sel_start);
620 evas_textblock_cursor_free(en->sel_end);
621 en->sel_start = NULL;
627 en->selection = NULL;
634 if (sel->obj_bg) evas_object_del(sel->obj_bg);
635 if (sel->obj_fg) evas_object_del(sel->obj_fg);
637 en->sel = eina_list_remove_list(en->sel, en->sel);
639 if (en->have_selection)
641 en->have_selection = EINA_FALSE;
642 _edje_emit(ed, "selection,cleared", en->rp->part->name);
647 _sel_update(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o, Entry *en)
650 Evas_Object *smart, *clip;
652 smart = evas_object_smart_parent_get(o);
653 clip = evas_object_clip_get(o);
657 evas_object_geometry_get(o, &x, &y, NULL, NULL);
658 if (en->have_selection)
660 Eina_Iterator *range = NULL;
663 Evas_Textblock_Rectangle *r;
665 range = evas_textblock_cursor_range_simple_geometry_get(en->sel_start,
669 EINA_ITERATOR_FOREACH(range, r)
675 sel = calloc(1, sizeof(Sel));
676 en->sel = eina_list_append(en->sel, sel);
677 ob = edje_object_add(ed->base->evas);
678 edje_object_file_set(ob, ed->path, en->rp->part->source);
679 evas_object_smart_member_add(ob, smart);
680 evas_object_stack_below(ob, o);
681 evas_object_clip_set(ob, clip);
682 evas_object_pass_events_set(ob, EINA_TRUE);
683 evas_object_show(ob);
685 _edje_subobj_register(ed, sel->obj_bg);
687 ob = edje_object_add(ed->base->evas);
688 edje_object_file_set(ob, ed->path, en->rp->part->source2);
689 evas_object_smart_member_add(ob, smart);
690 evas_object_stack_above(ob, o);
691 evas_object_clip_set(ob, clip);
692 evas_object_pass_events_set(ob, EINA_TRUE);
693 evas_object_show(ob);
695 _edje_subobj_register(ed, sel->obj_fg);
699 sel = eina_list_data_get(l);
702 *(&(sel->rect)) = *r;
706 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
707 evas_object_resize(sel->obj_bg, r->w, r->h);
711 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
712 evas_object_resize(sel->obj_fg, r->w, r->h);
716 eina_iterator_free(range);
718 /* delete redundant selection rects */
721 Eina_List *temp = l->next;
722 sel = eina_list_data_get(l);
725 if (sel->obj_bg) evas_object_del(sel->obj_bg);
726 if (sel->obj_fg) evas_object_del(sel->obj_fg);
729 en->sel = eina_list_remove_list(en->sel, l);
736 _edje_anchor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
739 Evas_Event_Mouse_Down *ev = event_info;
740 Edje_Real_Part *rp = an->en->rp;
745 Edje *ed = an->en->ed;
747 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
748 (!rp->typedata.text)) return;
749 en = rp->typedata.text->entry_data;
750 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
754 ignored = rp->part->ignore_flags & ev->event_flags;
755 if ((!ev->event_flags) || (!ignored))
759 len = 200 + strlen(n);
761 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
762 snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, n);
763 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
764 snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, n);
766 snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
767 _edje_emit(ed, buf, rp->part->name);
769 ev->event_flags |= rp->part->mask_flags;
773 _edje_anchor_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
776 Evas_Event_Mouse_Up *ev = event_info;
777 Edje_Real_Part *rp = an->en->rp;
782 Edje *ed = an->en->ed;
784 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
785 (!rp->typedata.text)) return;
787 en = rp->typedata.text->entry_data;
788 ignored = rp->part->ignore_flags & ev->event_flags;
791 len = 200 + strlen(n);
793 if ((rp->part->select_mode != EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
796 if ((!ev->event_flags) || (!ignored))
798 snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n);
799 _edje_emit(ed, buf, rp->part->name);
802 if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
804 snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
805 _edje_emit(ed, buf, rp->part->name);
807 ev->event_flags |= rp->part->mask_flags;
811 _edje_anchor_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
814 Evas_Event_Mouse_Move *ev = event_info;
815 Edje_Real_Part *rp = an->en->rp;
820 Edje *ed = an->en->ed;
822 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
823 (!rp->typedata.text)) return;
824 en = rp->typedata.text->entry_data;
825 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
829 ignored = rp->part->ignore_flags & ev->event_flags;
830 if ((!ev->event_flags) || (!ignored))
834 len = 200 + strlen(n);
836 snprintf(buf, len, "anchor,mouse,move,%s", n);
837 _edje_emit(ed, buf, rp->part->name);
839 ev->event_flags |= rp->part->mask_flags;
843 _edje_anchor_mouse_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
846 Evas_Event_Mouse_In *ev = event_info;
847 Edje_Real_Part *rp = an->en->rp;
848 Edje *ed = an->en->ed;
853 ignored = rp->part->ignore_flags & ev->event_flags;
854 if ((!ev->event_flags) || (!ignored))
856 /* set to allow handling in elementary, in case we have
857 * an unwanted event propagation */
858 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
862 len = 200 + strlen(n);
864 snprintf(buf, len, "anchor,mouse,in,%s", n);
865 _edje_emit(ed, buf, rp->part->name);
867 ev->event_flags |= rp->part->mask_flags;
871 _edje_anchor_mouse_out_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
874 Evas_Event_Mouse_Out *ev = event_info;
875 Edje_Real_Part *rp = an->en->rp;
879 Edje *ed = an->en->ed;
881 ignored = rp->part->ignore_flags & ev->event_flags;
882 if ((!ev->event_flags) || (!ignored))
884 /* set to allow handling in elementary, in case we have
885 * an unwanted event propagation */
886 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
890 len = 200 + strlen(n);
892 snprintf(buf, len, "anchor,mouse,out,%s", n);
893 _edje_emit(ed, buf, rp->part->name);
895 ev->event_flags |= rp->part->mask_flags;
899 _anchors_update(Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Entry *en)
901 Eina_List *l, *ll, *range = NULL;
902 Evas_Coord x, y, w, h;
903 Evas_Object *smart, *clip;
908 smart = evas_object_smart_parent_get(o);
909 clip = evas_object_clip_get(o);
911 evas_object_geometry_get(o, &x, &y, &w, &h);
912 EINA_LIST_FOREACH(en->anchors, l, an)
924 if (sel->obj_bg) evas_object_del(sel->obj_bg);
925 if (sel->obj_fg) evas_object_del(sel->obj_fg);
926 if (sel->obj) evas_object_del(sel->obj);
928 an->sel = eina_list_remove_list(an->sel, an->sel);
931 sel = calloc(1, sizeof(Sel));
932 an->sel = eina_list_append(an->sel, sel);
934 if (ed->item_provider.func)
936 ob = ed->item_provider.func
937 (ed->item_provider.data, smart,
938 en->rp->part->name, an->name);
939 evas_object_smart_member_add(ob, smart);
940 evas_object_stack_above(ob, o);
941 evas_object_clip_set(ob, clip);
942 evas_object_pass_events_set(ob, EINA_TRUE);
943 evas_object_show(ob);
952 evas_textblock_cursor_range_geometry_get(an->start, an->end);
953 if (eina_list_count(range) != eina_list_count(an->sel))
958 if (sel->obj_bg) evas_object_del(sel->obj_bg);
959 if (sel->obj_fg) evas_object_del(sel->obj_fg);
960 if (sel->obj) evas_object_del(sel->obj);
962 an->sel = eina_list_remove_list(an->sel, an->sel);
964 for (ll = range; ll; ll = eina_list_next(ll))
968 sel = calloc(1, sizeof(Sel));
969 an->sel = eina_list_append(an->sel, sel);
970 ob = edje_object_add(ed->base->evas);
971 edje_object_file_set(ob, ed->path, en->rp->part->source5);
972 evas_object_smart_member_add(ob, smart);
973 evas_object_stack_below(ob, o);
974 evas_object_clip_set(ob, clip);
975 evas_object_pass_events_set(ob, EINA_TRUE);
976 evas_object_show(ob);
978 _edje_subobj_register(ed, sel->obj_bg);
980 ob = edje_object_add(ed->base->evas);
981 edje_object_file_set(ob, ed->path, en->rp->part->source6);
982 evas_object_smart_member_add(ob, smart);
983 evas_object_stack_above(ob, o);
984 evas_object_clip_set(ob, clip);
985 evas_object_pass_events_set(ob, EINA_TRUE);
986 evas_object_show(ob);
988 _edje_subobj_register(ed, sel->obj_fg);
990 ob = evas_object_rectangle_add(ed->base->evas);
991 evas_object_color_set(ob, 0, 0, 0, 0);
992 evas_object_smart_member_add(ob, smart);
993 evas_object_stack_above(ob, o);
994 evas_object_clip_set(ob, clip);
995 evas_object_repeat_events_set(ob, EINA_TRUE);
996 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an);
997 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an);
998 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an);
999 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an);
1000 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an);
1001 evas_object_show(ob);
1006 EINA_LIST_FOREACH(an->sel, ll, sel)
1010 Evas_Coord cx, cy, cw, ch;
1012 if (!evas_textblock_cursor_format_item_geometry_get
1013 (an->start, &cx, &cy, &cw, &ch))
1015 evas_object_move(sel->obj, x + cx, y + cy);
1016 evas_object_resize(sel->obj, cw, ch);
1020 Evas_Textblock_Rectangle *r;
1023 *(&(sel->rect)) = *r;
1026 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
1027 evas_object_resize(sel->obj_bg, r->w, r->h);
1031 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
1032 evas_object_resize(sel->obj_fg, r->w, r->h);
1036 evas_object_move(sel->obj, x + r->x, y + r->y);
1037 evas_object_resize(sel->obj, r->w, r->h);
1039 range = eina_list_remove_list(range, range);
1047 _anchors_clear(Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Entry *en)
1049 while (en->anchorlist)
1051 free(en->anchorlist->data);
1052 en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
1054 while (en->itemlist)
1056 free(en->itemlist->data);
1057 en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
1061 Anchor *an = en->anchors->data;
1063 evas_textblock_cursor_free(an->start);
1064 evas_textblock_cursor_free(an->end);
1067 Sel *sel = an->sel->data;
1068 if (sel->obj_bg) evas_object_del(sel->obj_bg);
1069 if (sel->obj_fg) evas_object_del(sel->obj_fg);
1070 if (sel->obj) evas_object_del(sel->obj);
1072 an->sel = eina_list_remove_list(an->sel, an->sel);
1076 en->anchors = eina_list_remove_list(en->anchors, en->anchors);
1080 /* FIXME: This is horrible. It's just a copy&paste (with some adjustments)
1081 * from textblock. I didn't want to introduce any non-API links between the
1082 * libs so I just copied it. Should have been handled differently. */
1084 _anchor_format_parse(const char *item)
1086 const char *start, *end;
1090 start = strchr(item, '=');
1091 if (!start) return NULL;
1093 start++; /* Advance after the '=' */
1094 /* If we can find a quote as the first non-space char,
1095 * our new delimiter is a quote, not a space. */
1096 while (*start == ' ')
1102 end = strchr(start, '\'');
1103 while ((end) && (end > start) && (end[-1] == '\\'))
1104 end = strchr(end + 1, '\'');
1108 end = strchr(start, ' ');
1109 while ((end) && (end > start) && (end[-1] == '\\'))
1110 end = strchr(end + 1, ' ');
1113 /* Null terminate before the spaces */
1114 if (end) len = end - start;
1115 else len = strlen(start);
1117 tmp = malloc(len + 1);
1118 strncpy(tmp, start, len);
1125 _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1127 const Eina_List *anchors_a, *anchors_item;
1129 _anchors_clear(c, o, en);
1131 anchors_a = evas_textblock_node_format_list_get(o, "a");
1132 anchors_item = evas_textblock_node_format_list_get(o, "item");
1136 const Evas_Object_Textblock_Node_Format *node;
1137 const Eina_List *itr;
1138 EINA_LIST_FOREACH(anchors_a, itr, node)
1140 const char *s = evas_textblock_node_format_text_get(node);
1142 an = calloc(1, sizeof(Anchor));
1147 p = strstr(s, "href=");
1150 an->name = _anchor_format_parse(p);
1152 en->anchors = eina_list_append(en->anchors, an);
1153 an->start = evas_object_textblock_cursor_new(o);
1154 an->end = evas_object_textblock_cursor_new(o);
1155 evas_textblock_cursor_at_format_set(an->start, node);
1156 evas_textblock_cursor_copy(an->start, an->end);
1158 /* Close the anchor, if the anchor was without text,
1159 * free it as well */
1160 node = evas_textblock_node_format_next_get(node);
1161 for (; node; node = evas_textblock_node_format_next_get(node))
1163 s = evas_textblock_node_format_text_get(node);
1164 if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
1170 evas_textblock_cursor_at_format_set(an->end, node);
1172 else if (!evas_textblock_cursor_compare(an->start, an->end))
1174 if (an->name) free(an->name);
1175 evas_textblock_cursor_free(an->start);
1176 evas_textblock_cursor_free(an->end);
1177 en->anchors = eina_list_remove(en->anchors, an);
1186 const Evas_Object_Textblock_Node_Format *node;
1187 const Eina_List *itr;
1188 EINA_LIST_FOREACH(anchors_item, itr, node)
1190 const char *s = evas_textblock_node_format_text_get(node);
1192 an = calloc(1, sizeof(Anchor));
1198 p = strstr(s, "href=");
1201 an->name = _anchor_format_parse(p);
1203 en->anchors = eina_list_append(en->anchors, an);
1204 an->start = evas_object_textblock_cursor_new(o);
1205 an->end = evas_object_textblock_cursor_new(o);
1206 evas_textblock_cursor_at_format_set(an->start, node);
1207 evas_textblock_cursor_copy(an->start, an->end);
1208 /* Although needed in textblock, don't bother with finding the end
1209 * here cause it doesn't really matter. */
1215 _free_entry_change_info(void *_info)
1217 Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
1220 eina_stringshare_del(info->change.insert.content);
1224 eina_stringshare_del(info->change.del.content);
1230 _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Entry *en)
1234 Edje_Entry_Change_Info *info;
1236 start = evas_textblock_cursor_pos_get(en->sel_start);
1237 end = evas_textblock_cursor_pos_get(en->sel_end);
1241 info = calloc(1, sizeof(*info));
1242 info->insert = EINA_FALSE;
1243 info->change.del.start = start;
1244 info->change.del.end = end;
1246 tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
1247 info->change.del.content = eina_stringshare_add(tmp);
1249 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1250 _edje_emit(ed, "entry,changed", en->rp->part->name);
1251 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
1252 _free_entry_change_info);
1254 _sel_clear(ed, en->cursor, en->rp->object, en);
1258 //_range_del(Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED, Entry *en)
1260 // evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1261 // _sel_clear(ed, en->cursor, en->rp->object, en);
1265 _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1266 Eina_Bool backspace)
1268 if (!evas_textblock_cursor_char_next(c))
1272 evas_textblock_cursor_char_prev(c);
1274 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1275 char *tmp = evas_textblock_cursor_content_get(c);
1277 info->insert = EINA_FALSE;
1280 info->change.del.start = pos - 1;
1281 info->change.del.end = pos;
1285 info->change.del.start = pos + 1;
1286 info->change.del.end = pos;
1289 info->change.del.content = eina_stringshare_add(tmp);
1292 evas_textblock_cursor_char_delete(c);
1293 _edje_emit(ed, "entry,changed", en->rp->part->name);
1294 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1295 info, _free_entry_change_info);
1299 _edje_entry_hide_visible_password(Edje *ed, Edje_Real_Part *rp)
1301 const Evas_Object_Textblock_Node_Format *node;
1302 node = evas_textblock_node_format_first_get(rp->object);
1303 for (; node; node = evas_textblock_node_format_next_get(node))
1305 const char *text = evas_textblock_node_format_text_get(node);
1308 if (!strcmp(text, "+ password=off"))
1310 evas_textblock_node_format_remove_pair(rp->object,
1311 (Evas_Object_Textblock_Node_Format *) node);
1312 _edje_emit(ed, "entry,changed", rp->part->name);
1317 _edje_entry_real_part_configure(ed, rp);
1321 _password_timer_cb(void *data)
1323 Entry *en = (Entry *)data;
1324 _edje_entry_hide_visible_password(en->ed, en->rp);
1325 en->pw_timer = NULL;
1326 return ECORE_CALLBACK_CANCEL;
1330 _is_modifier(const char *key)
1332 if ((!strncmp(key, "Shift", 5)) ||
1333 (!strncmp(key, "Control", 7)) ||
1334 (!strncmp(key, "Alt", 3)) ||
1335 (!strncmp(key, "Meta", 4)) ||
1336 (!strncmp(key, "Super", 5)) ||
1337 (!strncmp(key, "Hyper", 5)) ||
1338 (!strcmp(key, "Scroll_Lock")) ||
1339 (!strcmp(key, "Num_Lock")) ||
1340 (!strcmp(key, "Caps_Lock")))
1346 _compose_seq_reset(Entry *en)
1350 EINA_LIST_FREE(en->seq, str) eina_stringshare_del(str);
1351 en->composing = EINA_FALSE;
1355 _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1358 Evas_Event_Key_Down *ev = event_info;
1359 Edje_Real_Part *rp = ed->focused_part;
1361 Eina_Bool control, alt, shift;
1362 Eina_Bool multiline;
1363 Eina_Bool cursor_changed;
1366 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1367 (!rp->typedata.text)) return;
1368 en = rp->typedata.text->entry_data;
1369 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1370 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1372 if (!ev->key) return;
1374 _edje_emit(ed, "entry,keydown", rp->part->name);
1375 #ifdef HAVE_ECORE_IMF
1376 if (en->imf_context)
1378 Ecore_IMF_Event_Key_Down ecore_ev;
1379 ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
1382 if (ecore_imf_context_filter_event(en->imf_context,
1383 ECORE_IMF_EVENT_KEY_DOWN,
1384 (Ecore_IMF_Event *)&ecore_ev))
1386 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1393 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1395 control = evas_key_modifier_is_set(ev->modifiers, "Control");
1396 alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
1397 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1398 multiline = rp->part->multiline;
1399 cursor_changed = EINA_FALSE;
1400 if (!strcmp(ev->key, "Escape"))
1402 _compose_seq_reset(en);
1403 // dead keys here. Escape for now (should emit these)
1404 _edje_emit(ed, "entry,key,escape", rp->part->name);
1405 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1407 else if (!strcmp(ev->key, "Up") ||
1408 (!strcmp(ev->key, "KP_Up") && !ev->string))
1410 _compose_seq_reset(en);
1413 if (en->have_selection &&
1414 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1415 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1416 if (en->select_allow)
1420 _sel_start(en->cursor, rp->object, en);
1421 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1423 else if (en->have_selection)
1425 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
1426 evas_textblock_cursor_copy(en->sel_start, en->cursor);
1428 evas_textblock_cursor_copy(en->sel_end, en->cursor);
1429 _sel_clear(ed, en->cursor, rp->object, en);
1432 if (_curs_up(en->cursor, rp->object, en))
1433 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1434 if (en->select_allow)
1436 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1437 else _sel_clear(ed, en->cursor, rp->object, en);
1440 _edje_emit(ed, "entry,key,up", rp->part->name);
1441 _edje_emit(ed, "cursor,changed,manual", rp->part->name);
1443 else if (!strcmp(ev->key, "Down") ||
1444 (!strcmp(ev->key, "KP_Down") && !ev->string))
1446 _compose_seq_reset(en);
1449 if (en->have_selection &&
1450 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1451 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1452 if (en->select_allow)
1456 _sel_start(en->cursor, rp->object, en);
1457 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1459 else if (en->have_selection)
1461 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
1462 evas_textblock_cursor_copy(en->sel_end, en->cursor);
1464 evas_textblock_cursor_copy(en->sel_start, en->cursor);
1465 _sel_clear(ed, en->cursor, rp->object, en);
1468 if (_curs_down(en->cursor, rp->object, en))
1469 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1470 if (en->select_allow)
1472 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1473 else _sel_clear(ed, en->cursor, rp->object, en);
1476 _edje_emit(ed, "entry,key,down", rp->part->name);
1477 _edje_emit(ed, "cursor,changed,manual", rp->part->name);
1479 else if (!strcmp(ev->key, "Left") ||
1480 (!strcmp(ev->key, "KP_Left") && !ev->string))
1482 _compose_seq_reset(en);
1483 if (en->have_selection &&
1484 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1485 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1486 if (en->select_allow)
1490 _sel_start(en->cursor, rp->object, en);
1491 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1495 if (en->have_selection)
1497 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
1498 evas_textblock_cursor_copy(en->sel_start, en->cursor);
1500 evas_textblock_cursor_copy(en->sel_end, en->cursor);
1501 _sel_clear(ed, en->cursor, rp->object, en);
1505 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
1506 //if (evas_textblock_cursor_char_prev(en->cursor))
1507 if (evas_textblock_cursor_cluster_prev(en->cursor))
1508 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1509 /* If control is pressed, go to the start of the word */
1510 if (control) evas_textblock_cursor_word_start(en->cursor);
1511 if (en->select_allow)
1513 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1514 else _sel_clear(ed, en->cursor, rp->object, en);
1516 _edje_emit(ed, "entry,key,left", rp->part->name);
1517 _edje_emit(ed, "cursor,changed,manual", rp->part->name);
1519 else if (!strcmp(ev->key, "Right") ||
1520 (!strcmp(ev->key, "KP_Right") && !ev->string))
1522 _compose_seq_reset(en);
1523 if (en->have_selection &&
1524 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1525 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1526 if (en->select_allow)
1530 _sel_start(en->cursor, rp->object, en);
1531 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1535 if (en->have_selection)
1537 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
1538 evas_textblock_cursor_copy(en->sel_end, en->cursor);
1540 evas_textblock_cursor_copy(en->sel_start, en->cursor);
1541 _sel_clear(ed, en->cursor, rp->object, en);
1545 /* If control is pressed, go to the end of the word */
1546 if (control) evas_textblock_cursor_word_end(en->cursor);
1547 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
1548 //if (evas_textblock_cursor_char_next(en->cursor))
1549 if (evas_textblock_cursor_cluster_next(en->cursor))
1550 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1551 if (en->select_allow)
1553 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1554 else _sel_clear(ed, en->cursor, rp->object, en);
1556 _edje_emit(ed, "entry,key,right", rp->part->name);
1557 _edje_emit(ed, "cursor,changed,manual", rp->part->name);
1559 else if (!strcmp(ev->key, "BackSpace"))
1561 _compose_seq_reset(en);
1562 if (control && !en->have_selection)
1564 // del to start of previous word
1565 _sel_start(en->cursor, rp->object, en);
1567 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
1568 //evas_textblock_cursor_char_prev(en->cursor);
1569 evas_textblock_cursor_cluster_prev(en->cursor);
1571 evas_textblock_cursor_word_start(en->cursor);
1573 _sel_preextend(ed, en->cursor, rp->object, en);
1575 _range_del_emit(ed, en->cursor, rp->object, en);
1577 else if ((alt) && (shift))
1583 if (en->have_selection)
1585 _range_del_emit(ed, en->cursor, rp->object, en);
1589 if (evas_textblock_cursor_char_prev(en->cursor))
1591 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
1595 _sel_clear(ed, en->cursor, rp->object, en);
1596 _anchors_get(en->cursor, rp->object, en);
1597 _edje_emit(ed, "entry,key,backspace", rp->part->name);
1598 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1600 else if (!strcmp(ev->key, "Delete") ||
1601 (!strcmp(ev->key, "KP_Delete") && !ev->string))
1603 _compose_seq_reset(en);
1606 // del to end of next word
1607 _sel_start(en->cursor, rp->object, en);
1609 evas_textblock_cursor_word_end(en->cursor);
1610 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
1611 //evas_textblock_cursor_char_next(en->cursor);
1612 evas_textblock_cursor_cluster_next(en->cursor);
1615 _sel_extend(ed, en->cursor, rp->object, en);
1617 _range_del_emit(ed, en->cursor, rp->object, en);
1625 if (en->have_selection)
1627 _range_del_emit(ed, en->cursor, rp->object, en);
1631 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
1634 _sel_clear(ed, en->cursor, rp->object, en);
1635 _anchors_get(en->cursor, rp->object, en);
1636 _edje_emit(ed, "entry,key,delete", rp->part->name);
1637 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1640 (!strcmp(ev->key, "Home") ||
1641 ((!strcmp(ev->key, "KP_Home")) && !ev->string)))
1643 _compose_seq_reset(en);
1644 if (en->select_allow)
1646 if (shift) _sel_start(en->cursor, rp->object, en);
1647 else _sel_clear(ed, en->cursor, rp->object, en);
1649 if ((control) && (multiline))
1650 _curs_start(en->cursor, rp->object, en);
1652 _curs_lin_start(en->cursor, rp->object, en);
1653 if (en->select_allow)
1655 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1657 _edje_emit(ed, "entry,key,home", rp->part->name);
1658 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1661 (!strcmp(ev->key, "End") ||
1662 ((!strcmp(ev->key, "KP_End")) && !ev->string)))
1664 _compose_seq_reset(en);
1665 if (en->select_allow)
1667 if (shift) _sel_start(en->cursor, rp->object, en);
1668 else _sel_clear(ed, en->cursor, rp->object, en);
1670 if ((control) && (multiline))
1671 _curs_end(en->cursor, rp->object, en);
1673 _curs_lin_end(en->cursor, rp->object, en);
1674 if (en->select_allow)
1676 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1678 _edje_emit(ed, "entry,key,end", rp->part->name);
1679 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1681 else if ((control) && (!shift) && (!strcmp(ev->key, "v")))
1683 _compose_seq_reset(en);
1684 _edje_emit(ed, "entry,paste,request", rp->part->name);
1685 _edje_emit(ed, "entry,paste,request,3", rp->part->name);
1686 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1688 else if ((control) && (!strcmp(ev->key, "a")))
1690 _compose_seq_reset(en);
1693 _edje_emit(ed, "entry,selection,none,request", rp->part->name);
1694 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1698 _edje_emit(ed, "entry,selection,all,request", rp->part->name);
1699 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1702 else if ((control) && (((!shift) && !strcmp(ev->key, "c")) || !strcmp(ev->key, "Insert")))
1704 _compose_seq_reset(en);
1705 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1706 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1708 else if ((control) && (!shift) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m")))))
1710 _compose_seq_reset(en);
1711 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1712 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1714 else if ((control) && (!strcmp(ev->key, "z")))
1716 _compose_seq_reset(en);
1720 _edje_emit(ed, "entry,redo,request", rp->part->name);
1725 _edje_emit(ed, "entry,undo,request", rp->part->name);
1727 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1729 else if ((control) && (!shift) && (!strcmp(ev->key, "y")))
1731 _compose_seq_reset(en);
1733 _edje_emit(ed, "entry,redo,request", rp->part->name);
1734 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1736 //else if ((control) && (!shift) && (!strcmp(ev->key, "w")))
1738 //_compose_seq_reset(en);
1739 //_sel_clear(ed, en->cursor, rp->object, en);
1740 //select current word?
1741 //ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1743 else if (!strcmp(ev->key, "Tab"))
1745 _compose_seq_reset(en);
1754 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1755 info->insert = EINA_TRUE;
1756 info->change.insert.plain_length = 1;
1758 if (en->have_selection)
1760 _range_del_emit(ed, en->cursor, rp->object, en);
1761 info->merge = EINA_TRUE;
1763 info->change.insert.pos =
1764 evas_textblock_cursor_pos_get(en->cursor);
1765 info->change.insert.content = eina_stringshare_add("<tab/>");
1766 _text_filter_format_prepend(ed, en, en->cursor, "tab");
1767 _anchors_get(en->cursor, rp->object, en);
1768 _edje_emit(ed, "entry,changed", rp->part->name);
1769 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1770 info, _free_entry_change_info);
1772 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1774 _edje_emit(ed, "entry,key,tab", rp->part->name);
1776 else if ((!strcmp(ev->key, "ISO_Left_Tab")) && (multiline))
1778 _compose_seq_reset(en);
1780 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1782 else if (!strcmp(ev->key, "Prior") ||
1783 (!strcmp(ev->key, "KP_Prior") && !ev->string))
1785 _compose_seq_reset(en);
1786 if (en->select_allow)
1788 if (shift) _sel_start(en->cursor, rp->object, en);
1789 else _sel_clear(ed, en->cursor, rp->object, en);
1791 if (!_curs_jump_line_by(en->cursor, rp->object, en, -10))
1793 evas_textblock_cursor_line_set(en->cursor, 0);
1794 _curs_lin_start(en->cursor, rp->object, en);
1796 if (en->select_allow)
1798 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1799 else _sel_clear(ed, en->cursor, rp->object, en);
1801 _edje_emit(ed, "entry,key,pgup", rp->part->name);
1802 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1804 else if (!strcmp(ev->key, "Next") ||
1805 (!strcmp(ev->key, "KP_Next") && !ev->string))
1807 _compose_seq_reset(en);
1808 if (en->select_allow)
1810 if (shift) _sel_start(en->cursor, rp->object, en);
1811 else _sel_clear(ed, en->cursor, rp->object, en);
1813 if (!_curs_jump_line_by(en->cursor, rp->object, en, 10))
1815 int last = _curs_line_last_get(en->cursor, rp->object, en);
1816 evas_textblock_cursor_line_set(en->cursor, last);
1817 _curs_lin_end(en->cursor, rp->object, en);
1819 if (en->select_allow)
1821 if (shift) _sel_extend(ed, en->cursor, rp->object, en);
1822 else _sel_clear(ed, en->cursor, rp->object, en);
1824 _edje_emit(ed, "entry,key,pgdn", rp->part->name);
1825 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1827 else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
1829 _compose_seq_reset(en);
1832 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1833 info->insert = EINA_TRUE;
1834 info->change.insert.plain_length = 1;
1835 if (en->have_selection)
1837 _range_del_emit(ed, en->cursor, rp->object, en);
1838 info->merge = EINA_TRUE;
1841 info->change.insert.pos =
1842 evas_textblock_cursor_pos_get(en->cursor);
1844 evas_object_textblock_legacy_newline_get(rp->object))
1846 _text_filter_format_prepend(ed, en, en->cursor, "br");
1847 info->change.insert.content = eina_stringshare_add("<br/>");
1851 _text_filter_format_prepend(ed, en, en->cursor, "ps");
1852 info->change.insert.content = eina_stringshare_add("<ps/>");
1854 _anchors_get(en->cursor, rp->object, en);
1855 _edje_emit(ed, "entry,changed", rp->part->name);
1856 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1857 info, _free_entry_change_info);
1858 _edje_emit(ed, "cursor,changed", rp->part->name);
1859 cursor_changed = EINA_TRUE;
1860 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1862 _edje_emit(ed, "entry,key,enter", rp->part->name);
1866 char *compres = NULL, *string = (char *)ev->string;
1867 Eina_Bool free_string = EINA_FALSE;
1868 Ecore_Compose_State state;
1872 _compose_seq_reset(en);
1873 en->seq = eina_list_append(en->seq, eina_stringshare_add(ev->key));
1874 state = ecore_compose_get(en->seq, &compres);
1875 if (state == ECORE_COMPOSE_MIDDLE) en->composing = EINA_TRUE;
1876 else en->composing = EINA_FALSE;
1881 _compose_seq_reset(en);
1882 if (ev->string && (!ev->string[1]) && (ev->string[0] < 0x20))
1894 if (_is_modifier(ev->key)) goto end;
1895 en->seq = eina_list_append(en->seq, eina_stringshare_add(ev->key));
1896 state = ecore_compose_get(en->seq, &compres);
1897 if (state == ECORE_COMPOSE_NONE)
1899 _compose_seq_reset(en);
1903 else if (state == ECORE_COMPOSE_DONE)
1905 _compose_seq_reset(en);
1909 free_string = EINA_TRUE;
1923 Edje_Entry_Change_Info *info = NULL;
1924 // if PASSWORD_SHOW_LAST mode, appending text with password=off tag
1925 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
1926 _edje_password_show_last)
1928 _edje_entry_hide_visible_password(ed, en->rp);
1929 info = _text_filter_text_prepend(ed, en, en->cursor, string,
1932 EINA_TRUE, EINA_TRUE);
1937 ecore_timer_del(en->pw_timer);
1938 en->pw_timer = NULL;
1940 if (_edje_password_show_last_timeout >= 0)
1941 en->pw_timer = ecore_timer_add
1942 (_edje_password_show_last_timeout,
1943 _password_timer_cb, en);
1947 info = _text_filter_text_prepend(ed, en, en->cursor, string,
1949 EINA_TRUE, EINA_TRUE);
1950 _anchors_get(en->cursor, rp->object, en);
1953 _edje_emit(ed, "entry,changed", rp->part->name);
1954 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1955 info, _free_entry_change_info);
1956 _edje_emit(ed, "cursor,changed", rp->part->name);
1957 cursor_changed = EINA_TRUE;
1958 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1960 if (free_string) free(string);
1964 if (!cursor_changed &&
1965 (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
1966 _edje_emit(ed, "cursor,changed", rp->part->name);
1968 _edje_entry_imf_cursor_info_set(en);
1969 _edje_entry_real_part_configure(ed, rp);
1973 _edje_key_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1976 Edje_Real_Part *rp = ed->focused_part;
1980 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1981 (!rp->typedata.text)) return;
1982 en = rp->typedata.text->entry_data;
1983 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1984 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1987 _edje_emit(ed, "entry,keyup", rp->part->name);
1988 #ifdef HAVE_ECORE_IMF
1989 if (en->imf_context)
1991 Evas_Event_Key_Up *ev = event_info;
1992 Ecore_IMF_Event_Key_Up ecore_ev;
1994 ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev);
1995 if (ecore_imf_context_filter_event(en->imf_context,
1996 ECORE_IMF_EVENT_KEY_UP,
1997 (Ecore_IMF_Event *)&ecore_ev))
2006 _edje_part_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2008 Edje_Real_Part *rp = data;
2011 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2012 (!rp->typedata.text)) return;
2013 en = rp->typedata.text->entry_data;
2015 _edje_entry_imf_cursor_location_set(en);
2019 _edje_part_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
2022 Edje_Real_Part *rp = data;
2023 Evas_Event_Mouse_Down *ev = event_info;
2025 Evas_Coord x, y, w, h;
2026 // Eina_Bool multiline;
2027 Evas_Textblock_Cursor *tc = NULL;
2028 // TIZEN_ONLY (20150825): For cursor positioning when mouse down
2029 Evas_Coord fh = 0, cly = 0;
2030 Evas_Textblock_Cursor *line_cur;
2032 Eina_Bool dosel = EINA_FALSE;
2034 if ((!rp) || (!ev)) return;
2035 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
2036 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2037 (!rp->typedata.text)) return;
2038 en = rp->typedata.text->entry_data;
2039 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2040 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2042 if ((ev->button != 1) && (ev->button != 2)) return;
2044 #ifdef HAVE_ECORE_IMF
2045 if (en->imf_context)
2047 Ecore_IMF_Event_Mouse_Down ecore_ev;
2048 ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev);
2049 if (ecore_imf_context_filter_event(en->imf_context,
2050 ECORE_IMF_EVENT_MOUSE_DOWN,
2051 (Ecore_IMF_Event *)&ecore_ev))
2056 _edje_entry_imf_context_reset(rp);
2058 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
2059 en->select_mod_start = EINA_FALSE;
2060 en->select_mod_end = EINA_FALSE;
2062 if (en->select_allow && ev->button != 2) dosel = EINA_TRUE;
2065 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
2069 tc = evas_object_textblock_cursor_new(rp->object);
2070 evas_textblock_cursor_copy(en->cursor, tc);
2071 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
2072 evas_textblock_cursor_line_char_first(en->cursor);
2074 evas_textblock_cursor_line_char_last(en->cursor);
2075 _sel_extend(en->ed, en->cursor, rp->object, en);
2079 en->have_selection = EINA_FALSE;
2080 en->selecting = EINA_FALSE;
2081 _sel_clear(en->ed, en->cursor, rp->object, en);
2082 tc = evas_object_textblock_cursor_new(rp->object);
2083 evas_textblock_cursor_copy(en->cursor, tc);
2084 evas_textblock_cursor_line_char_first(en->cursor);
2085 _sel_start(en->cursor, rp->object, en);
2086 evas_textblock_cursor_line_char_last(en->cursor);
2087 _sel_extend(en->ed, en->cursor, rp->object, en);
2091 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
2095 tc = evas_object_textblock_cursor_new(rp->object);
2096 evas_textblock_cursor_copy(en->cursor, tc);
2097 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
2098 evas_textblock_cursor_word_start(en->cursor);
2101 evas_textblock_cursor_word_end(en->cursor);
2102 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
2103 //evas_textblock_cursor_char_next(en->cursor);
2104 evas_textblock_cursor_cluster_next(en->cursor);
2107 _sel_extend(en->ed, en->cursor, rp->object, en);
2111 en->have_selection = EINA_FALSE;
2112 en->selecting = EINA_FALSE;
2113 _sel_clear(en->ed, en->cursor, rp->object, en);
2114 tc = evas_object_textblock_cursor_new(rp->object);
2115 evas_textblock_cursor_copy(en->cursor, tc);
2116 evas_textblock_cursor_word_start(en->cursor);
2117 _sel_start(en->cursor, rp->object, en);
2118 evas_textblock_cursor_word_end(en->cursor);
2119 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
2120 //evas_textblock_cursor_char_next(en->cursor);
2121 evas_textblock_cursor_cluster_next(en->cursor);
2123 _sel_extend(en->ed, en->cursor, rp->object, en);
2128 tc = evas_object_textblock_cursor_new(rp->object);
2129 evas_textblock_cursor_copy(en->cursor, tc);
2130 // multiline = rp->part->multiline;
2131 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2132 cx = ev->canvas.x - x;
2133 cy = ev->canvas.y - y;
2134 // TIZEN_ONLY (20150825): For cursor positioning when down up
2135 evas_object_textblock_size_formatted_get(rp->object, NULL, &fh);
2140 line_cur = evas_object_textblock_cursor_new(rp->object);
2141 evas_textblock_cursor_paragraph_first(line_cur);
2142 evas_textblock_cursor_line_geometry_get(line_cur, NULL, &cly, NULL, NULL);
2148 evas_textblock_cursor_free(line_cur);
2150 // TIZEN ONLY (20150909): only change cursor position in mouse up
2151 //if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2152 if (dosel && !evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2155 Evas_Coord lx, ly, lw, lh;
2158 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2161 if (rp->part->multiline)
2162 _curs_end(en->cursor, rp->object, en);
2165 evas_textblock_cursor_paragraph_first(en->cursor);
2166 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2167 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2168 _curs_end(en->cursor, rp->object, en);
2175 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2178 _curs_lin_start(en->cursor, rp->object, en);
2183 _curs_lin_start(en->cursor, rp->object, en);
2185 _curs_lin_end(en->cursor, rp->object, en);
2191 if ((en->have_selection) &&
2192 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2195 _sel_extend(en->ed, en->cursor, rp->object, en);
2198 Eina_List *first, *last;
2202 last = eina_list_last(en->sel);
2205 Evas_Textblock_Rectangle *r1, *r2;
2206 Evas_Coord d, d1, d2;
2212 d = (r1->y + (r1->h / 2)) - cy;
2214 d = r2->x + r2->w - 1 - cx;
2216 d = (r2->y + (r2->h / 2)) - cy;
2218 sc = DIV(en->ed->scale, en->ed->file->base_scale);
2219 if (sc == ZERO) sc = DIV(_edje_scale, en->ed->file->base_scale);
2220 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
2226 en->select_mod_start = EINA_TRUE;
2227 en->selecting = EINA_TRUE;
2234 en->select_mod_end = EINA_TRUE;
2235 en->selecting = EINA_TRUE;
2243 if ((en->have_selection) && (shift))
2244 _sel_extend(en->ed, en->cursor, rp->object, en);
2247 en->selecting = EINA_TRUE;
2248 _sel_clear(en->ed, en->cursor, rp->object, en);
2249 _sel_start(en->cursor, rp->object, en);
2254 if (evas_textblock_cursor_compare(tc, en->cursor))
2256 _edje_emit(en->ed, "cursor,changed", rp->part->name);
2257 _edje_emit(en->ed, "cursor,changed,manual", rp->part->name);
2259 evas_textblock_cursor_free(tc);
2261 _edje_entry_real_part_configure(en->ed, rp);
2262 if (ev->button == 2)
2264 _edje_emit(en->ed, "entry,paste,request", rp->part->name);
2265 _edje_emit(en->ed, "entry,paste,request,1", rp->part->name);
2270 _edje_part_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
2273 Edje_Real_Part *rp = data;
2274 Evas_Event_Mouse_Up *ev = event_info;
2276 Evas_Coord x, y, w, h;
2277 // TIZEN_ONLY (20150813): For cursor positioning when mouse up
2278 Evas_Coord fh = 0, cly = 0;
2279 Evas_Textblock_Cursor *line_cur;
2281 Evas_Textblock_Cursor *tc;
2282 if ((!ev) || (ev->button != 1)) return;
2284 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return;
2285 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return;
2286 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2287 (!rp->typedata.text)) return;
2288 en = rp->typedata.text->entry_data;
2289 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2290 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2294 /* We don't check for ON_HOLD because we'd like to end selection anyway when
2295 * mouse is up, even if it's held. */
2296 // TIZEN_ONLY(20150709): When parent is moving entry needs not to update
2297 // cursor and above comment seems not be valid since when parent is moving selection
2299 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2301 _edje_entry_imf_cursor_info_set(en);
2306 #ifdef HAVE_ECORE_IMF
2307 if (en->imf_context)
2309 Ecore_IMF_Event_Mouse_Up ecore_ev;
2310 ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev);
2311 if (ecore_imf_context_filter_event(en->imf_context,
2312 ECORE_IMF_EVENT_MOUSE_UP,
2313 (Ecore_IMF_Event *)&ecore_ev))
2318 tc = evas_object_textblock_cursor_new(rp->object);
2319 evas_textblock_cursor_copy(en->cursor, tc);
2320 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2321 cx = ev->canvas.x - x;
2322 cy = ev->canvas.y - y;
2323 // TIZEN_ONLY (20150813): For cursor positioning when mouse up
2324 evas_object_textblock_size_formatted_get(rp->object, NULL, &fh);
2329 line_cur = evas_object_textblock_cursor_new(rp->object);
2330 evas_textblock_cursor_paragraph_first(line_cur);
2331 evas_textblock_cursor_line_geometry_get(line_cur, NULL, &cly, NULL, NULL);
2337 evas_textblock_cursor_free(line_cur);
2339 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs. //
2340 //if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2341 if (!evas_textblock_cursor_cluster_coord_set(en->cursor, cx, cy))
2343 Evas_Coord lx, ly, lw, lh;
2346 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2349 if (rp->part->multiline)
2350 _curs_end(en->cursor, rp->object, en);
2353 evas_textblock_cursor_paragraph_first(en->cursor);
2354 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2355 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
2356 //if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2357 if (!evas_textblock_cursor_cluster_coord_set(en->cursor, cx, ly + (lh / 2)))
2358 _curs_end(en->cursor, rp->object, en);
2365 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2368 _curs_lin_start(en->cursor, rp->object, en);
2373 _curs_lin_start(en->cursor, rp->object, en);
2375 _curs_lin_end(en->cursor, rp->object, en);
2379 if (en->select_allow)
2381 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
2385 if (en->select_mod_end)
2386 _sel_extend(en->ed, en->cursor, rp->object, en);
2387 else if (en->select_mod_start)
2388 _sel_preextend(en->ed, en->cursor, rp->object, en);
2391 _sel_extend(en->ed, en->cursor, rp->object, en);
2392 //evas_textblock_cursor_copy(en->cursor, en->sel_end);
2396 evas_textblock_cursor_copy(en->cursor, en->sel_end);
2401 if (en->have_selection)
2402 en->had_sel = EINA_TRUE;
2403 en->selecting = EINA_FALSE;
2405 if (evas_textblock_cursor_compare(tc, en->cursor))
2407 _edje_emit(en->ed, "cursor,changed", rp->part->name);
2408 _edje_emit(en->ed, "cursor,changed,manual", rp->part->name);
2411 _edje_entry_imf_cursor_info_set(en);
2413 evas_textblock_cursor_free(tc);
2415 _edje_entry_real_part_configure(en->ed, rp);
2419 _edje_part_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
2422 Edje_Real_Part *rp = data;
2423 Evas_Event_Mouse_Move *ev = event_info;
2425 Evas_Coord x, y, w, h;
2426 Evas_Textblock_Cursor *tc;
2428 if ((!rp) || (!ev)) return;
2429 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2430 (!rp->typedata.text)) return;
2431 en = rp->typedata.text->entry_data;
2432 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2433 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2436 #ifdef HAVE_ECORE_IMF
2437 if (en->imf_context)
2439 Ecore_IMF_Event_Mouse_Move ecore_ev;
2440 ecore_imf_evas_event_mouse_move_wrap(ev, &ecore_ev);
2441 if (ecore_imf_context_filter_event(en->imf_context,
2442 ECORE_IMF_EVENT_MOUSE_MOVE,
2443 (Ecore_IMF_Event *)&ecore_ev))
2450 tc = evas_object_textblock_cursor_new(rp->object);
2451 evas_textblock_cursor_copy(en->cursor, tc);
2452 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2453 cx = ev->cur.canvas.x - x;
2454 cy = ev->cur.canvas.y - y;
2455 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
2456 //if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2457 if (!evas_textblock_cursor_cluster_coord_set(en->cursor, cx, cy))
2459 Evas_Coord lx, ly, lw, lh;
2461 if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0)
2463 if (rp->part->multiline)
2464 _curs_end(en->cursor, rp->object, en);
2467 evas_textblock_cursor_paragraph_first(en->cursor);
2468 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2469 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
2470 //if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2471 if (!evas_textblock_cursor_cluster_coord_set(en->cursor, cx, ly + (lh / 2)))
2472 _curs_end(en->cursor, rp->object, en);
2477 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2479 _curs_lin_start(en->cursor, rp->object, en);
2481 _curs_lin_end(en->cursor, rp->object, en);
2484 if (en->select_allow)
2486 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
2490 if (en->select_mod_end)
2491 _sel_extend(en->ed, en->cursor, rp->object, en);
2492 else if (en->select_mod_start)
2493 _sel_preextend(en->ed, en->cursor, rp->object, en);
2496 _sel_extend(en->ed, en->cursor, rp->object, en);
2500 _sel_extend(en->ed, en->cursor, rp->object, en);
2503 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0)
2504 _sel_enable(en->ed, en->cursor, rp->object, en);
2505 if (en->have_selection)
2506 _sel_update(en->ed, en->cursor, rp->object, en);
2508 if (evas_textblock_cursor_compare(tc, en->cursor))
2510 _edje_emit(en->ed, "cursor,changed", rp->part->name);
2511 _edje_emit(en->ed, "cursor,changed,manual", rp->part->name);
2513 evas_textblock_cursor_free(tc);
2515 _edje_entry_real_part_configure(en->ed, rp);
2520 _evas_focus_in_cb(void *data, Evas *e, EINA_UNUSED void *event_info)
2522 Edje *ed = (Edje *)data;
2525 if (evas_focus_get(e) == ed->obj)
2527 _edje_focus_in_cb(data, NULL, NULL, NULL);
2532 _evas_focus_out_cb(void *data, Evas *e, EINA_UNUSED void *event_info)
2534 Edje *ed = (Edje *)data;
2537 if (evas_focus_get(e) == ed->obj)
2539 _edje_focus_out_cb(data, NULL, NULL, NULL);
2543 /***************************************************************/
2545 _edje_entry_init(Edje *ed)
2547 if (!ed->has_entries)
2549 if (ed->entries_inited)
2551 ed->entries_inited = EINA_TRUE;
2553 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed);
2554 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed);
2555 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed);
2556 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed);
2557 evas_event_callback_add(ed->base->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed);
2558 evas_event_callback_add(ed->base->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed);
2562 _edje_entry_shutdown(Edje *ed)
2564 if ((!ed) || (!ed->has_entries))
2566 if (!ed->entries_inited)
2568 ed->entries_inited = EINA_FALSE;
2570 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb);
2571 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb);
2572 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb);
2573 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb);
2574 if (evas_event_callback_del_full(ed->base->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed)
2575 ERR("could not unregister EVAS_CALLBACK_FOCUS_IN");
2576 if (evas_event_callback_del_full(ed->base->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed)
2577 ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT");
2581 _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp, Ecore_IMF_Context *ic)
2584 #ifdef HAVE_ECORE_IMF
2586 const Ecore_IMF_Context_Info *ctx_info;
2589 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2590 (!rp->typedata.text)) return;
2591 en = calloc(1, sizeof(Entry));
2593 rp->typedata.text->entry_data = en;
2597 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp);
2599 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp);
2600 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp);
2601 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp);
2603 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
2604 en->select_allow = EINA_TRUE;
2606 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
2608 Edje_Part_Description_Text *txt;
2610 txt = (Edje_Part_Description_Text *)rp->chosen_description;
2612 en->select_allow = EINA_FALSE;
2613 if (txt && edje_string_get(&txt->text.repch))
2614 evas_object_textblock_replace_char_set(rp->object, edje_string_get(&txt->text.repch));
2616 evas_object_textblock_replace_char_set(rp->object, "*");
2619 en->cursor_bg = edje_object_add(ed->base->evas);
2620 edje_object_file_set(en->cursor_bg, ed->path, rp->part->source3);
2621 evas_object_smart_member_add(en->cursor_bg, ed->obj);
2622 evas_object_stack_below(en->cursor_bg, rp->object);
2623 evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object));
2624 evas_object_pass_events_set(en->cursor_bg, EINA_TRUE);
2625 _edje_subobj_register(ed, en->cursor_bg);
2627 en->cursor_fg = edje_object_add(ed->base->evas);
2628 edje_object_file_set(en->cursor_fg, ed->path, rp->part->source4);
2629 evas_object_smart_member_add(en->cursor_fg, ed->obj);
2630 evas_object_stack_above(en->cursor_fg, rp->object);
2631 evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object));
2632 evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
2633 _edje_subobj_register(ed, en->cursor_fg);
2635 /* A proxy to the main cursor. */
2636 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
2638 en->cursor_fg2 = evas_object_image_add(ed->base->evas);
2639 evas_object_image_source_set(en->cursor_fg2, en->cursor_fg);
2640 evas_object_image_fill_set(en->cursor_fg2, 0, 0, 1, 1);
2641 evas_object_smart_member_add(en->cursor_fg2, ed->obj);
2642 evas_object_stack_above(en->cursor_fg2, rp->object);
2643 evas_object_clip_set(en->cursor_fg2, evas_object_clip_get(rp->object));
2644 evas_object_pass_events_set(en->cursor_fg2, EINA_TRUE);
2645 _edje_subobj_register(en->ed, en->cursor_fg2);
2648 evas_object_textblock_legacy_newline_set(rp->object, EINA_TRUE);
2650 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2652 evas_object_show(en->cursor_bg);
2653 evas_object_show(en->cursor_fg);
2654 evas_object_show(en->cursor_fg2);
2655 en->input_panel_enable = EINA_TRUE;
2657 #ifdef HAVE_ECORE_IMF
2660 en->commit_cancel = EINA_FALSE;
2662 edje_object_signal_callback_add(ed->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
2663 edje_object_signal_callback_add(ed->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
2665 // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
2668 en->imf_context = ic;
2671 ctx_id = ecore_imf_context_default_id_get();
2674 ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
2675 if (!ctx_info->canvas_type ||
2676 strcmp(ctx_info->canvas_type, "evas") == 0)
2678 en->imf_context = ecore_imf_context_add(ctx_id);
2682 ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
2685 en->imf_context = ecore_imf_context_add(ctx_id);
2690 en->imf_context = NULL;
2692 if (!en->imf_context) goto done;
2695 ecore_imf_context_client_window_set
2697 (void *)ecore_evas_window_get
2698 (ecore_evas_ecore_evas_get(ed->base->evas)));
2699 ecore_imf_context_client_canvas_set(en->imf_context, ed->base->evas);
2701 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
2702 _edje_entry_imf_retrieve_surrounding_cb, ed);
2703 ecore_imf_context_retrieve_selection_callback_set(en->imf_context, _edje_entry_imf_retrieve_selection_cb, ed);
2704 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, ed);
2705 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, ed);
2706 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, ed);
2707 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_SELECTION_SET, _edje_entry_imf_event_selection_set_cb, ed);
2708 ecore_imf_context_input_mode_set(en->imf_context,
2709 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
2710 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
2712 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
2713 ecore_imf_context_input_panel_language_set(en->imf_context, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
2718 #ifdef HAVE_ECORE_IMF
2720 ecore_imf_context_del(ic);
2723 #ifdef HAVE_ECORE_IMF
2726 en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
2730 _edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp, Eina_Bool reuse_ic)
2734 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2735 (!rp->typedata.text)) return;
2736 en = rp->typedata.text->entry_data;
2738 rp->typedata.text->entry_data = NULL;
2739 _sel_clear(ed, en->cursor, rp->object, en);
2740 _anchors_clear(en->cursor, rp->object, en);
2741 #ifdef HAVE_ECORE_IMF
2744 evas_object_del(en->cursor_bg);
2745 evas_object_del(en->cursor_fg);
2746 evas_object_del(en->cursor_fg2);
2750 ecore_timer_del(en->pw_timer);
2751 en->pw_timer = NULL;
2754 #ifdef HAVE_ECORE_IMF
2755 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2757 if (en->imf_context)
2759 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb);
2760 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb);
2761 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
2762 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_SELECTION_SET, _edje_entry_imf_event_selection_set_cb);
2766 ecore_imf_context_del(en->imf_context);
2767 en->imf_context = NULL;
2771 edje_object_signal_callback_del(ed->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
2772 edje_object_signal_callback_del(ed->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb);
2775 _compose_seq_reset(en);
2781 _edje_entry_real_part_configure(Edje *ed, Edje_Real_Part *rp)
2783 Evas_Coord x, y, w, h, xx, yy, ww, hh, xx2, yy2;
2785 Evas_Textblock_Cursor_Type cur_type;
2786 Eina_Bool bidi_cursor = EINA_FALSE;
2788 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2789 (!rp->typedata.text)) return;
2790 en = rp->typedata.text->entry_data;
2792 switch (rp->part->cursor_mode)
2794 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
2795 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
2797 case EDJE_ENTRY_CURSOR_MODE_UNDER:
2798 /* no break for a reason */
2800 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
2803 _sel_update(ed, en->cursor, rp->object, en);
2804 _anchors_update(en->cursor, rp->object, en);
2806 xx = yy = ww = hh = -1;
2807 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2808 bidi_cursor = evas_textblock_cursor_geometry_bidi_get(en->cursor, &xx, &yy, &ww, &hh, &xx2, &yy2, NULL, NULL, cur_type);
2813 evas_object_move(en->cursor_bg, x + xx, y + yy);
2814 evas_object_resize(en->cursor_bg, ww, hh);
2818 evas_object_move(en->cursor_fg, x + xx, y + yy);
2819 evas_object_resize(en->cursor_fg, ww, hh);
2825 evas_object_image_fill_set(en->cursor_fg2, 0, 0, ww, hh / 2);
2826 evas_object_move(en->cursor_fg2, x + xx2, y + yy2 + (hh / 2));
2827 evas_object_resize(en->cursor_fg, ww, hh / 2);
2828 evas_object_resize(en->cursor_fg2, ww, hh / 2);
2830 evas_object_show(en->cursor_fg2);
2834 evas_object_hide(en->cursor_fg2);
2839 // TIZEN_ONLY(20150128): Add evas_textblock_cursor_range_text_valid_markup_get API.
2841 _edje_entry_selection_valid_markup_get(Edje_Real_Part *rp)
2845 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2846 (!rp->typedata.text)) return NULL;
2847 en = rp->typedata.text->entry_data;
2848 if (!en) return NULL;
2849 // get selection - convert to markup
2850 if ((!en->selection) && (en->have_selection))
2851 en->selection = evas_textblock_cursor_range_text_valid_markup_get
2852 (en->sel_start, en->sel_end);
2853 return en->selection;
2858 _edje_entry_selection_get(Edje_Real_Part *rp)
2862 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2863 (!rp->typedata.text)) return NULL;
2864 en = rp->typedata.text->entry_data;
2865 if (!en) return NULL;
2866 // get selection - convert to markup
2867 if ((!en->selection) && (en->have_selection))
2868 en->selection = evas_textblock_cursor_range_text_get
2869 (en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
2870 return en->selection;
2874 _edje_entry_text_get(Edje_Real_Part *rp)
2878 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2879 (!rp->typedata.text)) return NULL;
2880 en = rp->typedata.text->entry_data;
2881 if (!en) return NULL;
2882 // get text - convert to markup
2883 return evas_object_textblock_text_markup_get(rp->object);
2887 _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
2891 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2892 (!rp->typedata.text)) return;
2893 en = rp->typedata.text->entry_data;
2895 _edje_entry_imf_context_reset(rp);
2896 // set text as markup
2897 _sel_clear(en->ed, en->cursor, rp->object, en);
2898 evas_object_textblock_text_markup_set(rp->object, text);
2899 _edje_entry_set_cursor_start(rp);
2901 _anchors_get(en->cursor, rp->object, en);
2902 _edje_emit(en->ed, "entry,changed", rp->part->name);
2903 // TIZEN_ONLY(20150716): Add edje_object_part_text_freeze, thaw APIs for freezing cursor movements.
2904 //_edje_entry_imf_cursor_info_set(en);
2906 //_edje_entry_real_part_configure(en->ed, rp);
2909 _edje_entry_imf_cursor_info_set(en);
2910 _edje_entry_real_part_configure(en->ed, rp);
2914 /* Don't emit cursor changed cause it didn't. It's just init to 0. */
2915 _edje_emit(en->ed, "cursor,changed", rp->part->name);
2920 _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
2924 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2925 (!rp->typedata.text)) return;
2926 en = rp->typedata.text->entry_data;
2927 Evas_Textblock_Cursor *end_cur;
2929 end_cur = evas_object_textblock_cursor_new(rp->object);
2930 evas_textblock_cursor_paragraph_last(end_cur);
2932 _text_filter_markup_prepend(en->ed, en, end_cur, text, NULL, NULL,
2933 EINA_TRUE, EINA_FALSE);
2934 evas_textblock_cursor_free(end_cur);
2936 /* We are updating according to the real cursor on purpose */
2937 _anchors_get(en->cursor, rp->object, en);
2938 _edje_emit(en->ed, "entry,changed", rp->part->name);
2940 _edje_entry_real_part_configure(en->ed, rp);
2944 _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
2948 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2949 (!rp->typedata.text)) return;
2950 en = rp->typedata.text->entry_data;
2952 _edje_entry_imf_context_reset(rp);
2954 // prepend markup @ cursor pos .. XXX: do we need to do this? maybe not?
2955 // if (en->have_selection)
2956 // _range_del(en->cursor, rp->object, en);
2957 _text_filter_markup_prepend(en->ed, en, en->cursor, text, NULL, NULL,
2958 EINA_TRUE, EINA_FALSE);
2959 _anchors_get(en->cursor, rp->object, en);
2960 _edje_emit(en->ed, "entry,changed", rp->part->name);
2961 _edje_emit(en->ed, "cursor,changed", rp->part->name);
2963 _edje_entry_imf_cursor_info_set(en);
2964 _edje_entry_real_part_configure(en->ed, rp);
2968 _edje_entry_set_cursor_start(Edje_Real_Part *rp)
2972 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2973 (!rp->typedata.text)) return;
2974 en = rp->typedata.text->entry_data;
2976 _curs_start(en->cursor, rp->object, en);
2978 // TIZEN_ONLY(20150716): Add edje_object_part_text_freeze, thaw APIs for freezing cursor movements.
2979 //_edje_entry_imf_cursor_info_set(en);
2981 _edje_entry_imf_cursor_info_set(en);
2986 _edje_entry_set_cursor_end(Edje_Real_Part *rp)
2990 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2991 (!rp->typedata.text)) return;
2992 en = rp->typedata.text->entry_data;
2994 _curs_end(en->cursor, rp->object, en);
2996 _edje_entry_imf_cursor_info_set(en);
3000 _edje_entry_select_none(Edje_Real_Part *rp)
3004 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3005 (!rp->typedata.text)) return;
3006 en = rp->typedata.text->entry_data;
3008 _sel_clear(en->ed, en->cursor, rp->object, en);
3009 //TIZEN_ONLY (20150821): Selection is being handled in elm so on mouse up
3010 //selection is clear so cursor info is not sent to imf,
3011 //h/w mouse does not need this.
3012 _edje_entry_imf_cursor_info_set(en);
3017 _edje_entry_select_all(Edje_Real_Part *rp)
3021 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3022 (!rp->typedata.text)) return;
3023 en = rp->typedata.text->entry_data;
3026 _edje_entry_imf_context_reset(rp);
3028 _sel_clear(en->ed, en->cursor, rp->object, en);
3029 _curs_start(en->cursor, rp->object, en);
3030 _sel_enable(en->ed, en->cursor, rp->object, en);
3031 _sel_start(en->cursor, rp->object, en);
3032 _curs_end(en->cursor, rp->object, en);
3033 _sel_extend(en->ed, en->cursor, rp->object, en);
3035 _edje_entry_real_part_configure(en->ed, rp);
3039 _edje_entry_select_begin(Edje_Real_Part *rp)
3043 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3044 (!rp->typedata.text)) return;
3045 en = rp->typedata.text->entry_data;
3048 _sel_clear(en->ed, en->cursor, rp->object, en);
3049 _sel_enable(en->ed, en->cursor, rp->object, en);
3050 _sel_start(en->cursor, rp->object, en);
3051 _sel_extend(en->ed, en->cursor, rp->object, en);
3053 _edje_entry_real_part_configure(en->ed, rp);
3057 _edje_entry_select_extend(Edje_Real_Part *rp)
3061 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3062 (!rp->typedata.text)) return;
3063 en = rp->typedata.text->entry_data;
3065 _sel_extend(en->ed, en->cursor, rp->object, en);
3067 _edje_entry_real_part_configure(en->ed, rp);
3071 _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
3077 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3078 (!rp->typedata.text)) return NULL;
3079 en = rp->typedata.text->entry_data;
3080 if (!en) return NULL;
3081 EINA_LIST_FOREACH(en->anchors, l, an)
3083 const char *n = an->name;
3084 if ((an->item) || (!n)) continue;
3085 if (!strcmp(anchor, n))
3092 _edje_entry_anchors_list(Edje_Real_Part *rp)
3095 Eina_List *l, *anchors = NULL;
3098 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3099 (!rp->typedata.text)) return NULL;
3100 en = rp->typedata.text->entry_data;
3101 if (!en) return NULL;
3102 if (!en->anchorlist)
3104 EINA_LIST_FOREACH(en->anchors, l, an)
3106 const char *n = an->name;
3107 if ((an->item) || (!n)) continue;
3108 anchors = eina_list_append(anchors, strdup(n));
3110 en->anchorlist = anchors;
3112 return en->anchorlist;
3116 _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
3122 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3123 (!rp->typedata.text)) return EINA_FALSE;
3124 en = rp->typedata.text->entry_data;
3125 if (!en) return EINA_FALSE;
3126 EINA_LIST_FOREACH(en->anchors, l, an)
3128 const char *n = an->name;
3129 if (!an->item) continue;
3131 if (!strcmp(item, n))
3133 evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
3141 _edje_entry_items_list(Edje_Real_Part *rp)
3144 Eina_List *l, *items = NULL;
3147 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3148 (!rp->typedata.text)) return NULL;
3149 en = rp->typedata.text->entry_data;
3150 if (!en) return NULL;
3153 EINA_LIST_FOREACH(en->anchors, l, an)
3155 const char *n = an->name;
3156 if (!an->item) continue;
3158 items = eina_list_append(items, strdup(n));
3160 en->itemlist = items;
3162 return en->itemlist;
3166 _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, Evas_BiDi_Direction *cdir)
3168 Evas_Coord x, y, w, h, xx, yy, ww, hh;
3170 Evas_Textblock_Cursor_Type cur_type;
3171 Evas_BiDi_Direction dir;
3173 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3174 (!rp->typedata.text)) return;
3175 en = rp->typedata.text->entry_data;
3177 switch (rp->part->cursor_mode)
3179 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3180 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3182 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3183 /* no break for a reason */
3185 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3189 xx = yy = ww = hh = -1;
3190 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
3191 evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, &dir, cur_type);
3193 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
3194 edje_object_size_min_restricted_calc(en->cursor_fg, &ww, NULL, ww, 0);
3196 if (cx) *cx = x + xx;
3197 if (cy) *cy = y + yy;
3200 if (cdir) *cdir = dir;
3204 _edje_entry_user_insert(Edje_Real_Part *rp, const char *text)
3207 Edje_Entry_Change_Info *info;
3209 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3210 (!rp->typedata.text)) return;
3211 en = rp->typedata.text->entry_data;
3213 _edje_entry_imf_context_reset(rp);
3214 info = _text_filter_markup_prepend(en->ed, en, en->cursor, text, NULL, NULL,
3215 EINA_TRUE, EINA_TRUE);
3216 _anchors_get(en->cursor, rp->object, en);
3219 _edje_emit(en->ed, "entry,changed", rp->part->name);
3220 _edje_emit_full(en->ed, "entry,changed,user", rp->part->name,
3221 info, _free_entry_change_info);
3222 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3225 _edje_entry_imf_cursor_info_set(en);
3226 _edje_entry_real_part_configure(en->ed, rp);
3230 _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
3234 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3235 (!rp->typedata.text)) return;
3236 en = rp->typedata.text->entry_data;
3239 en->select_allow = allow;
3243 _edje_entry_select_allow_get(const Edje_Real_Part *rp)
3247 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3248 (!rp->typedata.text)) return EINA_FALSE;
3249 en = rp->typedata.text->entry_data;
3250 if (!en) return EINA_FALSE;
3251 return en->select_allow;
3255 _edje_entry_select_abort(Edje_Real_Part *rp)
3259 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3260 (!rp->typedata.text)) return;
3261 en = rp->typedata.text->entry_data;
3265 en->selecting = EINA_FALSE;
3267 _edje_entry_imf_context_reset(rp);
3268 _edje_entry_imf_cursor_info_set(en);
3269 _edje_entry_real_part_configure(en->ed, rp);
3274 _edje_entry_imf_context_get(Edje_Real_Part *rp)
3276 #ifdef HAVE_ECORE_IMF
3279 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3280 (!rp->typedata.text)) return NULL;
3281 en = rp->typedata.text->entry_data;
3282 if (!en) return NULL;
3284 return en->imf_context;
3292 _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type)
3294 #ifdef HAVE_ECORE_IMF
3297 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3298 (!rp->typedata.text)) return;
3299 en = rp->typedata.text->entry_data;
3302 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
3303 autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
3305 if (en->imf_context)
3306 ecore_imf_context_autocapital_type_set(en->imf_context, (Ecore_IMF_Autocapital_Type)autocapital_type);
3309 (void)autocapital_type;
3313 Edje_Text_Autocapital_Type
3314 _edje_entry_autocapital_type_get(Edje_Real_Part *rp)
3316 #ifdef HAVE_ECORE_IMF
3319 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3320 (!rp->typedata.text)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
3321 en = rp->typedata.text->entry_data;
3322 if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
3324 if (en->imf_context)
3325 return (Edje_Text_Autocapital_Type)ecore_imf_context_autocapital_type_get(en->imf_context);
3326 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
3328 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
3334 _edje_entry_prediction_allow_set(Edje_Real_Part *rp, Eina_Bool prediction)
3338 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3339 (!rp->typedata.text)) return;
3340 en = rp->typedata.text->entry_data;
3342 en->prediction_allow = prediction;
3343 #ifdef HAVE_ECORE_IMF
3344 if (en->imf_context)
3345 ecore_imf_context_prediction_allow_set(en->imf_context, prediction);
3350 _edje_entry_prediction_allow_get(Edje_Real_Part *rp)
3354 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3355 (!rp->typedata.text)) return EINA_FALSE;
3356 en = rp->typedata.text->entry_data;
3357 if (!en) return EINA_FALSE;
3358 return en->prediction_allow;
3362 _edje_entry_input_hint_set(Edje_Real_Part *rp, Edje_Input_Hints input_hints)
3366 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3367 (!rp->typedata.text)) return;
3368 en = rp->typedata.text->entry_data;
3370 #ifdef HAVE_ECORE_IMF
3371 if (en->imf_context)
3372 ecore_imf_context_input_hint_set(en->imf_context, (Ecore_IMF_Input_Hints)input_hints);
3379 _edje_entry_input_hint_get(const Edje_Real_Part *rp)
3383 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3384 (!rp->typedata.text)) return EDJE_INPUT_HINT_NONE;
3385 en = rp->typedata.text->entry_data;
3386 if (!en) return EDJE_INPUT_HINT_NONE;
3387 #ifdef HAVE_ECORE_IMF
3388 if (en->imf_context)
3389 return (Edje_Input_Hints)ecore_imf_context_input_hint_get(en->imf_context);
3392 return EDJE_INPUT_HINT_NONE;
3396 _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled)
3400 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3401 (!rp->typedata.text)) return;
3402 en = rp->typedata.text->entry_data;
3404 en->input_panel_enable = enabled;
3405 #ifdef HAVE_ECORE_IMF
3406 if (en->imf_context)
3407 ecore_imf_context_input_panel_enabled_set(en->imf_context, enabled);
3412 _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp)
3416 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3417 (!rp->typedata.text)) return EINA_FALSE;
3418 en = rp->typedata.text->entry_data;
3419 if (!en) return EINA_FALSE;
3420 return en->input_panel_enable;
3424 _edje_entry_input_panel_show(Edje_Real_Part *rp)
3426 #ifdef HAVE_ECORE_IMF
3429 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3430 (!rp->typedata.text)) return;
3431 en = rp->typedata.text->entry_data;
3433 if (en->imf_context)
3434 ecore_imf_context_input_panel_show(en->imf_context);
3441 _edje_entry_input_panel_hide(Edje_Real_Part *rp)
3443 #ifdef HAVE_ECORE_IMF
3446 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3447 (!rp->typedata.text)) return;
3448 en = rp->typedata.text->entry_data;
3450 if (en->imf_context)
3451 ecore_imf_context_input_panel_hide(en->imf_context);
3458 _edje_entry_input_panel_language_set(Edje_Real_Part *rp, Edje_Input_Panel_Lang lang)
3462 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3463 (!rp->typedata.text)) return;
3464 en = rp->typedata.text->entry_data;
3466 en->input_panel_lang = lang;
3467 #ifdef HAVE_ECORE_IMF
3468 if (en->imf_context)
3469 ecore_imf_context_input_panel_language_set(en->imf_context, (Ecore_IMF_Input_Panel_Lang)lang);
3473 Edje_Input_Panel_Lang
3474 _edje_entry_input_panel_language_get(Edje_Real_Part *rp)
3478 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3479 (!rp->typedata.text)) return EDJE_INPUT_PANEL_LANG_AUTOMATIC;
3480 en = rp->typedata.text->entry_data;
3481 if (!en) return EDJE_INPUT_PANEL_LANG_AUTOMATIC;
3482 return en->input_panel_lang;
3486 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data, int len)
3488 #ifdef HAVE_ECORE_IMF
3491 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3492 (!rp->typedata.text)) return;
3493 en = rp->typedata.text->entry_data;
3495 if (en->imf_context)
3496 ecore_imf_context_input_panel_imdata_set(en->imf_context, data, len);
3505 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data, int *len)
3507 #ifdef HAVE_ECORE_IMF
3510 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3511 (!rp->typedata.text)) return;
3512 en = rp->typedata.text->entry_data;
3514 if (en->imf_context)
3515 ecore_imf_context_input_panel_imdata_get(en->imf_context, data, len);
3524 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type)
3526 #ifdef HAVE_ECORE_IMF
3529 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3530 (!rp->typedata.text)) return;
3531 en = rp->typedata.text->entry_data;
3533 if (en->imf_context)
3534 ecore_imf_context_input_panel_return_key_type_set(en->imf_context, (Ecore_IMF_Input_Panel_Return_Key_Type)return_key_type);
3537 (void)return_key_type;
3541 Edje_Input_Panel_Return_Key_Type
3542 _edje_entry_input_panel_return_key_type_get(Edje_Real_Part *rp)
3544 #ifdef HAVE_ECORE_IMF
3547 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3548 (!rp->typedata.text)) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
3549 en = rp->typedata.text->entry_data;
3550 if (!en) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
3551 if (en->imf_context)
3552 return (Edje_Input_Panel_Return_Key_Type)ecore_imf_context_input_panel_return_key_type_get(en->imf_context);
3553 return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
3555 return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
3561 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
3563 #ifdef HAVE_ECORE_IMF
3566 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3567 (!rp->typedata.text)) return;
3568 en = rp->typedata.text->entry_data;
3570 if (en->imf_context)
3571 ecore_imf_context_input_panel_return_key_disabled_set(en->imf_context, disabled);
3579 _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp)
3581 #ifdef HAVE_ECORE_IMF
3584 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3585 (!rp->typedata.text)) return EINA_FALSE;
3586 en = rp->typedata.text->entry_data;
3587 if (!en) return EINA_FALSE;
3588 if (en->imf_context)
3589 return ecore_imf_context_input_panel_return_key_disabled_get(en->imf_context);
3597 #ifdef HAVE_ECORE_IMF
3599 _edje_entry_input_panel_show_on_demand_set(Edje_Real_Part *rp, Eina_Bool ondemand)
3602 _edje_entry_input_panel_show_on_demand_set(Edje_Real_Part *rp, Eina_Bool ondemand EINA_UNUSED)
3607 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3608 (!rp->typedata.text)) return;
3609 en = rp->typedata.text->entry_data;
3611 #ifdef HAVE_ECORE_IMF
3612 if (en->imf_context)
3613 ecore_imf_context_input_panel_show_on_demand_set(en->imf_context, ondemand);
3618 _edje_entry_input_panel_show_on_demand_get(Edje_Real_Part *rp)
3622 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3623 (!rp->typedata.text)) return EINA_FALSE;
3624 en = rp->typedata.text->entry_data;
3625 if (!en) return EINA_FALSE;
3626 #ifdef HAVE_ECORE_IMF
3627 if (en->imf_context) {
3628 Eina_Bool ret = ecore_imf_context_input_panel_show_on_demand_get(en->imf_context);
3635 static Evas_Textblock_Cursor *
3636 _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
3640 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3641 (!rp->typedata.text)) return NULL;
3642 en = rp->typedata.text->entry_data;
3643 if (!en) return NULL;
3646 case EDJE_CURSOR_MAIN:
3648 case EDJE_CURSOR_SELECTION_BEGIN:
3649 return en->sel_start;
3650 case EDJE_CURSOR_SELECTION_END:
3652 case EDJE_CURSOR_PREEDIT_START:
3653 if (!en->preedit_start)
3654 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
3655 return en->preedit_start;
3656 case EDJE_CURSOR_PREEDIT_END:
3657 if (!en->preedit_end)
3658 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
3659 return en->preedit_end;
3660 case EDJE_CURSOR_USER:
3661 if (!en->cursor_user)
3662 en->cursor_user = evas_object_textblock_cursor_new(rp->object);
3663 return en->cursor_user;
3664 case EDJE_CURSOR_USER_EXTRA:
3665 if (!en->cursor_user_extra)
3666 en->cursor_user_extra = evas_object_textblock_cursor_new(rp->object);
3667 return en->cursor_user_extra;
3675 _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
3678 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3680 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3681 (!rp->typedata.text)) return EINA_FALSE;
3682 en = rp->typedata.text->entry_data;
3683 if (!en) return EINA_FALSE;
3685 if (!c) return EINA_FALSE;
3687 _edje_entry_imf_context_reset(rp);
3689 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
3690 //if (!evas_textblock_cursor_char_next(c))
3691 if (!evas_textblock_cursor_cluster_next(c))
3695 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3696 _edje_entry_imf_cursor_info_set(en);
3698 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3699 _edje_entry_real_part_configure(en->ed, rp);
3704 _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
3707 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3709 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3710 (!rp->typedata.text)) return EINA_FALSE;
3711 en = rp->typedata.text->entry_data;
3712 if (!en) return EINA_FALSE;
3713 if (!c) return EINA_FALSE;
3715 _edje_entry_imf_context_reset(rp);
3717 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
3718 //if (!evas_textblock_cursor_char_prev(c))
3719 if (!evas_textblock_cursor_cluster_prev(c))
3721 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
3722 else return EINA_FALSE;
3725 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3727 _edje_entry_imf_cursor_info_set(en);
3729 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3730 _edje_entry_real_part_configure(en->ed, rp);
3735 _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
3738 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3739 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
3742 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3743 (!rp->typedata.text)) return EINA_FALSE;
3744 en = rp->typedata.text->entry_data;
3745 if (!en) return EINA_FALSE;
3746 if (!c) return EINA_FALSE;
3748 _edje_entry_imf_context_reset(rp);
3750 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
3752 if (ln < 0) return EINA_FALSE;
3753 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
3754 &lx, &ly, &lw, &lh))
3756 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
3757 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
3758 //if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
3759 if (!evas_textblock_cursor_cluster_coord_set(c, cx, ly + (lh / 2)))
3761 if (cx < (lx + (lw / 2)))
3762 evas_textblock_cursor_line_char_last(c);
3764 evas_textblock_cursor_line_char_last(c);
3766 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3768 _edje_entry_imf_cursor_info_set(en);
3770 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3771 _edje_entry_real_part_configure(en->ed, rp);
3776 _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
3779 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3780 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
3783 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3784 (!rp->typedata.text)) return EINA_FALSE;
3785 en = rp->typedata.text->entry_data;
3786 if (!en) return EINA_FALSE;
3787 if (!c) return EINA_FALSE;
3789 _edje_entry_imf_context_reset(rp);
3791 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
3793 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
3794 &lx, &ly, &lw, &lh))
3796 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
3797 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
3798 //if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
3799 if (!evas_textblock_cursor_cluster_coord_set(c, cx, ly + (lh / 2)))
3801 if (cx < (lx + (lw / 2)))
3802 evas_textblock_cursor_line_char_last(c);
3804 evas_textblock_cursor_line_char_last(c);
3806 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3808 _edje_entry_imf_cursor_info_set(en);
3809 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3810 _edje_entry_real_part_configure(en->ed, rp);
3815 _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
3818 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3820 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3821 (!rp->typedata.text)) return;
3822 en = rp->typedata.text->entry_data;
3826 _edje_entry_imf_context_reset(rp);
3828 evas_textblock_cursor_paragraph_first(c);
3829 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3831 _edje_entry_imf_cursor_info_set(en);
3832 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3833 _edje_entry_real_part_configure(en->ed, rp);
3837 _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
3840 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3842 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3843 (!rp->typedata.text)) return;
3844 en = rp->typedata.text->entry_data;
3848 _edje_entry_imf_context_reset(rp);
3850 _curs_end(c, rp->object, rp->typedata.text->entry_data);
3851 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3853 _edje_entry_imf_cursor_info_set(en);
3855 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3856 _edje_entry_real_part_configure(en->ed, rp);
3860 _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
3863 Evas_Textblock_Cursor *c;
3864 Evas_Textblock_Cursor *d;
3866 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3867 (!rp->typedata.text)) return;
3868 en = rp->typedata.text->entry_data;
3870 c = _cursor_get(rp, cur);
3872 d = _cursor_get(rp, dst);
3874 evas_textblock_cursor_copy(c, d);
3875 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3877 _edje_entry_imf_context_reset(rp);
3878 _edje_entry_imf_cursor_info_set(en);
3879 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3880 _edje_entry_real_part_configure(en->ed, rp);
3884 _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
3887 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3889 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3890 (!rp->typedata.text)) return;
3891 en = rp->typedata.text->entry_data;
3894 _edje_entry_imf_context_reset(rp);
3896 evas_textblock_cursor_line_char_first(c);
3897 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3899 _edje_entry_imf_cursor_info_set(en);
3901 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3902 _edje_entry_real_part_configure(en->ed, rp);
3906 _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
3909 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3911 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3912 (!rp->typedata.text)) return;
3913 en = rp->typedata.text->entry_data;
3916 _edje_entry_imf_context_reset(rp);
3917 evas_textblock_cursor_line_char_last(c);
3918 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3920 _edje_entry_imf_cursor_info_set(en);
3921 _edje_emit(en->ed, "cursor,changed", rp->part->name);
3922 _edje_entry_real_part_configure(en->ed, rp);
3926 _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
3927 Evas_Coord x, Evas_Coord y)
3929 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3930 if (!c) return EINA_FALSE;
3931 Entry *en = rp->typedata.text->entry_data;
3932 if ((cur == EDJE_CURSOR_SELECTION_BEGIN) ||
3933 (cur == EDJE_CURSOR_SELECTION_END))
3935 if (en->have_selection)
3937 // TIZEN ONLY(20150727): Clear selection (doing with sel handler)
3940 free(en->selection);
3941 en->selection = NULL;
3944 _edje_emit(en->ed, "selection,changed", rp->part->name);
3947 // TIZEN_ONLY(20150127): Add evas_textblock_cursor_cluster_* APIs.
3948 //return evas_textblock_cursor_char_coord_set(c, x, y);
3949 return evas_textblock_cursor_cluster_coord_set(c, x, y);
3954 _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
3956 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3957 if (!c) return EINA_FALSE;
3958 if (evas_textblock_cursor_is_format(c)) return EINA_TRUE;
3963 _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
3965 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3966 if (!c) return EINA_FALSE;
3967 return evas_textblock_cursor_format_is_visible_get(c);
3971 _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
3973 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3975 if (!c) return NULL;
3977 return evas_textblock_cursor_content_get(c);
3981 _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
3984 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
3986 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3987 (!rp->typedata.text)) return;
3988 en = rp->typedata.text->entry_data;
3991 /* Abort if cursor position didn't really change */
3992 if (evas_textblock_cursor_pos_get(c) == pos)
3995 _edje_entry_imf_context_reset(rp);
3996 evas_textblock_cursor_pos_set(c, pos);
3997 _sel_update(en->ed, c, rp->object, rp->typedata.text->entry_data);
3999 // TIZEN_ONLY(20150716): Add edje_object_part_text_freeze, thaw APIs for freezing cursor movements.
4000 //_edje_entry_imf_cursor_info_set(en);
4001 //_edje_emit(en->ed, "cursor,changed", rp->part->name);
4002 //_edje_entry_real_part_configure(en->ed, rp);
4003 _edje_emit(en->ed, "cursor,changed", rp->part->name);
4006 if (!en->have_selection)
4008 _edje_entry_imf_cursor_info_set(en);
4010 _edje_entry_real_part_configure(en->ed, rp);
4016 _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur)
4018 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4020 return evas_textblock_cursor_pos_get(c);
4024 _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout)
4026 #ifdef HAVE_ECORE_IMF
4029 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4030 (!rp->typedata.text)) return;
4031 en = rp->typedata.text->entry_data;
4033 if (en->imf_context)
4034 ecore_imf_context_input_panel_layout_set(en->imf_context, (Ecore_IMF_Input_Panel_Layout)layout);
4041 Edje_Input_Panel_Layout
4042 _edje_entry_input_panel_layout_get(Edje_Real_Part *rp)
4044 #ifdef HAVE_ECORE_IMF
4047 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4048 (!rp->typedata.text)) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4049 en = rp->typedata.text->entry_data;
4050 if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4051 if (en->imf_context)
4052 return (Edje_Input_Panel_Layout)ecore_imf_context_input_panel_layout_get(en->imf_context);
4053 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4055 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4061 _edje_entry_input_panel_layout_variation_set(Edje_Real_Part *rp, int variation)
4065 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4066 (!rp->typedata.text)) return;
4067 en = rp->typedata.text->entry_data;
4069 #ifdef HAVE_ECORE_IMF
4070 if (en->imf_context)
4071 ecore_imf_context_input_panel_layout_variation_set(en->imf_context, variation);
4078 _edje_entry_input_panel_layout_variation_get(Edje_Real_Part *rp)
4082 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4083 (!rp->typedata.text)) return 0;
4084 en = rp->typedata.text->entry_data;
4086 #ifdef HAVE_ECORE_IMF
4087 if (en->imf_context)
4088 return ecore_imf_context_input_panel_layout_variation_get(en->imf_context);
4095 _edje_entry_imf_context_reset(Edje_Real_Part *rp)
4097 #ifdef HAVE_ECORE_IMF
4100 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4101 (!rp->typedata.text)) return;
4102 en = rp->typedata.text->entry_data;
4104 if (en->imf_context)
4105 ecore_imf_context_reset(en->imf_context);
4106 if (en->commit_cancel)
4107 en->commit_cancel = EINA_FALSE;
4114 _edje_entry_imf_cursor_location_set(Entry *en)
4116 #ifdef HAVE_ECORE_IMF
4117 Evas_Coord cx, cy, cw, ch;
4118 Evas_BiDi_Direction dir;
4119 if (!en || !en->rp || !en->imf_context) return;
4121 _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch, &dir);
4122 ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch);
4123 ecore_imf_context_bidi_direction_set(en->imf_context, (Ecore_IMF_BiDi_Direction)dir);
4130 _edje_entry_imf_cursor_info_set(Entry *en)
4134 #ifdef HAVE_ECORE_IMF
4135 if (!en || !en->rp || !en->imf_context) return;
4137 if (en->have_selection)
4139 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
4140 cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
4142 cursor_pos = evas_textblock_cursor_pos_get(en->sel_end);
4145 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
4147 ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos);
4149 _edje_entry_imf_cursor_location_set(en);
4155 #ifdef HAVE_ECORE_IMF
4156 // TIZEN_ONLY (20150814): Pass correct cursor position and correct text to imf when selection is there
4157 // FIXME: Need to be pushed in upstream
4160 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos)
4163 Edje_Real_Part *rp = ed->focused_part;
4168 if (!rp) return EINA_FALSE;
4169 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4170 (!rp->typedata.text)) return EINA_FALSE;
4172 en = rp->typedata.text->entry_data;
4173 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4174 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4179 str = _edje_entry_text_get(rp);
4182 plain_text = evas_textblock_text_markup_to_utf8(NULL, str);
4186 *text = strdup(plain_text);
4201 *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
4210 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos)
4213 Edje_Real_Part *rp = ed->focused_part;
4217 Eina_Strbuf *buf = NULL;
4219 if (!rp) return EINA_FALSE;
4220 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4221 (!rp->typedata.text)) return EINA_FALSE;
4223 en = rp->typedata.text->entry_data;
4224 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4225 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4230 str = _edje_entry_text_get(rp);
4233 plain_text = evas_textblock_text_markup_to_utf8(NULL, str);
4237 if (en->have_selection)
4239 buf = eina_strbuf_new();
4242 eina_strbuf_append_n(buf, plain_text, evas_textblock_cursor_pos_get(en->sel_start));
4244 eina_strbuf_append(buf, plain_text);
4246 *text = strdup(eina_strbuf_string_get(buf));
4247 eina_strbuf_free(buf);
4250 *text = strdup(plain_text);
4264 if (en->have_selection && en->sel_start)
4265 *cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
4266 else if (en->cursor)
4267 *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
4277 _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
4280 Edje_Real_Part *rp = ed->focused_part;
4282 char *commit_str = event_info;
4283 Edje_Entry_Change_Info *info = NULL;
4286 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4287 (!rp->typedata.text)) return;
4289 en = rp->typedata.text->entry_data;
4290 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4291 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4294 if (en->have_selection)
4296 if (strcmp(commit_str, ""))
4298 /* delete selected characters */
4299 _range_del_emit(ed, en->cursor, rp->object, en);
4300 _sel_clear(ed, en->cursor, rp->object, en);
4304 /* delete preedit characters */
4308 // Skipping commit process when it is useless
4309 if (en->commit_cancel)
4311 en->commit_cancel = EINA_FALSE;
4315 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
4316 _edje_password_show_last)
4317 _edje_entry_hide_visible_password(ed, en->rp);
4318 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
4319 _edje_password_show_last && (!en->preedit_start))
4321 info = _text_filter_text_prepend(ed, en, en->cursor, commit_str,
4322 "+ password=off", "- password",
4323 EINA_TRUE, EINA_TRUE);
4328 ecore_timer_del(en->pw_timer);
4329 en->pw_timer = NULL;
4331 if (_edje_password_show_last_timeout >= 0)
4332 en->pw_timer = ecore_timer_add
4333 (_edje_password_show_last_timeout,
4334 _password_timer_cb, en);
4339 info = _text_filter_text_prepend(ed, en, en->cursor, commit_str,
4341 EINA_TRUE, EINA_TRUE);
4345 _edje_entry_imf_cursor_info_set(en);
4346 _anchors_get(en->cursor, rp->object, en);
4349 _edje_emit(ed, "entry,changed", rp->part->name);
4350 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
4351 info, _free_entry_change_info);
4352 _edje_emit(ed, "cursor,changed", rp->part->name);
4354 _edje_entry_imf_cursor_info_set(en);
4355 _edje_entry_real_part_configure(ed, rp);
4359 _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info EINA_UNUSED)
4362 Edje_Real_Part *rp = ed->focused_part;
4365 int preedit_start_pos, preedit_end_pos;
4366 char *preedit_string;
4367 char *markup_txt = NULL;
4368 char *tagname[] = {NULL, "preedit", "preedit_sel", "preedit_highlight",
4369 "preedit_sub1", "preedit_sub2", "preedit_sub3", "preedit_sub4"};
4371 size_t preedit_type_size = sizeof(tagname) / sizeof(tagname[0]);
4372 Eina_Bool preedit_end_state = EINA_FALSE;
4373 Eina_List *attrs = NULL, *l = NULL;
4374 Ecore_IMF_Preedit_Attr *attr;
4376 Eina_Strbuf *preedit_attr_str;
4380 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4381 (!rp->typedata.text)) return;
4383 en = rp->typedata.text->entry_data;
4384 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4385 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4388 if (!en->imf_context) return;
4390 ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
4392 &attrs, &cursor_pos);
4393 if (!preedit_string) return;
4395 if (!strcmp(preedit_string, ""))
4396 preedit_end_state = EINA_TRUE;
4398 if (en->have_selection && !preedit_end_state)
4399 _range_del_emit(ed, en->cursor, rp->object, en);
4401 /* delete preedit characters */
4404 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
4406 /* insert preedit character(s) */
4407 if (strlen(preedit_string) > 0)
4409 buf = eina_strbuf_new();
4412 EINA_LIST_FOREACH(attrs, l, attr)
4414 if (attr->preedit_type < preedit_type_size &&
4415 tagname[attr->preedit_type])
4417 preedit_attr_str = eina_strbuf_new();
4418 if (preedit_attr_str)
4420 eina_strbuf_append_n(preedit_attr_str, preedit_string + attr->start_index, attr->end_index - attr->start_index);
4421 markup_txt = evas_textblock_text_utf8_to_markup(NULL, eina_strbuf_string_get(preedit_attr_str));
4425 eina_strbuf_append_printf(buf, "<%s>%s</%s>", tagname[attr->preedit_type], markup_txt, tagname[attr->preedit_type]);
4428 eina_strbuf_free(preedit_attr_str);
4432 eina_strbuf_append(buf, preedit_string);
4437 eina_strbuf_append(buf, preedit_string);
4440 // For skipping useless commit
4441 if (!preedit_end_state)
4442 en->have_preedit = EINA_TRUE;
4444 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
4445 _edje_password_show_last)
4447 Edje_Entry_Change_Info *info;
4449 _edje_entry_hide_visible_password(ed, en->rp);
4450 // TIZEN_ONLY(20150629): In case of unicode language preedit status is needed to be maintained
4451 // so markup text comes from imf
4452 info = _text_filter_markup_prepend(ed, en, en->cursor,
4453 eina_strbuf_string_get(buf),
4456 EINA_TRUE, EINA_TRUE);
4457 //info = _text_filter_text_prepend(ed, en, en->cursor,
4458 // eina_strbuf_string_get(buf),
4459 // "+ password=off",
4461 // EINA_TRUE, EINA_TRUE);
4468 ecore_timer_del(en->pw_timer);
4469 en->pw_timer = NULL;
4471 if (_edje_password_show_last_timeout >= 0)
4472 en->pw_timer = ecore_timer_add
4473 (_edje_password_show_last_timeout,
4474 _password_timer_cb, en);
4479 _text_filter_markup_prepend(ed, en, en->cursor,
4480 eina_strbuf_string_get(buf),
4482 EINA_TRUE, EINA_FALSE);
4483 eina_strbuf_free(buf);
4486 if (!preedit_end_state)
4488 /* set preedit start cursor */
4489 if (!en->preedit_start)
4490 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
4491 evas_textblock_cursor_copy(en->cursor, en->preedit_start);
4493 /* set preedit end cursor */
4494 if (!en->preedit_end)
4495 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
4496 evas_textblock_cursor_copy(en->cursor, en->preedit_end);
4498 preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor);
4500 for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++)
4502 evas_textblock_cursor_char_prev(en->preedit_start);
4505 en->have_preedit = EINA_TRUE;
4507 /* set cursor position */
4508 evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos);
4511 _edje_entry_imf_cursor_info_set(en);
4512 _anchors_get(en->cursor, rp->object, en);
4513 _edje_emit(ed, "preedit,changed", rp->part->name);
4514 _edje_emit(ed, "cursor,changed", rp->part->name);
4516 /* delete attribute list */
4519 EINA_LIST_FREE(attrs, attr) free(attr);
4522 free(preedit_string);
4526 _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
4529 Edje_Real_Part *rp = ed->focused_part;
4531 Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
4532 Evas_Textblock_Cursor *del_start, *del_end;
4533 Edje_Entry_Change_Info *info;
4537 if ((!rp) || (!ev)) return;
4538 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4539 (!rp->typedata.text)) return;
4541 en = rp->typedata.text->entry_data;
4542 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4543 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4546 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
4548 del_start = evas_object_textblock_cursor_new(en->rp->object);
4549 evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
4551 del_end = evas_object_textblock_cursor_new(en->rp->object);
4552 evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars);
4554 start = evas_textblock_cursor_pos_get(del_start);
4555 end = evas_textblock_cursor_pos_get(del_end);
4556 if (start == end) goto end;
4558 evas_textblock_cursor_range_delete(del_start, del_end);
4559 _anchors_get(en->cursor, rp->object, en);
4560 _anchors_update(en->cursor, rp->object, en);
4562 info = calloc(1, sizeof(*info));
4563 info->insert = EINA_FALSE;
4564 info->change.del.start = start;
4565 info->change.del.end = end;
4566 _edje_emit(ed, "entry,changed", en->rp->part->name);
4567 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
4568 _free_entry_change_info);
4569 _edje_emit(ed, "cursor,changed", en->rp->part->name);
4570 _edje_emit(ed, "cursor,changed,manual", en->rp->part->name);
4572 _edje_entry_imf_cursor_info_set(en);
4573 _edje_entry_real_part_configure(ed, rp);
4576 evas_textblock_cursor_free(del_start);
4577 evas_textblock_cursor_free(del_end);
4581 _edje_entry_imf_event_selection_set_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
4584 Edje_Real_Part *rp = ed->focused_part;
4586 Ecore_IMF_Event_Selection *ev = event_info;
4588 if ((!rp) || (!ev)) return;
4589 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4590 (!rp->typedata.text)) return;
4592 en = rp->typedata.text->entry_data;
4593 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4594 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4597 if (ev->start == ev->end)
4599 _edje_entry_cursor_pos_set(rp, EDJE_CURSOR_MAIN, ev->start);
4603 _sel_clear(ed, en->cursor, rp->object, en);
4604 evas_textblock_cursor_pos_set(en->cursor, ev->start);
4605 _sel_enable(ed, en->cursor, rp->object, en);
4606 _sel_start(en->cursor, rp->object, en);
4607 evas_textblock_cursor_pos_set(en->cursor, ev->end);
4608 _sel_extend(ed, en->cursor, rp->object, en);
4611 _edje_entry_real_part_configure(en->ed, rp);
4615 _edje_entry_imf_retrieve_selection_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text)
4618 Edje_Real_Part *rp = ed->focused_part;
4621 if (!rp) return EINA_FALSE;
4622 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4623 (!rp->typedata.text)) return EINA_FALSE;
4625 en = rp->typedata.text->entry_data;
4626 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4627 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4630 if (en->have_selection)
4633 *text = strdup(_edje_entry_selection_get(rp));
4641 // TIZEN_ONLY(20150716): Add edje_object_part_text_freeze, thaw APIs for freezing cursor movements.
4642 void _edje_entry_freeze(Edje_Real_Part *rp)
4646 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4647 (!rp->typedata.text)) return;
4649 en = rp->typedata.text->entry_data;
4652 en->freeze = EINA_TRUE;
4655 void _edje_entry_thaw(Edje_Real_Part *rp)
4659 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4660 (!rp->typedata.text)) return;
4662 en = rp->typedata.text->entry_data;
4665 en->freeze = EINA_FALSE;
4667 _edje_entry_imf_cursor_info_set(en);
4668 _edje_entry_real_part_configure(en->ed, rp);
4670 ////////////////////////////////////////////////////////////////////////////////////////////////
4672 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/