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 Eina_Bool _edje_entry_imf_event_commit_cb(void *data, int type, void *event);
6 static Eina_Bool _edje_entry_imf_event_preedit_changed_cb(void *data, int type, void *event);
7 static Eina_Bool _edje_entry_imf_event_delete_surrounding_cb(void *data, int type, void *event);
10 typedef struct _Entry Entry;
11 typedef struct _Sel Sel;
12 typedef struct _Anchor Anchor;
14 static void _edje_entry_imf_cursor_info_set(Entry *en);
15 static void _edje_entry_imf_context_reset(Entry *en);
20 Evas_Object *cursor_bg;
21 Evas_Object *cursor_fg;
22 Evas_Textblock_Cursor *cursor;
23 Evas_Textblock_Cursor *sel_start, *sel_end;
24 Evas_Textblock_Cursor *cursor_user, *cursor_user_extra;
25 Evas_Textblock_Cursor *preedit_start, *preedit_end;
26 Ecore_Timer *pw_timer;
29 Eina_List *anchorlist;
32 Eina_Bool selecting : 1;
33 Eina_Bool have_selection : 1;
34 Eina_Bool select_allow : 1;
35 Eina_Bool select_mod_start : 1;
36 Eina_Bool select_mod_end : 1;
37 Eina_Bool had_sel : 1;
40 Eina_Bool have_preedit : 1;
41 Ecore_IMF_Context *imf_context;
43 Ecore_Event_Handler *imf_ee_handler_commit;
44 Ecore_Event_Handler *imf_ee_handler_delete;
45 Ecore_Event_Handler *imf_ee_handler_changed;
51 Evas_Textblock_Rectangle rect;
52 Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
59 Evas_Textblock_Cursor *start, *end;
66 _preedit_clear(Entry *en)
68 if (en->preedit_start)
70 evas_textblock_cursor_free(en->preedit_start);
71 en->preedit_start = NULL;
76 evas_textblock_cursor_free(en->preedit_end);
77 en->preedit_end = NULL;
80 en->have_preedit = EINA_FALSE;
84 _preedit_del(Entry *en)
86 if (!en || !en->have_preedit) return;
87 if (!en->preedit_start || !en->preedit_end) return;
88 if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return;
90 /* delete the preedit characters */
91 evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end);
95 _edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
101 if (!rp || !rp->entry_data || !rp->edje || !rp->edje->obj) return;
104 if (!en || !en->imf_context) return;
106 if (evas_object_focus_get(rp->edje->obj))
108 ecore_imf_context_reset(en->imf_context);
109 ecore_imf_context_focus_in(en->imf_context);
110 _edje_entry_imf_cursor_info_set(en);
115 _edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
121 if (!rp || !rp->entry_data) return;
124 if (!en || !en->imf_context) return;
126 ecore_imf_context_reset(en->imf_context);
127 _edje_entry_imf_cursor_info_set(en);
128 ecore_imf_context_focus_out(en->imf_context);
133 _edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
136 #ifdef HAVE_ECORE_IMF
141 _edje_emit(ed, "focus,in", "");
142 #ifdef HAVE_ECORE_IMF
143 rp = ed->focused_part;
147 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
148 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
151 if (!en->imf_context) return;
153 ecore_imf_context_reset(en->imf_context);
154 ecore_imf_context_focus_in(en->imf_context);
155 _edje_entry_imf_cursor_info_set(en);
160 _edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
163 #ifdef HAVE_ECORE_IMF
164 Edje_Real_Part *rp = ed->focused_part;
168 _edje_emit(ed, "focus,out", "");
170 #ifdef HAVE_ECORE_IMF
173 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
174 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
177 if (!en->imf_context) return;
179 ecore_imf_context_reset(en->imf_context);
180 _edje_entry_imf_cursor_info_set(en);
181 ecore_imf_context_focus_out(en->imf_context);
186 _text_filter_text_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
189 Edje_Text_Insert_Filter_Callback *cb;
192 text2 = strdup(text);
193 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
195 if (!strcmp(cb->part, en->rp->part->name))
197 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2);
203 evas_textblock_cursor_text_prepend(c, text2);
209 _text_filter_format_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
212 Edje_Text_Insert_Filter_Callback *cb;
215 text2 = strdup(text);
216 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
218 if (!strcmp(cb->part, en->rp->part->name))
220 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2);
226 evas_textblock_cursor_format_prepend(c, text2);
232 _text_filter_markup_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
235 Edje_Text_Insert_Filter_Callback *cb;
238 text2 = strdup(text);
239 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
241 if (!strcmp(cb->part, en->rp->part->name))
243 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2);
249 evas_object_textblock_text_markup_prepend(c, text2);
255 _curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en, Evas_Coord *cx, Evas_Coord *cy)
258 Evas_Textblock_Cursor_Type cur_type;
259 if (c != en->cursor) return;
260 switch (en->rp->part->cursor_mode)
262 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
263 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
265 case EDJE_ENTRY_CURSOR_MODE_UNDER:
266 /* no break for a resaon */
268 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
270 evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type);
276 _curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
278 Evas_Textblock_Cursor *cc;
281 cc = evas_object_textblock_cursor_new(o);
282 evas_textblock_cursor_paragraph_last(cc);
283 ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL);
284 evas_textblock_cursor_free(cc);
289 _curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
290 Entry *en __UNUSED__)
292 evas_textblock_cursor_line_char_first(c);
296 _curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
297 Entry *en __UNUSED__)
299 evas_textblock_cursor_line_char_last(c);
303 _curs_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
304 Entry *en __UNUSED__)
306 evas_textblock_cursor_paragraph_first(c);
310 _curs_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__)
312 evas_textblock_cursor_paragraph_last(c);
316 _curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
319 Evas_Coord lx, ly, lw, lh;
320 int last = _curs_line_last_get(c, o, en);
325 if (ln > last) ln = last;
328 _curs_update_from_curs(c, o, en, &cx, &cy);
330 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
332 if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
334 evas_textblock_cursor_line_set(c, ln);
335 if (cx < (lx + (lw / 2)))
337 if (ln == last) _curs_end(c, o, en);
338 _curs_lin_start(c, o, en);
345 _curs_lin_end(c, o, en);
350 _curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
354 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
355 _curs_jump_line(c, o, en, ln);
359 _curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
361 _curs_jump_line_by(c, o, en, -1);
365 _curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
367 _curs_jump_line_by(c, o, en, 1);
371 _sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
373 if (en->sel_start) return;
374 en->sel_start = evas_object_textblock_cursor_new(o);
375 evas_textblock_cursor_copy(c, en->sel_start);
376 en->sel_end = evas_object_textblock_cursor_new(o);
377 evas_textblock_cursor_copy(c, en->sel_end);
379 en->have_selection = EINA_FALSE;
383 en->selection = NULL;
388 _sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
390 if (en->have_selection) return;
391 en->have_selection = EINA_TRUE;
395 en->selection = NULL;
397 _edje_emit(en->rp->edje, "selection,start", en->rp->part->name);
401 _sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
403 if (!en->sel_end) return;
404 _sel_enable(c, o, en);
405 if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
406 evas_textblock_cursor_copy(c, en->sel_end);
410 en->selection = NULL;
412 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
413 _edje_entry_imf_context_reset(en);
417 _sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
419 if (!en->sel_end) return;
420 _sel_enable(c, o, en);
421 if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
422 evas_textblock_cursor_copy(c, en->sel_start);
426 en->selection = NULL;
428 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
429 _edje_entry_imf_context_reset(en);
433 _sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
435 en->had_sel = EINA_FALSE;
438 evas_textblock_cursor_free(en->sel_start);
439 evas_textblock_cursor_free(en->sel_end);
440 en->sel_start = NULL;
446 en->selection = NULL;
453 if (sel->obj_bg) evas_object_del(sel->obj_bg);
454 if (sel->obj_fg) evas_object_del(sel->obj_fg);
456 en->sel = eina_list_remove_list(en->sel, en->sel);
458 if (en->have_selection)
460 en->have_selection = EINA_FALSE;
461 _edje_emit(en->rp->edje, "selection,cleared", en->rp->part->name);
466 _sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
468 Eina_List *range = NULL, *l;
470 Evas_Coord x, y, w, h;
471 Evas_Object *smart, *clip;
473 smart = evas_object_smart_parent_get(o);
474 clip = evas_object_clip_get(o);
476 range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end);
479 if (eina_list_count(range) != eina_list_count(en->sel))
484 if (sel->obj_bg) evas_object_del(sel->obj_bg);
485 if (sel->obj_fg) evas_object_del(sel->obj_fg);
487 en->sel = eina_list_remove_list(en->sel, en->sel);
489 if (en->have_selection)
491 for (l = range; l; l = eina_list_next(l))
495 sel = calloc(1, sizeof(Sel));
496 en->sel = eina_list_append(en->sel, sel);
497 ob = edje_object_add(en->rp->edje->base.evas);
498 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source);
499 evas_object_smart_member_add(ob, smart);
500 evas_object_stack_below(ob, o);
501 evas_object_clip_set(ob, clip);
502 evas_object_pass_events_set(ob, EINA_TRUE);
503 evas_object_show(ob);
505 _edje_subobj_register(en->rp->edje, sel->obj_bg);
507 ob = edje_object_add(en->rp->edje->base.evas);
508 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source2);
509 evas_object_smart_member_add(ob, smart);
510 evas_object_stack_above(ob, o);
511 evas_object_clip_set(ob, clip);
512 evas_object_pass_events_set(ob, EINA_TRUE);
513 evas_object_show(ob);
515 _edje_subobj_register(en->rp->edje, sel->obj_fg);
520 evas_object_geometry_get(o, &x, &y, &w, &h);
521 if (en->have_selection)
523 EINA_LIST_FOREACH(en->sel, l, sel)
525 Evas_Textblock_Rectangle *r;
530 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
531 evas_object_resize(sel->obj_bg, r->w, r->h);
535 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
536 evas_object_resize(sel->obj_fg, r->w, r->h);
538 *(&(sel->rect)) = *r;
539 range = eina_list_remove_list(range, range);
548 range = eina_list_remove_list(range, range);
554 _edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
557 Evas_Event_Mouse_Down *ev = event_info;
558 Edje_Real_Part *rp = an->en->rp;
565 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
568 ignored = rp->part->ignore_flags & ev->event_flags;
569 if ((!ev->event_flags) || (!ignored))
573 len = 200 + strlen(n);
575 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
576 snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, n);
577 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
578 snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, n);
580 snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
581 _edje_emit(rp->edje, buf, rp->part->name);
586 _edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
589 Evas_Event_Mouse_Up *ev = event_info;
590 Edje_Real_Part *rp = an->en->rp;
597 ignored = rp->part->ignore_flags & ev->event_flags;
598 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
603 len = 200 + strlen(n);
605 if ((!ev->event_flags) || (!ignored))
607 snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n);
608 _edje_emit(rp->edje, buf, rp->part->name);
610 if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
612 snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
613 _edje_emit(rp->edje, buf, rp->part->name);
618 _edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
621 Evas_Event_Mouse_Move *ev = event_info;
622 Edje_Real_Part *rp = an->en->rp;
629 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
632 ignored = rp->part->ignore_flags & ev->event_flags;
633 if ((!ev->event_flags) || (!ignored))
637 len = 200 + strlen(n);
639 snprintf(buf, len, "anchor,mouse,move,%s", n);
640 _edje_emit(rp->edje, buf, rp->part->name);
645 _edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
648 Evas_Event_Mouse_In *ev = event_info;
649 Edje_Real_Part *rp = an->en->rp;
654 ignored = rp->part->ignore_flags & ev->event_flags;
655 if ((!ev->event_flags) || (!ignored))
659 len = 200 + strlen(n);
661 snprintf(buf, len, "anchor,mouse,in,%s", n);
662 _edje_emit(rp->edje, buf, rp->part->name);
667 _edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
670 Evas_Event_Mouse_Out *ev = event_info;
671 Edje_Real_Part *rp = an->en->rp;
676 ignored = rp->part->ignore_flags & ev->event_flags;
677 if ((!ev->event_flags) || (!ignored))
681 len = 200 + strlen(n);
683 snprintf(buf, len, "anchor,mouse,out,%s", n);
684 _edje_emit(rp->edje, buf, rp->part->name);
689 _anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
691 Eina_List *l, *ll, *range = NULL;
692 Evas_Coord x, y, w, h;
693 Evas_Object *smart, *clip;
697 smart = evas_object_smart_parent_get(o);
698 clip = evas_object_clip_get(o);
700 evas_object_geometry_get(o, &x, &y, &w, &h);
701 EINA_LIST_FOREACH(en->anchors, l, an)
713 if (sel->obj_bg) evas_object_del(sel->obj_bg);
714 if (sel->obj_fg) evas_object_del(sel->obj_fg);
715 if (sel->obj) evas_object_del(sel->obj);
717 an->sel = eina_list_remove_list(an->sel, an->sel);
720 sel = calloc(1, sizeof(Sel));
721 an->sel = eina_list_append(an->sel, sel);
723 if (en->rp->edje->item_provider.func)
725 ob = en->rp->edje->item_provider.func
726 (en->rp->edje->item_provider.data, smart,
727 en->rp->part->name, an->name);
728 evas_object_smart_member_add(ob, smart);
729 evas_object_stack_above(ob, o);
730 evas_object_clip_set(ob, clip);
731 evas_object_pass_events_set(ob, EINA_TRUE);
732 evas_object_show(ob);
741 evas_textblock_cursor_range_geometry_get(an->start, an->end);
742 if (eina_list_count(range) != eina_list_count(an->sel))
747 if (sel->obj_bg) evas_object_del(sel->obj_bg);
748 if (sel->obj_fg) evas_object_del(sel->obj_fg);
749 if (sel->obj) evas_object_del(sel->obj);
751 an->sel = eina_list_remove_list(an->sel, an->sel);
753 for (ll = range; ll; ll = eina_list_next(ll))
757 sel = calloc(1, sizeof(Sel));
758 an->sel = eina_list_append(an->sel, sel);
759 ob = edje_object_add(en->rp->edje->base.evas);
760 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source5);
761 evas_object_smart_member_add(ob, smart);
762 evas_object_stack_below(ob, o);
763 evas_object_clip_set(ob, clip);
764 evas_object_pass_events_set(ob, EINA_TRUE);
765 evas_object_show(ob);
767 _edje_subobj_register(en->rp->edje, sel->obj_bg);
769 ob = edje_object_add(en->rp->edje->base.evas);
770 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source6);
771 evas_object_smart_member_add(ob, smart);
772 evas_object_stack_above(ob, o);
773 evas_object_clip_set(ob, clip);
774 evas_object_pass_events_set(ob, EINA_TRUE);
775 evas_object_show(ob);
777 _edje_subobj_register(en->rp->edje, sel->obj_fg);
779 ob = evas_object_rectangle_add(en->rp->edje->base.evas);
780 evas_object_color_set(ob, 0, 0, 0, 0);
781 evas_object_smart_member_add(ob, smart);
782 evas_object_stack_above(ob, o);
783 evas_object_clip_set(ob, clip);
784 evas_object_repeat_events_set(ob, EINA_TRUE);
785 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an);
786 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an);
787 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an);
788 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an);
789 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an);
790 evas_object_show(ob);
795 EINA_LIST_FOREACH(an->sel, ll, sel)
799 Evas_Coord cx, cy, cw, ch;
801 if (!evas_textblock_cursor_format_item_geometry_get
802 (an->start, &cx, &cy, &cw, &ch))
804 evas_object_move(sel->obj, x + cx, y + cy);
805 evas_object_resize(sel->obj, cw, ch);
809 Evas_Textblock_Rectangle *r;
812 *(&(sel->rect)) = *r;
815 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
816 evas_object_resize(sel->obj_bg, r->w, r->h);
820 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
821 evas_object_resize(sel->obj_fg, r->w, r->h);
825 evas_object_move(sel->obj, x + r->x, y + r->y);
826 evas_object_resize(sel->obj, r->w, r->h);
828 range = eina_list_remove_list(range, range);
836 _anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
838 while (en->anchorlist)
840 free(en->anchorlist->data);
841 en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
845 free(en->itemlist->data);
846 en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
850 Anchor *an = en->anchors->data;
852 evas_textblock_cursor_free(an->start);
853 evas_textblock_cursor_free(an->end);
856 Sel *sel = an->sel->data;
857 if (sel->obj_bg) evas_object_del(sel->obj_bg);
858 if (sel->obj_fg) evas_object_del(sel->obj_fg);
859 if (sel->obj) evas_object_del(sel->obj);
861 an->sel = eina_list_remove_list(an->sel, an->sel);
865 en->anchors = eina_list_remove_list(en->anchors, en->anchors);
870 _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
872 const Eina_List *anchors_a, *anchors_item;
874 _anchors_clear(c, o, en);
876 anchors_a = evas_textblock_node_format_list_get(o, "a");
877 anchors_item = evas_textblock_node_format_list_get(o, "item");
881 const Evas_Object_Textblock_Node_Format *node;
882 const Eina_List *itr;
883 EINA_LIST_FOREACH(anchors_a, itr, node)
885 const char *s = evas_textblock_node_format_text_get(node);
887 an = calloc(1, sizeof(Anchor));
892 p = strstr(s, "href=");
895 an->name = strdup(p + 5);
897 en->anchors = eina_list_append(en->anchors, an);
898 an->start = evas_object_textblock_cursor_new(o);
899 an->end = evas_object_textblock_cursor_new(o);
900 evas_textblock_cursor_at_format_set(an->start, node);
901 evas_textblock_cursor_copy(an->start, an->end);
903 /* Close the anchor, if the anchor was without text,
905 node = evas_textblock_node_format_next_get(node);
906 for (; node; node = evas_textblock_node_format_next_get(node))
908 s = evas_textblock_node_format_text_get(node);
909 if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
915 evas_textblock_cursor_at_format_set(an->end, node);
917 else if (!evas_textblock_cursor_compare(an->start, an->end))
919 if (an->name) free(an->name);
920 evas_textblock_cursor_free(an->start);
921 evas_textblock_cursor_free(an->end);
922 en->anchors = eina_list_remove(en->anchors, an);
931 const Evas_Object_Textblock_Node_Format *node;
932 const Eina_List *itr;
933 EINA_LIST_FOREACH(anchors_item, itr, node)
935 const char *s = evas_textblock_node_format_text_get(node);
937 an = calloc(1, sizeof(Anchor));
943 p = strstr(s, "href=");
946 an->name = strdup(p + 5);
948 en->anchors = eina_list_append(en->anchors, an);
949 an->start = evas_object_textblock_cursor_new(o);
950 an->end = evas_object_textblock_cursor_new(o);
951 evas_textblock_cursor_at_format_set(an->start, node);
952 evas_textblock_cursor_copy(an->start, an->end);
953 /* Although needed in textblock, don't bother with finding the end
954 * here cause it doesn't really matter. */
960 _free_entry_change_info(void *_info)
962 Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
965 eina_stringshare_del(info->change.insert.content);
969 eina_stringshare_del(info->change.del.content);
975 _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
979 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
980 info->insert = EINA_FALSE;
981 start = evas_textblock_cursor_pos_get(en->sel_start);
982 end = evas_textblock_cursor_pos_get(en->sel_end);
983 info->change.del.start = start;
984 info->change.del.end = end;
986 tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
987 info->change.del.content = eina_stringshare_add(tmp);
989 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
990 _edje_emit(ed, "entry,changed", en->rp->part->name);
991 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
992 _free_entry_change_info);
996 _range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
998 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1002 _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1003 Eina_Bool backspace)
1005 if (!evas_textblock_cursor_char_next(c))
1009 evas_textblock_cursor_char_prev(c);
1011 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1012 char *tmp = evas_textblock_cursor_content_get(c);
1014 info->insert = EINA_FALSE;
1017 info->change.del.start = pos - 1;
1018 info->change.del.end = pos;
1022 info->change.del.start = pos + 1;
1023 info->change.del.end = pos;
1026 info->change.del.content = eina_stringshare_add(tmp);
1029 evas_textblock_cursor_char_delete(c);
1030 _edje_emit(ed, "entry,changed", en->rp->part->name);
1031 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1032 info, _free_entry_change_info);
1036 _edje_entry_hide_visible_password(Edje_Real_Part *rp)
1038 const Evas_Object_Textblock_Node_Format *node;
1039 node = evas_textblock_node_format_first_get(rp->object);
1040 for (; node; node = evas_textblock_node_format_next_get(node))
1042 const char *text = evas_textblock_node_format_text_get(node);
1045 if (!strcmp(text, "+ password=off"))
1047 evas_textblock_node_format_remove_pair(rp->object,
1048 (Evas_Object_Textblock_Node_Format *) node);
1053 _edje_entry_real_part_configure(rp);
1054 _edje_emit(rp->edje, "entry,changed", rp->part->name);
1058 _password_timer_cb(void *data)
1060 Entry *en = (Entry *)data;
1061 _edje_entry_hide_visible_password(en->rp);
1062 en->pw_timer = NULL;
1063 return ECORE_CALLBACK_CANCEL;
1067 _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1070 Evas_Event_Key_Down *ev = event_info;
1071 Edje_Real_Part *rp = ed->focused_part;
1073 Eina_Bool control, alt, shift;
1074 Eina_Bool multiline;
1075 Eina_Bool cursor_changed;
1078 en = rp->entry_data;
1079 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1080 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1082 if (!ev->key) return;
1084 #ifdef HAVE_ECORE_IMF
1085 if (en->imf_context)
1087 Ecore_IMF_Event_Key_Down ecore_ev;
1088 ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
1089 if (ecore_imf_context_filter_event(en->imf_context,
1090 ECORE_IMF_EVENT_KEY_DOWN,
1091 (Ecore_IMF_Event *)&ecore_ev))
1096 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1098 control = evas_key_modifier_is_set(ev->modifiers, "Control");
1099 alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
1100 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1101 multiline = rp->part->multiline;
1102 cursor_changed = EINA_FALSE;
1103 if (!strcmp(ev->key, "Escape"))
1105 // dead keys here. Escape for now (should emit these)
1106 _edje_emit(ed, "entry,key,escape", rp->part->name);
1107 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1109 else if (!strcmp(ev->key, "Up") || !strcmp(ev->key, "KP_Up"))
1113 if (en->select_allow)
1115 if (shift) _sel_start(en->cursor, rp->object, en);
1116 else _sel_clear(en->cursor, rp->object, en);
1118 _curs_up(en->cursor, rp->object, en);
1119 if (en->select_allow)
1121 if (shift) _sel_extend(en->cursor, rp->object, en);
1123 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1125 _sel_clear(en->cursor, rp->object, en);
1126 _edje_emit(ed, "entry,key,up", rp->part->name);
1127 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1129 else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down"))
1133 if (en->select_allow)
1135 if (shift) _sel_start(en->cursor, rp->object, en);
1136 else _sel_clear(en->cursor, rp->object, en);
1138 _curs_down(en->cursor, rp->object, en);
1139 if (en->select_allow)
1141 if (shift) _sel_extend(en->cursor, rp->object, en);
1143 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1145 _sel_clear(en->cursor, rp->object, en);
1146 _edje_emit(ed, "entry,key,down", rp->part->name);
1147 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1149 else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left"))
1151 if (en->select_allow)
1153 if (shift) _sel_start(en->cursor, rp->object, en);
1154 else _sel_clear(en->cursor, rp->object, en);
1156 evas_textblock_cursor_char_prev(en->cursor);
1157 /* If control is pressed, go to the start of the word */
1158 if (control) evas_textblock_cursor_word_start(en->cursor);
1159 if (en->select_allow)
1161 if (shift) _sel_extend(en->cursor, rp->object, en);
1163 _sel_clear(en->cursor, rp->object, en);
1164 _edje_emit(ed, "entry,key,left", rp->part->name);
1165 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1166 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1168 else if (!strcmp(ev->key, "Right") || !strcmp(ev->key, "KP_Right"))
1170 if (en->select_allow)
1172 if (shift) _sel_start(en->cursor, rp->object, en);
1173 else _sel_clear(en->cursor, rp->object, en);
1175 /* If control is pressed, go to the start of the word */
1176 if (control) evas_textblock_cursor_word_end(en->cursor);
1177 evas_textblock_cursor_char_next(en->cursor);
1178 if (en->select_allow)
1180 if (shift) _sel_extend(en->cursor, rp->object, en);
1182 _sel_clear(en->cursor, rp->object, en);
1183 _edje_emit(ed, "entry,key,right", rp->part->name);
1184 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1185 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1187 else if (!strcmp(ev->key, "BackSpace"))
1189 if (control && !en->have_selection)
1191 // del to start of previous word
1192 _sel_start(en->cursor, rp->object, en);
1194 evas_textblock_cursor_char_prev(en->cursor);
1195 evas_textblock_cursor_word_start(en->cursor);
1197 _sel_extend(en->cursor, rp->object, en);
1199 _range_del_emit(ed, en->cursor, rp->object, en);
1201 else if ((alt) && (shift))
1207 if (en->have_selection)
1209 _range_del_emit(ed, en->cursor, rp->object, en);
1213 if (evas_textblock_cursor_char_prev(en->cursor))
1215 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
1219 _sel_clear(en->cursor, rp->object, en);
1220 _anchors_get(en->cursor, rp->object, en);
1221 _edje_emit(ed, "entry,key,backspace", rp->part->name);
1222 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1224 else if (!strcmp(ev->key, "Delete") || !strcmp(ev->key, "KP_Delete"))
1228 // del to end of next word
1229 _sel_start(en->cursor, rp->object, en);
1231 evas_textblock_cursor_word_end(en->cursor);
1232 evas_textblock_cursor_char_next(en->cursor);
1234 _sel_extend(en->cursor, rp->object, en);
1236 _range_del_emit(ed, en->cursor, rp->object, en);
1244 if (en->have_selection)
1246 _range_del_emit(ed, en->cursor, rp->object, en);
1250 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
1253 _sel_clear(en->cursor, rp->object, en);
1254 _anchors_get(en->cursor, rp->object, en);
1255 _edje_emit(ed, "entry,key,delete", rp->part->name);
1256 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1258 else if (!strcmp(ev->key, "Home") || !strcmp(ev->key, "KP_Home"))
1260 if (en->select_allow)
1262 if (shift) _sel_start(en->cursor, rp->object, en);
1263 else _sel_clear(en->cursor, rp->object, en);
1265 if ((control) && (multiline))
1266 _curs_start(en->cursor, rp->object, en);
1268 _curs_lin_start(en->cursor, rp->object, en);
1269 if (en->select_allow)
1271 if (shift) _sel_extend(en->cursor, rp->object, en);
1273 _edje_emit(ed, "entry,key,home", rp->part->name);
1274 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1276 else if (!strcmp(ev->key, "End") || !strcmp(ev->key, "KP_End"))
1278 if (en->select_allow)
1280 if (shift) _sel_start(en->cursor, rp->object, en);
1281 else _sel_clear(en->cursor, rp->object, en);
1283 if ((control) && (multiline))
1284 _curs_end(en->cursor, rp->object, en);
1286 _curs_lin_end(en->cursor, rp->object, en);
1287 if (en->select_allow)
1289 if (shift) _sel_extend(en->cursor, rp->object, en);
1291 _edje_emit(ed, "entry,key,end", rp->part->name);
1292 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1294 else if (!strcmp(ev->key, "Shift_L") || !strcmp(ev->key, "Shift_R"))
1298 else if ((control) && (!strcmp(ev->key, "v")))
1300 _edje_emit(ed, "entry,paste,request", rp->part->name);
1301 _edje_emit(ed, "entry,paste,request,3", rp->part->name);
1302 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1304 else if ((control) && (!strcmp(ev->key, "a")))
1306 _edje_emit(ed, "entry,selection,all,request", rp->part->name);
1307 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1309 else if ((control) && (!strcmp(ev->key, "A")))
1311 _edje_emit(ed, "entry,selection,none,request", rp->part->name);
1312 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1314 else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert")))))
1316 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1317 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1319 else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m")))))
1321 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1322 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1324 else if ((control) && (!strcmp(ev->key, "z")))
1329 _edje_emit(ed, "entry,redo,request", rp->part->name);
1334 _edje_emit(ed, "entry,undo,request", rp->part->name);
1336 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1338 else if ((control) && (!strcmp(ev->key, "y")))
1341 _edje_emit(ed, "entry,redo,request", rp->part->name);
1342 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1344 else if ((control) && (!strcmp(ev->key, "w")))
1346 _sel_clear(en->cursor, rp->object, en);
1347 // select current word?
1348 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1350 else if (!strcmp(ev->key, "Tab"))
1360 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1361 info->insert = EINA_TRUE;
1362 info->change.insert.plain_length = 1;
1364 if (en->have_selection)
1366 _range_del_emit(ed, en->cursor, rp->object, en);
1367 info->merge = EINA_TRUE;
1369 _sel_clear(en->cursor, rp->object, en);
1370 info->change.insert.pos =
1371 evas_textblock_cursor_pos_get(en->cursor);
1372 info->change.insert.content = eina_stringshare_add("<tab/>");
1374 // evas_textblock_cursor_format_prepend(en->cursor, "tab");
1375 _text_filter_format_prepend(en, en->cursor, "tab");
1376 _anchors_get(en->cursor, rp->object, en);
1377 _edje_emit(ed, "entry,changed", rp->part->name);
1378 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1379 info, _free_entry_change_info);
1381 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1383 _edje_emit(ed, "entry,key,tab", rp->part->name);
1385 else if ((!strcmp(ev->key, "ISO_Left_Tab")) && (multiline))
1388 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1390 else if (!strcmp(ev->key, "Prior") || !strcmp(ev->key, "KP_Prior"))
1392 if (en->select_allow)
1394 if (shift) _sel_start(en->cursor, rp->object, en);
1395 else _sel_clear(en->cursor, rp->object, en);
1397 _curs_jump_line_by(en->cursor, rp->object, en, -10);
1398 if (en->select_allow)
1400 if (shift) _sel_extend(en->cursor, rp->object, en);
1402 _sel_clear(en->cursor, rp->object, en);
1403 _edje_emit(ed, "entry,key,pgup", rp->part->name);
1404 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1406 else if (!strcmp(ev->key, "Next") || !strcmp(ev->key, "KP_Next"))
1408 if (en->select_allow)
1410 if (shift) _sel_start(en->cursor, rp->object, en);
1411 else _sel_clear(en->cursor, rp->object, en);
1413 _curs_jump_line_by(en->cursor, rp->object, en, 10);
1414 if (en->select_allow)
1416 if (shift) _sel_extend(en->cursor, rp->object, en);
1418 _sel_clear(en->cursor, rp->object, en);
1419 _edje_emit(ed, "entry,key,pgdn", rp->part->name);
1420 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1422 else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
1426 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1427 info->insert = EINA_TRUE;
1428 info->change.insert.plain_length = 1;
1429 if (en->have_selection)
1431 _range_del_emit(ed, en->cursor, rp->object, en);
1432 info->merge = EINA_TRUE;
1434 _sel_clear(en->cursor, rp->object, en);
1436 info->change.insert.pos =
1437 evas_textblock_cursor_pos_get(en->cursor);
1441 // evas_textblock_cursor_format_prepend(en->cursor, "br");
1442 _text_filter_format_prepend(en, en->cursor, "br");
1443 info->change.insert.content = eina_stringshare_add("<br/>");
1448 // evas_textblock_cursor_format_prepend(en->cursor, "ps");
1449 _text_filter_format_prepend(en, en->cursor, "ps");
1450 info->change.insert.content = eina_stringshare_add("<ps/>");
1452 _anchors_get(en->cursor, rp->object, en);
1453 _edje_emit(ed, "entry,changed", rp->part->name);
1454 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1455 info, _free_entry_change_info);
1456 _edje_emit(ed, "cursor,changed", rp->part->name);
1457 cursor_changed = EINA_TRUE;
1458 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1460 _edje_emit(ed, "entry,key,enter", rp->part->name);
1466 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1467 info->insert = EINA_TRUE;
1468 info->change.insert.plain_length = 1;
1469 info->change.insert.content = eina_stringshare_add(ev->string);
1471 if (en->have_selection)
1473 _range_del_emit(ed, en->cursor, rp->object, en);
1474 info->merge = EINA_TRUE;
1476 _sel_clear(en->cursor, rp->object, en);
1478 info->change.insert.pos =
1479 evas_textblock_cursor_pos_get(en->cursor);
1480 // if PASSWORD_SHOW_LAST mode, appending text with password=off tag
1481 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
1482 _edje_password_show_last)
1484 _edje_entry_hide_visible_password(en->rp);
1485 _text_filter_format_prepend(en, en->cursor, "+ password=off");
1486 _text_filter_text_prepend(en, en->cursor, ev->string);
1487 _text_filter_format_prepend(en, en->cursor, "- password");
1490 ecore_timer_del(en->pw_timer);
1491 en->pw_timer = NULL;
1493 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
1494 _password_timer_cb, en);
1497 _text_filter_text_prepend(en, en->cursor, ev->string);
1498 _anchors_get(en->cursor, rp->object, en);
1499 _edje_emit(ed, "entry,changed", rp->part->name);
1500 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1501 info, _free_entry_change_info);
1502 _edje_emit(ed, "cursor,changed", rp->part->name);
1503 cursor_changed = EINA_TRUE;
1504 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1507 if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
1508 _edje_emit(ed, "cursor,changed", rp->part->name);
1510 _edje_entry_imf_context_reset(en);
1511 _edje_entry_imf_cursor_info_set(en);
1512 _edje_entry_real_part_configure(rp);
1516 _edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1519 Edje_Real_Part *rp = ed->focused_part;
1523 en = rp->entry_data;
1524 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1525 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1528 #ifdef HAVE_ECORE_IMF
1529 if (en->imf_context)
1531 Evas_Event_Key_Up *ev = event_info;
1532 Ecore_IMF_Event_Key_Up ecore_ev;
1534 ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev);
1535 if (ecore_imf_context_filter_event(en->imf_context,
1536 ECORE_IMF_EVENT_KEY_UP,
1537 (Ecore_IMF_Event *)&ecore_ev))
1546 _edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1548 Edje_Real_Part *rp = data;
1551 en = rp->entry_data;
1553 _edje_entry_imf_cursor_info_set(en);
1557 _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1560 Edje_Real_Part *rp = data;
1561 Evas_Event_Mouse_Down *ev = event_info;
1563 Evas_Coord x, y, w, h;
1564 // Eina_Bool multiline;
1565 Evas_Textblock_Cursor *tc;
1566 Eina_Bool dosel = EINA_FALSE;
1568 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1569 en = rp->entry_data;
1570 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1571 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
1573 if ((ev->button != 1) && (ev->button != 2)) return;
1575 #ifdef HAVE_ECORE_IMF
1576 if (en->imf_context)
1578 Ecore_IMF_Event_Mouse_Down ecore_ev;
1579 ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev);
1580 if (ecore_imf_context_filter_event(en->imf_context,
1581 ECORE_IMF_EVENT_MOUSE_DOWN,
1582 (Ecore_IMF_Event *)&ecore_ev))
1587 en->select_mod_start = EINA_FALSE;
1588 en->select_mod_end = EINA_FALSE;
1589 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
1591 else if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
1593 if (en->select_allow) dosel = EINA_TRUE;
1595 if (ev->button == 2) dosel = EINA_FALSE;
1598 // double click -> select word
1599 // triple click -> select line
1601 tc = evas_object_textblock_cursor_new(rp->object);
1602 evas_textblock_cursor_copy(en->cursor, tc);
1603 // multiline = rp->part->multiline;
1604 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1605 cx = ev->canvas.x - x;
1606 cy = ev->canvas.y - y;
1607 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
1609 Evas_Coord lx, ly, lw, lh;
1612 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
1615 if (rp->part->multiline)
1616 _curs_end(en->cursor, rp->object, en);
1619 evas_textblock_cursor_paragraph_first(en->cursor);
1620 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1621 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
1622 _curs_end(en->cursor, rp->object, en);
1629 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1632 _curs_lin_start(en->cursor, rp->object, en);
1637 _curs_lin_start(en->cursor, rp->object, en);
1639 _curs_lin_end(en->cursor, rp->object, en);
1645 if ((en->have_selection) &&
1646 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
1648 Eina_List *first, *last;
1652 last = eina_list_last(en->sel);
1655 Evas_Textblock_Rectangle *r1, *r2;
1656 Evas_Coord d, d1, d2;
1662 d = (r1->y + (r1->h / 2)) - cy;
1664 d = r2->x + r2->w - 1 - cx;
1666 d = (r2->y + (r2->h / 2)) - cy;
1668 sc = rp->edje->scale;
1669 if (sc == ZERO) sc = _edje_scale;
1670 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
1676 en->select_mod_start = EINA_TRUE;
1677 en->selecting = EINA_TRUE;
1684 en->select_mod_end = EINA_TRUE;
1685 en->selecting = EINA_TRUE;
1692 en->selecting = EINA_TRUE;
1693 _sel_clear(en->cursor, rp->object, en);
1694 if (en->select_allow)
1696 _sel_start(en->cursor, rp->object, en);
1700 if (evas_textblock_cursor_compare(tc, en->cursor))
1702 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1703 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1705 evas_textblock_cursor_free(tc);
1707 _edje_entry_imf_context_reset(en);
1708 _edje_entry_imf_cursor_info_set(en);
1710 _edje_entry_real_part_configure(rp);
1711 if (ev->button == 2)
1713 _edje_emit(rp->edje, "entry,paste,request", rp->part->name);
1714 _edje_emit(rp->edje, "entry,paste,request,1", rp->part->name);
1719 _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1722 Edje_Real_Part *rp = data;
1723 Evas_Event_Mouse_Up *ev = event_info;
1725 Evas_Coord x, y, w, h;
1726 Evas_Textblock_Cursor *tc;
1727 if (ev->button != 1) return;
1729 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1730 en = rp->entry_data;
1731 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1732 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
1735 #ifdef HAVE_ECORE_IMF
1736 if (en->imf_context)
1738 Ecore_IMF_Event_Mouse_Up ecore_ev;
1739 ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev);
1740 if (ecore_imf_context_filter_event(en->imf_context,
1741 ECORE_IMF_EVENT_MOUSE_UP,
1742 (Ecore_IMF_Event *)&ecore_ev))
1747 tc = evas_object_textblock_cursor_new(rp->object);
1748 evas_textblock_cursor_copy(en->cursor, tc);
1749 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1750 cx = ev->canvas.x - x;
1751 cy = ev->canvas.y - y;
1752 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
1754 Evas_Coord lx, ly, lw, lh;
1757 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
1760 if (rp->part->multiline)
1761 _curs_end(en->cursor, rp->object, en);
1764 evas_textblock_cursor_paragraph_first(en->cursor);
1765 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1766 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
1767 _curs_end(en->cursor, rp->object, en);
1774 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1777 _curs_lin_start(en->cursor, rp->object, en);
1782 _curs_lin_start(en->cursor, rp->object, en);
1784 _curs_lin_end(en->cursor, rp->object, en);
1788 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
1790 if (en->select_allow)
1794 if (en->select_mod_end)
1795 _sel_extend(en->cursor, rp->object, en);
1796 else if (en->select_mod_start)
1797 _sel_preextend(en->cursor, rp->object, en);
1800 _sel_extend(en->cursor, rp->object, en);
1801 //evas_textblock_cursor_copy(en->cursor, en->sel_end);
1805 evas_textblock_cursor_copy(en->cursor, en->sel_end);
1808 if (en->have_selection)
1809 en->had_sel = EINA_TRUE;
1810 en->selecting = EINA_FALSE;
1812 if (evas_textblock_cursor_compare(tc, en->cursor))
1814 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1815 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1817 evas_textblock_cursor_free(tc);
1819 _edje_entry_imf_context_reset(en);
1820 _edje_entry_imf_cursor_info_set(en);
1821 _edje_entry_real_part_configure(rp);
1825 _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1828 Edje_Real_Part *rp = data;
1829 Evas_Event_Mouse_Move *ev = event_info;
1831 Evas_Coord x, y, w, h;
1832 Evas_Textblock_Cursor *tc;
1834 en = rp->entry_data;
1835 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1836 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
1839 #ifdef HAVE_ECORE_IMF
1840 if (en->imf_context)
1842 Ecore_IMF_Event_Mouse_Move ecore_ev;
1843 ecore_imf_evas_event_mouse_move_wrap(ev, &ecore_ev);
1844 if (ecore_imf_context_filter_event(en->imf_context,
1845 ECORE_IMF_EVENT_MOUSE_MOVE,
1846 (Ecore_IMF_Event *)&ecore_ev))
1853 tc = evas_object_textblock_cursor_new(rp->object);
1854 evas_textblock_cursor_copy(en->cursor, tc);
1855 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1856 cx = ev->cur.canvas.x - x;
1857 cy = ev->cur.canvas.y - y;
1858 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
1860 Evas_Coord lx, ly, lw, lh;
1862 if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0)
1864 if (rp->part->multiline)
1865 _curs_end(en->cursor, rp->object, en);
1868 evas_textblock_cursor_paragraph_first(en->cursor);
1869 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1870 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
1871 _curs_end(en->cursor, rp->object, en);
1876 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1878 _curs_lin_start(en->cursor, rp->object, en);
1880 _curs_lin_end(en->cursor, rp->object, en);
1883 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
1885 if (en->select_allow)
1889 if (en->select_mod_end)
1890 _sel_extend(en->cursor, rp->object, en);
1891 else if (en->select_mod_start)
1892 _sel_preextend(en->cursor, rp->object, en);
1895 _sel_extend(en->cursor, rp->object, en);
1900 _sel_extend(en->cursor, rp->object, en);
1902 if (en->select_allow)
1904 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0)
1905 _sel_enable(en->cursor, rp->object, en);
1906 if (en->have_selection)
1907 _sel_update(en->cursor, rp->object, en);
1909 if (evas_textblock_cursor_compare(tc, en->cursor))
1911 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1912 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1914 evas_textblock_cursor_free(tc);
1916 _edje_entry_imf_context_reset(en);
1917 _edje_entry_imf_cursor_info_set(en);
1919 _edje_entry_real_part_configure(rp);
1924 _evas_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info)
1926 Edje *ed = (Edje *)data;
1928 if (evas_focus_get(e) == ed->obj)
1930 _edje_focus_in_cb(data, NULL, NULL, NULL);
1935 _evas_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info)
1937 Edje *ed = (Edje *)data;
1939 if (evas_focus_get(e) == ed->obj)
1941 _edje_focus_out_cb(data, NULL, NULL, NULL);
1945 /***************************************************************/
1947 _edje_entry_init(Edje *ed)
1949 if (!ed->has_entries)
1951 if (ed->entries_inited)
1953 ed->entries_inited = EINA_TRUE;
1955 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed);
1956 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed);
1957 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed);
1958 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed);
1959 evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed);
1960 evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed);
1964 _edje_entry_shutdown(Edje *ed)
1966 if (!ed->has_entries)
1968 if (!ed->entries_inited)
1970 ed->entries_inited = EINA_FALSE;
1972 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb);
1973 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb);
1974 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb);
1975 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb);
1976 if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed)
1977 ERR("could not unregister EVAS_CALLBACK_FOCUS_IN");
1978 if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed)
1979 ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT");
1983 _edje_entry_real_part_init(Edje_Real_Part *rp)
1986 #ifdef HAVE_ECORE_IMF
1988 const Ecore_IMF_Context_Info *ctx_info;
1991 en = calloc(1, sizeof(Entry));
1993 rp->entry_data = en;
1996 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp);
1998 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp);
1999 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp);
2000 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp);
2002 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
2003 en->select_allow = EINA_TRUE;
2005 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
2007 Edje_Part_Description_Text *txt;
2009 txt = (Edje_Part_Description_Text *)rp->chosen_description;
2011 en->select_allow = EINA_FALSE;
2012 if (txt && edje_string_get(&txt->text.repch))
2013 evas_object_textblock_replace_char_set(rp->object, edje_string_get(&txt->text.repch));
2015 evas_object_textblock_replace_char_set(rp->object, "*");
2018 en->cursor_bg = edje_object_add(rp->edje->base.evas);
2019 edje_object_file_set(en->cursor_bg, rp->edje->path, rp->part->source3);
2020 evas_object_smart_member_add(en->cursor_bg, rp->edje->obj);
2021 evas_object_stack_below(en->cursor_bg, rp->object);
2022 evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object));
2023 evas_object_pass_events_set(en->cursor_bg, EINA_TRUE);
2024 _edje_subobj_register(en->rp->edje, en->cursor_bg);
2026 en->cursor_fg = edje_object_add(rp->edje->base.evas);
2027 edje_object_file_set(en->cursor_fg, rp->edje->path, rp->part->source4);
2028 evas_object_smart_member_add(en->cursor_fg, rp->edje->obj);
2029 evas_object_stack_above(en->cursor_fg, rp->object);
2030 evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object));
2031 evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
2032 _edje_subobj_register(en->rp->edje, en->cursor_fg);
2034 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2036 evas_object_show(en->cursor_bg);
2037 evas_object_show(en->cursor_fg);
2038 #ifdef HAVE_ECORE_IMF
2041 edje_object_signal_callback_add(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
2042 edje_object_signal_callback_add(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
2044 ctx_id = ecore_imf_context_default_id_get();
2047 ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
2048 if (!ctx_info->canvas_type ||
2049 strcmp(ctx_info->canvas_type, "evas") == 0)
2051 en->imf_context = ecore_imf_context_add(ctx_id);
2055 ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
2058 en->imf_context = ecore_imf_context_add(ctx_id);
2063 en->imf_context = NULL;
2065 if (!en->imf_context) goto done;
2067 ecore_imf_context_client_window_set
2069 (void *)ecore_evas_window_get
2070 (ecore_evas_ecore_evas_get(rp->edje->base.evas)));
2071 ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->base.evas);
2073 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
2074 _edje_entry_imf_retrieve_surrounding_cb, rp->edje);
2075 en->imf_ee_handler_commit = ecore_event_handler_add(ECORE_IMF_EVENT_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
2076 en->imf_ee_handler_delete = ecore_event_handler_add(ECORE_IMF_EVENT_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje);
2077 en->imf_ee_handler_changed = ecore_event_handler_add(ECORE_IMF_EVENT_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje);
2078 ecore_imf_context_input_mode_set(en->imf_context,
2079 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
2080 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
2083 #ifdef HAVE_ECORE_IMF
2086 en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
2090 _edje_entry_real_part_shutdown(Edje_Real_Part *rp)
2092 Entry *en = rp->entry_data;
2094 rp->entry_data = NULL;
2095 _sel_clear(en->cursor, rp->object, en);
2096 _anchors_clear(en->cursor, rp->object, en);
2097 #ifdef HAVE_ECORE_IMF
2100 evas_object_del(en->cursor_bg);
2101 evas_object_del(en->cursor_fg);
2105 ecore_timer_del(en->pw_timer);
2106 en->pw_timer = NULL;
2109 #ifdef HAVE_ECORE_IMF
2110 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2112 if (en->imf_context)
2114 if (en->imf_ee_handler_commit)
2116 ecore_event_handler_del(en->imf_ee_handler_commit);
2117 en->imf_ee_handler_commit = NULL;
2120 if (en->imf_ee_handler_delete)
2122 ecore_event_handler_del(en->imf_ee_handler_delete);
2123 en->imf_ee_handler_delete = NULL;
2126 if (en->imf_ee_handler_changed)
2128 ecore_event_handler_del(en->imf_ee_handler_changed);
2129 en->imf_ee_handler_changed = NULL;
2132 ecore_imf_context_del(en->imf_context);
2133 en->imf_context = NULL;
2136 edje_object_signal_callback_del(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
2137 edje_object_signal_callback_del(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb);
2138 ecore_imf_shutdown();
2146 _edje_entry_real_part_configure(Edje_Real_Part *rp)
2148 Evas_Coord x, y, w, h, xx, yy, ww, hh;
2149 Entry *en = rp->entry_data;
2150 Evas_Textblock_Cursor_Type cur_type;
2152 switch (rp->part->cursor_mode)
2154 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
2155 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
2157 case EDJE_ENTRY_CURSOR_MODE_UNDER:
2158 /* no break for a resaon */
2160 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
2163 _sel_update(en->cursor, rp->object, en);
2164 _anchors_update(en->cursor, rp->object, en);
2166 xx = yy = ww = hh = -1;
2167 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2168 evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
2173 evas_object_move(en->cursor_bg, x + xx, y + yy);
2174 evas_object_resize(en->cursor_bg, ww, hh);
2178 evas_object_move(en->cursor_fg, x + xx, y + yy);
2179 evas_object_resize(en->cursor_fg, ww, hh);
2184 _edje_entry_selection_get(Edje_Real_Part *rp)
2186 Entry *en = rp->entry_data;
2187 if (!en) return NULL;
2188 // get selection - convert to markup
2189 if ((!en->selection) && (en->have_selection))
2190 en->selection = evas_textblock_cursor_range_text_get
2191 (en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
2192 return en->selection;
2196 _edje_entry_text_get(Edje_Real_Part *rp)
2198 Entry *en = rp->entry_data;
2199 if (!en) return NULL;
2200 // get text - convert to markup
2201 return evas_object_textblock_text_markup_get(rp->object);
2205 _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
2207 Entry *en = rp->entry_data;
2210 // set text as markup
2211 _sel_clear(en->cursor, rp->object, en);
2212 evas_object_textblock_text_markup_set(rp->object, text);
2213 _edje_entry_set_cursor_start(rp);
2215 _anchors_get(en->cursor, rp->object, en);
2216 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2217 _edje_entry_imf_cursor_info_set(en);
2219 /* Don't emit cursor changed cause it didn't. It's just init to 0. */
2220 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2225 _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
2227 Entry *en = rp->entry_data;
2228 Evas_Textblock_Cursor *end_cur;
2230 end_cur = evas_object_textblock_cursor_new(rp->object);
2231 evas_textblock_cursor_paragraph_last(end_cur);
2233 _text_filter_markup_prepend(en, end_cur, text);
2234 evas_textblock_cursor_free(end_cur);
2236 /* We are updating according to the real cursor on purpose */
2237 _anchors_get(en->cursor, rp->object, en);
2238 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2240 _edje_entry_real_part_configure(rp);
2244 _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
2246 Entry *en = rp->entry_data;
2248 // prepend markup @ cursor pos
2249 if (en->have_selection)
2250 _range_del(en->cursor, rp->object, en);
2251 _sel_clear(en->cursor, rp->object, en);
2253 // evas_object_textblock_text_markup_prepend(en->cursor, text);
2254 _text_filter_markup_prepend(en, en->cursor, text);
2255 _anchors_get(en->cursor, rp->object, en);
2256 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2257 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2259 _edje_entry_imf_context_reset(en);
2260 _edje_entry_imf_cursor_info_set(en);
2262 _edje_entry_real_part_configure(rp);
2266 _edje_entry_set_cursor_start(Edje_Real_Part *rp)
2268 Entry *en = rp->entry_data;
2270 _curs_start(en->cursor, rp->object, en);
2272 _edje_entry_imf_cursor_info_set(en);
2276 _edje_entry_set_cursor_end(Edje_Real_Part *rp)
2278 Entry *en = rp->entry_data;
2280 _curs_end(en->cursor, rp->object, en);
2282 _edje_entry_imf_cursor_info_set(en);
2286 _edje_entry_select_none(Edje_Real_Part *rp)
2288 Entry *en = rp->entry_data;
2290 _sel_clear(en->cursor, rp->object, en);
2294 _edje_entry_select_all(Edje_Real_Part *rp)
2296 Entry *en = rp->entry_data;
2298 _sel_clear(en->cursor, rp->object, en);
2299 _curs_start(en->cursor, rp->object, en);
2300 _sel_enable(en->cursor, rp->object, en);
2301 _sel_start(en->cursor, rp->object, en);
2302 _curs_end(en->cursor, rp->object, en);
2303 _sel_extend(en->cursor, rp->object, en);
2305 _edje_entry_imf_context_reset(en);
2306 _edje_entry_imf_cursor_info_set(en);
2307 _edje_entry_real_part_configure(rp);
2311 _edje_entry_select_begin(Edje_Real_Part *rp)
2313 Entry *en = rp->entry_data;
2315 _sel_clear(en->cursor, rp->object, en);
2316 _sel_enable(en->cursor, rp->object, en);
2317 _sel_start(en->cursor, rp->object, en);
2318 _sel_extend(en->cursor, rp->object, en);
2320 _edje_entry_imf_context_reset(en);
2321 _edje_entry_imf_cursor_info_set(en);
2323 _edje_entry_real_part_configure(rp);
2327 _edje_entry_select_extend(Edje_Real_Part *rp)
2329 Entry *en = rp->entry_data;
2331 _sel_extend(en->cursor, rp->object, en);
2333 _edje_entry_imf_context_reset(en);
2334 _edje_entry_imf_cursor_info_set(en);
2336 _edje_entry_real_part_configure(rp);
2340 _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
2342 Entry *en = rp->entry_data;
2346 if (!en) return NULL;
2347 EINA_LIST_FOREACH(en->anchors, l, an)
2349 if (an->item) continue;
2350 if (!strcmp(anchor, an->name))
2357 _edje_entry_anchors_list(Edje_Real_Part *rp)
2359 Entry *en = rp->entry_data;
2360 Eina_List *l, *anchors = NULL;
2363 if (!en) return NULL;
2364 if (!en->anchorlist)
2366 EINA_LIST_FOREACH(en->anchors, l, an)
2368 const char *n = an->name;
2369 if (an->item) continue;
2371 anchors = eina_list_append(anchors, strdup(n));
2373 en->anchorlist = anchors;
2375 return en->anchorlist;
2379 _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
2381 Entry *en = rp->entry_data;
2385 if (!en) return EINA_FALSE;
2386 EINA_LIST_FOREACH(en->anchors, l, an)
2388 if (an->item) continue;
2389 if (!strcmp(item, an->name))
2391 evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
2399 _edje_entry_items_list(Edje_Real_Part *rp)
2401 Entry *en = rp->entry_data;
2402 Eina_List *l, *items = NULL;
2405 if (!en) return NULL;
2408 EINA_LIST_FOREACH(en->anchors, l, an)
2410 const char *n = an->name;
2411 if (an->item) continue;
2413 items = eina_list_append(items, strdup(n));
2415 en->itemlist = items;
2417 return en->itemlist;
2421 _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
2423 Evas_Coord x, y, w, h, xx, yy, ww, hh;
2424 Entry *en = rp->entry_data;
2425 Evas_Textblock_Cursor_Type cur_type;
2427 switch (rp->part->cursor_mode)
2429 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
2430 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
2432 case EDJE_ENTRY_CURSOR_MODE_UNDER:
2433 /* no break for a resaon */
2435 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
2439 xx = yy = ww = hh = -1;
2440 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2441 evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
2443 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
2444 edje_object_size_min_restricted_calc(en->cursor_fg, &ww, NULL, ww, 0);
2446 if (cx) *cx = x + xx;
2447 if (cy) *cy = y + yy;
2453 _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
2455 Entry *en = rp->entry_data;
2456 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
2458 en->select_allow = allow;
2462 _edje_entry_select_allow_get(const Edje_Real_Part *rp)
2464 const Entry *en = rp->entry_data;
2465 return en->select_allow;
2469 _edje_entry_select_abort(Edje_Real_Part *rp)
2471 Entry *en = rp->entry_data;
2474 en->selecting = EINA_FALSE;
2476 _edje_entry_imf_context_reset(en);
2477 _edje_entry_imf_cursor_info_set(en);
2478 _edje_entry_real_part_configure(rp);
2483 _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type)
2485 Entry *en = rp->entry_data;
2488 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
2489 autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
2491 #ifdef HAVE_ECORE_IMF
2492 if (en->imf_context)
2493 ecore_imf_context_autocapital_type_set(en->imf_context, autocapital_type);
2497 Edje_Text_Autocapital_Type
2498 _edje_entry_autocapital_type_get(Edje_Real_Part *rp)
2500 Entry *en = rp->entry_data;
2501 if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
2503 #ifdef HAVE_ECORE_IMF
2504 if (en->imf_context)
2505 return ecore_imf_context_autocapital_type_get(en->imf_context);
2508 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
2512 _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled)
2514 Entry *en = rp->entry_data;
2517 #ifdef HAVE_ECORE_IMF
2518 if (en->imf_context)
2519 ecore_imf_context_input_panel_enabled_set(en->imf_context, enabled);
2526 _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp)
2528 Entry *en = rp->entry_data;
2529 if (!en) return EINA_FALSE;
2530 #ifdef HAVE_ECORE_IMF
2531 if (en->imf_context)
2532 return ecore_imf_context_input_panel_enabled_get(en->imf_context);
2538 static Evas_Textblock_Cursor *
2539 _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
2541 Entry *en = rp->entry_data;
2542 if (!en) return NULL;
2546 case EDJE_CURSOR_MAIN:
2548 case EDJE_CURSOR_SELECTION_BEGIN:
2549 return en->sel_start;
2550 case EDJE_CURSOR_SELECTION_END:
2552 case EDJE_CURSOR_PREEDIT_START:
2553 if (!en->preedit_start)
2554 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
2555 return en->preedit_start;
2556 case EDJE_CURSOR_PREEDIT_END:
2557 if (!en->preedit_end)
2558 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
2559 return en->preedit_end;
2560 case EDJE_CURSOR_USER:
2561 if (!en->cursor_user)
2562 en->cursor_user = evas_object_textblock_cursor_new(rp->object);
2563 return en->cursor_user;
2564 case EDJE_CURSOR_USER_EXTRA:
2565 if (!en->cursor_user_extra)
2566 en->cursor_user_extra = evas_object_textblock_cursor_new(rp->object);
2567 return en->cursor_user_extra;
2575 _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
2577 Entry *en = rp->entry_data;
2578 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2579 if (!c) return EINA_FALSE;
2580 if (!evas_textblock_cursor_char_next(c))
2584 _sel_update(c, rp->object, rp->entry_data);
2586 _edje_entry_imf_context_reset(en);
2587 _edje_entry_imf_cursor_info_set(en);
2589 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2590 _edje_entry_real_part_configure(rp);
2595 _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
2597 Entry *en = rp->entry_data;
2598 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2599 if (!c) return EINA_FALSE;
2600 if (!evas_textblock_cursor_char_prev(c))
2602 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
2603 else return EINA_FALSE;
2606 _sel_update(c, rp->object, rp->entry_data);
2608 _edje_entry_imf_context_reset(en);
2609 _edje_entry_imf_cursor_info_set(en);
2611 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2612 _edje_entry_real_part_configure(rp);
2617 _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
2619 Entry *en = rp->entry_data;
2620 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2621 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
2623 if (!c) return EINA_FALSE;
2624 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
2626 if (ln < 0) return EINA_FALSE;
2627 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
2628 &lx, &ly, &lw, &lh))
2630 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
2631 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
2633 if (cx < (lx + (lw / 2)))
2634 evas_textblock_cursor_line_char_last(c);
2636 evas_textblock_cursor_line_char_last(c);
2638 _sel_update(c, rp->object, rp->entry_data);
2640 _edje_entry_imf_context_reset(en);
2641 _edje_entry_imf_cursor_info_set(en);
2643 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2644 _edje_entry_real_part_configure(rp);
2649 _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
2651 Entry *en = rp->entry_data;
2652 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2653 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
2655 if (!c) return EINA_FALSE;
2656 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
2658 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
2659 &lx, &ly, &lw, &lh))
2661 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
2662 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
2664 if (cx < (lx + (lw / 2)))
2665 evas_textblock_cursor_line_char_last(c);
2667 evas_textblock_cursor_line_char_last(c);
2669 _sel_update(c, rp->object, rp->entry_data);
2671 _edje_entry_imf_context_reset(en);
2672 _edje_entry_imf_cursor_info_set(en);
2673 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2674 _edje_entry_real_part_configure(rp);
2679 _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
2681 Entry *en = rp->entry_data;
2682 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2684 evas_textblock_cursor_paragraph_first(c);
2685 _sel_update(c, rp->object, rp->entry_data);
2687 _edje_entry_imf_context_reset(en);
2688 _edje_entry_imf_cursor_info_set(en);
2689 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2690 _edje_entry_real_part_configure(rp);
2694 _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
2696 Entry *en = rp->entry_data;
2697 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2699 _curs_end(c, rp->object, rp->entry_data);
2700 _sel_update(c, rp->object, rp->entry_data);
2702 _edje_entry_imf_context_reset(en);
2703 _edje_entry_imf_cursor_info_set(en);
2705 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2706 _edje_entry_real_part_configure(rp);
2710 _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
2712 Entry *en = rp->entry_data;
2713 Evas_Textblock_Cursor *c;
2714 Evas_Textblock_Cursor *d;
2716 c = _cursor_get(rp, cur);
2718 d = _cursor_get(rp, dst);
2720 evas_textblock_cursor_copy(c, d);
2721 _sel_update(c, rp->object, rp->entry_data);
2723 _edje_entry_imf_context_reset(en);
2724 _edje_entry_imf_cursor_info_set(en);
2725 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2726 _edje_entry_real_part_configure(rp);
2730 _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
2732 Entry *en = rp->entry_data;
2733 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2735 evas_textblock_cursor_line_char_first(c);
2736 _sel_update(c, rp->object, rp->entry_data);
2738 _edje_entry_imf_context_reset(en);
2739 _edje_entry_imf_cursor_info_set(en);
2741 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2742 _edje_entry_real_part_configure(rp);
2746 _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
2748 Entry *en = rp->entry_data;
2749 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2751 evas_textblock_cursor_line_char_last(c);
2752 _sel_update(c, rp->object, rp->entry_data);
2754 _edje_entry_imf_context_reset(en);
2755 _edje_entry_imf_cursor_info_set(en);
2756 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2757 _edje_entry_real_part_configure(rp);
2761 _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
2762 Evas_Coord x, Evas_Coord y)
2764 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2765 if (!c) return EINA_FALSE;
2766 return evas_textblock_cursor_char_coord_set(c, x, y);
2770 _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
2772 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2773 if (!c) return EINA_FALSE;
2774 if (evas_textblock_cursor_is_format(c)) return EINA_TRUE;
2779 _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
2781 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2782 if (!c) return EINA_FALSE;
2783 return evas_textblock_cursor_format_is_visible_get(c);
2787 _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
2789 static char *s = NULL;
2790 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2792 if (!c) return NULL;
2799 s = evas_textblock_cursor_content_get(c);
2804 _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
2806 Entry *en = rp->entry_data;
2807 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2809 /* Abort if cursor position didn't really change */
2810 if (evas_textblock_cursor_pos_get(c) == pos)
2813 evas_textblock_cursor_pos_set(c, pos);
2814 _sel_update(c, rp->object, rp->entry_data);
2816 _edje_entry_imf_context_reset(en);
2817 _edje_entry_imf_cursor_info_set(en);
2818 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2819 _edje_entry_real_part_configure(rp);
2823 _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur)
2825 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2827 return evas_textblock_cursor_pos_get(c);
2831 _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout)
2833 Entry *en = rp->entry_data;
2835 #ifdef HAVE_ECORE_IMF
2836 if (en->imf_context)
2837 ecore_imf_context_input_panel_layout_set(en->imf_context, layout);
2843 Edje_Input_Panel_Layout
2844 _edje_entry_input_panel_layout_get(Edje_Real_Part *rp)
2846 Entry *en = rp->entry_data;
2847 if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
2848 #ifdef HAVE_ECORE_IMF
2849 if (en->imf_context)
2850 return ecore_imf_context_input_panel_layout_get(en->imf_context);
2853 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
2857 _edje_entry_imf_context_reset(Entry *en)
2859 #ifdef HAVE_ECORE_IMF
2860 if (en->imf_context)
2861 ecore_imf_context_reset(en->imf_context);
2868 _edje_entry_imf_cursor_info_set(Entry *en)
2870 #ifdef HAVE_ECORE_IMF
2871 Evas_Coord cx, cy, cw, ch;
2872 if (!en || !en->rp || !en->imf_context) return;
2874 _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch);
2876 ecore_imf_context_cursor_position_set(en->imf_context,
2877 evas_textblock_cursor_pos_get(en->cursor));
2878 ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch);
2884 #ifdef HAVE_ECORE_IMF
2886 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos)
2889 Edje_Real_Part *rp = ed->focused_part;
2893 if (!rp) return EINA_FALSE;
2894 en = rp->entry_data;
2895 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2896 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2901 str = _edje_entry_text_get(rp);
2902 *text = str ? strdup(str) : strdup("");
2906 *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
2912 _edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
2915 Edje_Real_Part *rp = ed->focused_part;
2917 Ecore_IMF_Event_Commit *ev = event;
2918 Evas_Textblock_Cursor *tc;
2919 Eina_Bool cursor_move = EINA_FALSE;
2922 if ((!rp) || (!ev) || (!ev->str)) return ECORE_CALLBACK_PASS_ON;
2924 en = rp->entry_data;
2925 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2926 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2927 return ECORE_CALLBACK_PASS_ON;
2929 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
2930 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
2932 if (en->have_selection)
2934 if (strcmp(ev->str, ""))
2936 /* delete selected characters */
2937 _range_del_emit(ed, en->cursor, rp->object, en);
2938 _sel_clear(en->cursor, rp->object, en);
2942 tc = evas_object_textblock_cursor_new(rp->object);
2944 /* calculate the cursor position to insert commit string */
2945 if (en->preedit_start)
2946 evas_textblock_cursor_copy(en->preedit_start, tc);
2948 evas_textblock_cursor_copy(en->cursor, tc);
2950 start_pos = evas_textblock_cursor_pos_get(tc);
2953 #ifdef HAVE_ECORE_IMF
2954 /* delete preedit characters */
2959 if (evas_textblock_cursor_compare(en->cursor, tc))
2960 cursor_move = EINA_TRUE;
2961 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2962 _edje_password_show_last)
2963 _edje_entry_hide_visible_password(en->rp);
2964 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2965 _edje_password_show_last && (!en->preedit_start))
2967 _text_filter_format_prepend(en, tc, "+ password=off");
2968 _text_filter_text_prepend(en, tc, ev->str);
2969 _text_filter_format_prepend(en, tc, "- password");
2972 ecore_timer_del(en->pw_timer);
2973 en->pw_timer = NULL;
2975 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
2976 _password_timer_cb, en);
2979 _text_filter_text_prepend(en, tc, ev->str);
2983 /* move cursor to the end of commit string */
2984 evas_textblock_cursor_copy(tc, en->cursor);
2987 evas_textblock_cursor_free(tc);
2989 _edje_entry_imf_cursor_info_set(en);
2990 _anchors_get(en->cursor, rp->object, en);
2991 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2994 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2995 info->insert = EINA_TRUE;
2996 info->change.insert.pos = start_pos;
2997 info->change.insert.content = eina_stringshare_add(ev->str);
2998 info->change.insert.plain_length =
2999 eina_unicode_utf8_get_len(info->change.insert.content);
3000 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
3001 info, _free_entry_change_info);
3002 _edje_emit(ed, "cursor,changed", rp->part->name);
3005 return ECORE_CALLBACK_DONE;
3009 _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *event)
3012 Edje_Real_Part *rp = ed->focused_part;
3014 Ecore_IMF_Event_Preedit_Changed *ev = event;
3016 int preedit_start_pos, preedit_end_pos;
3017 char *preedit_string;
3019 Eina_Bool preedit_end_state = EINA_FALSE;
3020 Eina_List *attrs = NULL, *l = NULL;
3021 Ecore_IMF_Preedit_Attr *attr;
3024 if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON;
3026 en = rp->entry_data;
3027 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
3028 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
3029 return ECORE_CALLBACK_PASS_ON;
3031 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
3033 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
3035 ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
3037 &attrs, &cursor_pos);
3038 if (!preedit_string) return ECORE_CALLBACK_PASS_ON;
3040 if (!strcmp(preedit_string, ""))
3041 preedit_end_state = EINA_TRUE;
3043 if (en->have_selection && !preedit_end_state)
3045 /* delete selected characters */
3046 _range_del_emit(ed, en->cursor, rp->object, en);
3047 _sel_clear(en->cursor, rp->object, en);
3050 /* delete preedit characters */
3053 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
3055 /* insert preedit character(s) */
3056 if (strlen(preedit_string) > 0)
3058 buf = eina_strbuf_new();
3061 EINA_LIST_FOREACH(attrs, l, attr)
3063 if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB1)
3065 eina_strbuf_append(buf, "<preedit>");
3066 eina_strbuf_append_n(buf, preedit_string + attr->start_index,
3067 attr->end_index - attr->start_index);
3068 eina_strbuf_append(buf, "</preedit>");
3071 else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB2 ||
3072 attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3)
3074 eina_strbuf_append(buf, "<preedit_sel>");
3075 eina_strbuf_append_n(buf, preedit_string + attr->start_index,
3076 attr->end_index - attr->start_index);
3077 eina_strbuf_append(buf, "</preedit_sel>");
3081 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
3082 _edje_password_show_last)
3084 _edje_entry_hide_visible_password(en->rp);
3085 _text_filter_format_prepend(en, en->cursor, "+ password=off");
3086 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
3087 _text_filter_format_prepend(en, en->cursor, "- password");
3090 ecore_timer_del(en->pw_timer);
3091 en->pw_timer = NULL;
3093 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
3094 _password_timer_cb, en);
3098 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
3100 eina_strbuf_free(buf);
3103 if (!preedit_end_state)
3105 /* set preedit start cursor */
3106 if (!en->preedit_start)
3107 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
3108 evas_textblock_cursor_copy(en->cursor, en->preedit_start);
3110 /* set preedit end cursor */
3111 if (!en->preedit_end)
3112 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
3113 evas_textblock_cursor_copy(en->cursor, en->preedit_end);
3115 preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor);
3117 for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++)
3119 evas_textblock_cursor_char_prev(en->preedit_start);
3122 en->have_preedit = EINA_TRUE;
3124 /* set cursor position */
3125 evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos);
3128 _edje_entry_imf_cursor_info_set(en);
3129 _anchors_get(en->cursor, rp->object, en);
3130 _edje_emit(rp->edje, "preedit,changed", rp->part->name);
3131 _edje_emit(ed, "cursor,changed", rp->part->name);
3133 /* delete attribute list */
3136 EINA_LIST_FREE(attrs, attr) free(attr);
3139 free(preedit_string);
3141 return ECORE_CALLBACK_DONE;
3145 _edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, void *event)
3148 Edje_Real_Part *rp = ed->focused_part;
3150 Ecore_IMF_Event_Delete_Surrounding *ev = event;
3151 Evas_Textblock_Cursor *del_start, *del_end;
3154 if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON;
3155 en = rp->entry_data;
3156 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
3157 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
3158 return ECORE_CALLBACK_PASS_ON;
3160 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
3161 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
3163 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
3165 del_start = evas_object_textblock_cursor_new(en->rp->object);
3166 evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
3168 del_end = evas_object_textblock_cursor_new(en->rp->object);
3169 evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars);
3171 evas_textblock_cursor_range_delete(del_start, del_end);
3173 evas_textblock_cursor_free(del_start);
3174 evas_textblock_cursor_free(del_end);
3176 return ECORE_CALLBACK_DONE;
3180 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/