[edje_entry] commit_cancel should be EINA_FALSE when there is one or more characters...
[framework/uifw/edje.git] / src / lib / edje_entry.c
1 #include "edje_private.h"
2 #include <ctype.h>
3
4 #ifdef HAVE_ECORE_IMF
5 static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
6 static void      _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
7 static void      _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
8 static void      _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event);
9 #endif
10
11 // TIZEN ONLY - START
12 static void _edje_entry_start_handler_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
13 static void _edje_entry_start_handler_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
14 static void _edje_entry_start_handler_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
15
16 static void _edje_entry_end_handler_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
17 static void _edje_entry_end_handler_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
18 static void _edje_entry_end_handler_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
19
20 static void _edje_entry_cursor_handler_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
21 static void _edje_entry_cursor_handler_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
22 static void _edje_entry_cursor_handler_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
23 // TIZEN ONLY - END
24
25 typedef struct _Entry Entry;
26 typedef struct _Sel Sel;
27 typedef struct _Anchor Anchor;
28
29 // TIZEN ONLY - START
30 typedef enum _Entry_Long_Press_State
31 {
32    _ENTRY_LONG_PRESSING,
33    _ENTRY_LONG_PRESSED,
34    _ENTRY_LONG_PRESS_RELEASED
35 } Entry_Long_Press_State;
36 // TIZEN ONLY - END
37
38 static void _edje_entry_imf_cursor_location_set(Entry *en);
39 static void _edje_entry_imf_cursor_info_set(Entry *en);
40
41 struct _Entry
42 {
43    Edje_Real_Part *rp;
44    Evas_Coord ox, oy; // TIZEN ONLY
45    Evas_Coord sx, sy; // TIZEN ONLY
46    Evas_Coord rx, ry; // TIZEN ONLY
47    Evas_Coord dx, dy; // TIZEN ONLY
48    Evas_Coord_Rectangle layout_region; // TIZEN ONLY
49    Evas_Coord_Rectangle viewport_region; // TIZEN ONLY
50    Evas_Object *cursor_bg;
51    Evas_Object *cursor_fg, *cursor_fg2;
52    Evas_Object *sel_handler_start; // TIZEN ONLY
53    Evas_Object *sel_handler_end; // TIZEN ONLY
54    Evas_Object *sel_handler_edge_start; // TIZEN ONLY
55    Evas_Object *sel_handler_edge_end; // TIZEN ONLY
56    Evas_Object *cursor_handler; // TIZEN ONLY
57    Evas_Textblock_Cursor *cursor;
58    Evas_Textblock_Cursor *sel_start, *sel_end;
59    Evas_Textblock_Cursor *cursor_user, *cursor_user_extra;
60    Evas_Textblock_Cursor *preedit_start, *preedit_end;
61    Ecore_Timer *pw_timer;
62    Eina_List *sel;
63    Eina_List *anchors;
64    Eina_List *anchorlist;
65    Eina_List *itemlist;
66    Eina_List *seq;
67    char *selection;
68    Edje_Input_Panel_Lang input_panel_lang;
69    Eina_Bool composing : 1;
70    Eina_Bool selecting : 1;
71    Eina_Bool have_selection : 1;
72    Eina_Bool select_allow : 1;
73    Eina_Bool select_mod_start : 1;
74    Eina_Bool select_mod_end : 1;
75    Eina_Bool handler_bypassing: 1; // TIZEN ONLY
76    Eina_Bool cursor_handler_disabled: 1; // TIZEN ONLY
77    Eina_Bool cursor_handler_show : 1; // TIZEN ONLY
78    Eina_Bool had_sel : 1;
79    Eina_Bool input_panel_enable : 1;
80    Eina_Bool prediction_allow : 1;
81    Eina_Bool focused : 1; // TIZEN ONLY
82    // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
83    Eina_Bool freeze : 1;
84    //
85    int select_dragging_state;
86
87 #ifdef HAVE_ECORE_IMF
88    Eina_Bool have_preedit : 1;
89    Eina_Bool commit_cancel : 1; // For skipping useless commit
90    Ecore_IMF_Context *imf_context;
91 #endif
92
93    Ecore_Timer *long_press_timer; // TIZEN ONLY
94    Ecore_Timer *cursor_handler_click_timer; // TIZEN ONLY
95    Entry_Long_Press_State long_press_state; // TIZEN ONLY
96 };
97
98 struct _Sel
99 {
100    Evas_Textblock_Rectangle rect;
101    Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
102 };
103
104 struct _Anchor
105 {
106    Entry *en;
107    char *name;
108    Evas_Textblock_Cursor *start, *end;
109    Eina_List *sel;
110    Eina_Bool item : 1;
111 };
112
113 #ifdef HAVE_ECORE_IMF
114 static void
115 _preedit_clear(Entry *en)
116 {
117    if (en->preedit_start)
118      {
119         evas_textblock_cursor_free(en->preedit_start);
120         en->preedit_start = NULL;
121      }
122
123    if (en->preedit_end)
124      {
125         evas_textblock_cursor_free(en->preedit_end);
126         en->preedit_end = NULL;
127      }
128
129    en->have_preedit = EINA_FALSE;
130 }
131
132 static void
133 _preedit_del(Entry *en)
134 {
135    if (!en || !en->have_preedit) return;
136    if (!en->preedit_start || !en->preedit_end) return;
137    if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return;
138
139    /* delete the preedit characters */
140    evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end);
141 }
142
143 static void
144 _edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
145 {
146    Edje_Real_Part *rp;
147    Entry *en;
148
149    rp = data;
150    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
151        (!rp->typedata.text)) return;
152    if (!rp || !rp->typedata.text->entry_data || !rp->edje || !rp->edje->obj) return;
153
154    en = rp->typedata.text->entry_data;
155    if (!en || !en->imf_context) return;
156
157    if (evas_object_focus_get(rp->edje->obj))
158      {
159         // TIZEN ONLY - START
160         if ((!en->sel_handler_start) && (!en->sel_handler_end) &&
161             (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
162           {
163              if (rp->part->source8)
164                {
165                   en->sel_handler_end = edje_object_add(en->rp->edje->base.evas);
166                   edje_object_file_set(en->sel_handler_end, en->rp->edje->path, en->rp->part->source8);
167
168                   evas_object_layer_set(en->sel_handler_end, EVAS_LAYER_MAX - 2);
169                   en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_end);
170                   evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_end_handler_mouse_down_cb, en->rp);
171                   evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_UP, _edje_entry_end_handler_mouse_up_cb, en->rp);
172                   evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_end_handler_mouse_move_cb, en->rp);
173                }
174
175              if (rp->part->source7)
176                {
177                   en->sel_handler_start = edje_object_add(en->rp->edje->base.evas);
178                   edje_object_file_set(en->sel_handler_start, en->rp->edje->path, en->rp->part->source7);
179                   evas_object_layer_set(en->sel_handler_start, EVAS_LAYER_MAX - 2);
180                   en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_start);
181                   evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_start_handler_mouse_down_cb, en->rp);
182                   evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_UP, _edje_entry_start_handler_mouse_up_cb, en->rp);
183                   evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_start_handler_mouse_move_cb, en->rp);
184                }
185
186              //start edge handler
187              if (rp->part->source10)
188                {
189                   en->sel_handler_edge_start = edje_object_add(en->rp->edje->base.evas);
190                   edje_object_file_set(en->sel_handler_edge_start, en->rp->edje->path, en->rp->part->source10);
191                   evas_object_layer_set(en->sel_handler_edge_start, EVAS_LAYER_MAX - 2);
192                   en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_start);
193                   evas_object_clip_set(en->sel_handler_edge_start, evas_object_clip_get(rp->object));
194                }
195
196              //end edge handler
197              if (rp->part->source11)
198                {
199                   en->sel_handler_edge_end = edje_object_add(en->rp->edje->base.evas);
200                   edje_object_file_set(en->sel_handler_edge_end, en->rp->edje->path, en->rp->part->source11);
201                   evas_object_layer_set(en->sel_handler_edge_end, EVAS_LAYER_MAX - 2);
202                   en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_end);
203                   evas_object_clip_set(en->sel_handler_edge_end, evas_object_clip_get(rp->object));
204                }
205           }
206         if (en->sel_handler_start)
207            edje_object_signal_emit(en->sel_handler_start, "edje,focus,in", "edje");
208         if (en->sel_handler_end)
209            edje_object_signal_emit(en->sel_handler_end, "edje,focus,in", "edje");
210         if (en->cursor_handler)
211            edje_object_signal_emit(en->cursor_handler, "edje,focus,in", "edje");
212         if (en->sel_handler_edge_start)
213            edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,in", "edje");
214         if (en->sel_handler_edge_end)
215            edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,in", "edje");
216         // TIZEN ONLY - END
217
218         ecore_imf_context_reset(en->imf_context);
219         ecore_imf_context_focus_in(en->imf_context);
220         _edje_entry_imf_cursor_info_set(en);
221         en->focused = EINA_TRUE;
222      }
223 }
224
225 static void
226 _edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
227 {
228    Edje_Real_Part *rp;
229    Entry *en;
230
231    rp = data;
232    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
233        (!rp->typedata.text)) return;
234    if (!rp || !rp->typedata.text->entry_data) return;
235
236    en = rp->typedata.text->entry_data;
237    if (!en || !en->imf_context) return;
238
239    // TIZEN ONLY - START
240    if (en->sel_handler_start)
241      edje_object_signal_emit(en->sel_handler_start, "edje,focus,out", "edje");
242    if (en->sel_handler_end)
243      edje_object_signal_emit(en->sel_handler_end, "edje,focus,out", "edje");
244    if (en->cursor_handler)
245       edje_object_signal_emit(en->cursor_handler, "edje,focus,out", "edje");
246    if (en->sel_handler_edge_start)
247      edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,out", "edje");
248    if (en->sel_handler_edge_end)
249      edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,out", "edje");
250    // TIZEN ONLY - END
251
252    ecore_imf_context_reset(en->imf_context);
253    ecore_imf_context_focus_out(en->imf_context);
254 }
255 #endif
256
257 static void
258 _edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
259 {
260    Edje *ed = data;
261 #ifdef HAVE_ECORE_IMF
262    Edje_Real_Part *rp;
263    Entry *en;
264 #endif
265
266    _edje_emit(ed, "focus,in", "");
267
268    rp = ed->focused_part;
269    if (!rp) return;
270
271    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
272        (!rp->typedata.text)) return;
273    en = rp->typedata.text->entry_data;
274    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
275        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))   //  TIZEN ONLY
276      return;
277
278    // TIZEN ONLY - START
279    if ((!en->sel_handler_start) && (!en->sel_handler_end) &&
280        (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
281      {
282         if (rp->part->source8)
283           {
284              en->sel_handler_end = edje_object_add(en->rp->edje->base.evas);
285              edje_object_file_set(en->sel_handler_end, en->rp->edje->path, en->rp->part->source8);
286
287              evas_object_layer_set(en->sel_handler_end, EVAS_LAYER_MAX - 2);
288              en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_end);
289              evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_end_handler_mouse_down_cb, en->rp);
290              evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_UP, _edje_entry_end_handler_mouse_up_cb, en->rp);
291              evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_end_handler_mouse_move_cb, en->rp);
292           }
293
294         if (rp->part->source7)
295           {
296              en->sel_handler_start = edje_object_add(en->rp->edje->base.evas);
297              edje_object_file_set(en->sel_handler_start, en->rp->edje->path, en->rp->part->source7);
298              evas_object_layer_set(en->sel_handler_start, EVAS_LAYER_MAX - 2);
299              en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_start);
300              evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_start_handler_mouse_down_cb, en->rp);
301              evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_UP, _edje_entry_start_handler_mouse_up_cb, en->rp);
302              evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_start_handler_mouse_move_cb, en->rp);
303           }
304
305         //start edge handler
306         if (rp->part->source10)
307           {
308              en->sel_handler_edge_start = edje_object_add(en->rp->edje->base.evas);
309              edje_object_file_set(en->sel_handler_edge_start, en->rp->edje->path, en->rp->part->source10);
310              evas_object_layer_set(en->sel_handler_edge_start, EVAS_LAYER_MAX - 2);
311              en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_start);
312              evas_object_clip_set(en->sel_handler_edge_start, evas_object_clip_get(rp->object));
313           }
314
315         //end edge handler
316         if (rp->part->source11)
317           {
318              en->sel_handler_edge_end = edje_object_add(en->rp->edje->base.evas);
319              edje_object_file_set(en->sel_handler_edge_end, en->rp->edje->path, en->rp->part->source11);
320              evas_object_layer_set(en->sel_handler_edge_end, EVAS_LAYER_MAX - 2);
321              en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_end);
322              evas_object_clip_set(en->sel_handler_edge_end, evas_object_clip_get(rp->object));
323           }
324      }
325    if (en->sel_handler_start)
326       edje_object_signal_emit(en->sel_handler_start, "edje,focus,in", "edje");
327    if (en->sel_handler_end)
328       edje_object_signal_emit(en->sel_handler_end, "edje,focus,in", "edje");
329    if (en->cursor_handler)
330       edje_object_signal_emit(en->cursor_handler, "edje,focus,in", "edje");
331    if (en->sel_handler_edge_start)
332       edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,in", "edje");
333    if (en->sel_handler_edge_end)
334       edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,in", "edje");
335
336    en->focused = EINA_TRUE;
337    if (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE) return;
338    // TIZEN ONLY - END
339
340 #ifdef HAVE_ECORE_IMF
341    if (!en->imf_context) return;
342
343    ecore_imf_context_reset(en->imf_context);
344    ecore_imf_context_focus_in(en->imf_context);
345    _edje_entry_imf_cursor_info_set(en);
346 #endif
347 }
348
349 static void
350 _edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
351 {
352    Edje *ed = data;
353 #ifdef HAVE_ECORE_IMF
354    Edje_Real_Part *rp = ed->focused_part;
355    Entry *en;
356 #endif
357
358    _edje_emit(ed, "focus,out", "");
359
360 #ifdef HAVE_ECORE_IMF
361    if (!rp) return;
362    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
363        (!rp->typedata.text)) return;
364    en = rp->typedata.text->entry_data;
365    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
366        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))  // TIZEN ONLY
367      return;
368
369    // TIZEN ONLY - START
370    if (en->sel_handler_start)
371      edje_object_signal_emit(en->sel_handler_start, "edje,focus,out", "edje");
372    if (en->sel_handler_end)
373      edje_object_signal_emit(en->sel_handler_end, "edje,focus,out", "edje");
374    if (en->cursor_handler)
375       edje_object_signal_emit(en->cursor_handler, "edje,focus,out", "edje");
376    if (en->sel_handler_edge_start)
377      edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,out", "edje");
378    if (en->sel_handler_edge_end)
379      edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,out", "edje");
380    en->focused = EINA_FALSE;
381    if (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE) return;
382    // TIZEN ONLY - END
383
384    if (!en->imf_context) return;
385
386    ecore_imf_context_reset(en->imf_context);
387    ecore_imf_context_focus_out(en->imf_context);
388 #endif
389 }
390
391 static void
392 _text_filter_markup_prepend_internal(Entry *en, Evas_Textblock_Cursor *c, char *text)
393 {
394    Edje_Markup_Filter_Callback *cb;
395    Eina_List *l;
396
397    EINA_LIST_FOREACH(en->rp->edje->markup_filter_callbacks, l, cb)
398      {
399         if (!strcmp(cb->part, en->rp->part->name))
400           {
401              cb->func(cb->data, en->rp->edje->obj, cb->part, &text);
402              if (!text) break;
403           }
404      }
405 #ifdef HAVE_ECORE_IMF
406    // For skipping useless commit
407    if (en->have_preedit && (!text || !strcmp(text, "")))
408      en->commit_cancel = EINA_TRUE;
409    else
410      en->commit_cancel = EINA_FALSE;
411 #endif
412    if (text)
413      {
414         evas_object_textblock_text_markup_prepend(c, text);
415         free(text);
416      }
417 }
418
419 static void
420 _text_filter_text_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
421 {
422    char *text2;
423    Edje_Text_Insert_Filter_Callback *cb;
424    Eina_List *l;
425
426    text2 = strdup(text);
427    EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
428      {
429         if (!strcmp(cb->part, en->rp->part->name))
430           {
431              cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2);
432              if (!text2) break;
433           }
434      }
435    if (text2)
436      {
437         char *markup_text;
438         markup_text = evas_textblock_text_utf8_to_markup(NULL, text2);
439         free(text2);
440         if (markup_text)
441           _text_filter_markup_prepend_internal(en, c, markup_text);
442      }
443 }
444
445 static void
446 _text_filter_format_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
447 {
448    char *text2;
449    Edje_Text_Insert_Filter_Callback *cb;
450    Eina_List *l;
451
452    text2 = strdup(text);
453    EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
454      {
455         if (!strcmp(cb->part, en->rp->part->name))
456           {
457              cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2);
458              if (!text2) break;
459           }
460      }
461    if (text2)
462      {
463         char *s, *markup_text;
464
465         s = text2;
466         if (*s == '+')
467           {
468              s++;
469              while (*s == ' ') s++;
470              if (!s)
471                {
472                   free(text2);
473                   return;
474                }
475              markup_text = (char*) malloc(strlen(s) + 3);
476              if (markup_text)
477                {
478                   *(markup_text) = '<';
479                   strncpy((markup_text + 1), s, strlen(s));
480                   *(markup_text + strlen(s) + 1) = '>';
481                   *(markup_text + strlen(s) + 2) = '\0';
482                }
483           }
484         else if (s[0] == '-')
485           {
486              s++;
487              while (*s == ' ') s++;
488              if (!s)
489                {
490                   free(text2);
491                   return;
492                }
493              markup_text = (char*) malloc(strlen(s) + 4);
494              if (markup_text)
495                {
496                   *(markup_text) = '<';
497                   *(markup_text + 1) = '/';
498                   strncpy((markup_text + 2), s, strlen(s));
499                   *(markup_text + strlen(s) + 2) = '>';
500                   *(markup_text + strlen(s) + 3) = '\0';
501                }
502           }
503         else
504           {
505              markup_text = (char*) malloc(strlen(s) + 4);
506              if (markup_text)
507                {
508                   *(markup_text) = '<';
509                   strncpy((markup_text + 1), s, strlen(s));
510                   *(markup_text + strlen(s) + 1) = '/';
511                   *(markup_text + strlen(s) + 2) = '>';
512                   *(markup_text + strlen(s) + 3) = '\0';
513                }
514           }
515         free(text2);
516         if (markup_text)
517           _text_filter_markup_prepend_internal(en, c, markup_text);
518      }
519 }
520
521 static void
522 _text_filter_markup_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
523 {
524    char *text2;
525    Edje_Text_Insert_Filter_Callback *cb;
526    Eina_List *l;
527
528    text2 = strdup(text);
529    EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
530      {
531         if (!strcmp(cb->part, en->rp->part->name))
532           {
533              cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2);
534              if (!text2) break;
535           }
536      }
537    if (text2)
538      _text_filter_markup_prepend_internal(en, c, text2);
539 }
540
541 static void
542 _curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en, Evas_Coord *cx, Evas_Coord *cy)
543 {
544    Evas_Coord cw, ch;
545    Evas_Textblock_Cursor_Type cur_type;
546    if (c != en->cursor) return;
547    switch (en->rp->part->cursor_mode)
548      {
549       case EDJE_ENTRY_CURSOR_MODE_BEFORE:
550          cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
551          break;
552       case EDJE_ENTRY_CURSOR_MODE_UNDER:
553          /* no break for a resaon */
554       default:
555          cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
556      }
557    evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type);
558    *cx += (cw / 2);
559    *cy += (ch / 2);
560 }
561
562 static int
563 _curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
564 {
565    Evas_Textblock_Cursor *cc;
566    int ln;
567
568    cc = evas_object_textblock_cursor_new(o);
569    evas_textblock_cursor_paragraph_last(cc);
570    ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL);
571    evas_textblock_cursor_free(cc);
572    return ln;
573 }
574
575 static void
576 _curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
577                 Entry *en __UNUSED__)
578 {
579    evas_textblock_cursor_line_char_first(c);
580 }
581
582 static void
583 _curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
584               Entry *en __UNUSED__)
585 {
586    evas_textblock_cursor_line_char_last(c);
587 }
588
589 static void
590 _curs_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
591             Entry *en __UNUSED__)
592 {
593    evas_textblock_cursor_paragraph_first(c);
594 }
595
596 static void
597 _curs_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__)
598 {
599    evas_textblock_cursor_paragraph_last(c);
600 }
601
602 static Eina_Bool
603 _curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
604 {
605    Evas_Coord cx, cy;
606    Evas_Coord lx, ly, lw, lh;
607    int last = _curs_line_last_get(c, o, en);
608
609    if (ln < 0) return EINA_FALSE;
610    if (ln > last) return EINA_FALSE;
611
612    _curs_update_from_curs(c, o, en, &cx, &cy);
613
614    if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
615      return EINA_FALSE;
616    if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
617      return EINA_TRUE;
618    evas_textblock_cursor_line_set(c, ln);
619    if (cx < (lx + (lw / 2)))
620      {
621         if (ln == last) _curs_end(c, o, en);
622         _curs_lin_start(c, o, en);
623      }
624    else
625      {
626         if (ln == last)
627           _curs_end(c, o, en);
628         else
629           _curs_lin_end(c, o, en);
630      }
631    return EINA_TRUE;
632 }
633
634 static Eina_Bool
635 _curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
636 {
637    int ln;
638
639    ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
640    return _curs_jump_line(c, o, en, ln);
641 }
642
643 static Eina_Bool
644 _curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
645 {
646    return _curs_jump_line_by(c, o, en, -1);
647 }
648
649 static Eina_Bool
650 _curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
651 {
652    return _curs_jump_line_by(c, o, en, 1);
653 }
654
655 static void
656 _sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
657 {
658    if (en->sel_start) return;
659    en->sel_start = evas_object_textblock_cursor_new(o);
660    evas_textblock_cursor_copy(c, en->sel_start);
661    en->sel_end = evas_object_textblock_cursor_new(o);
662    evas_textblock_cursor_copy(c, en->sel_end);
663
664    en->have_selection = EINA_FALSE;
665    if (en->selection)
666      {
667         free(en->selection);
668         en->selection = NULL;
669      }
670 }
671
672 static void
673 _sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
674 {
675    if (en->have_selection) return;
676    en->have_selection = EINA_TRUE;
677    if (en->selection)
678      {
679         free(en->selection);
680         en->selection = NULL;
681      }
682
683    _edje_entry_imf_context_reset(en->rp);
684    _edje_emit(en->rp->edje, "selection,start", en->rp->part->name);
685 }
686
687 static void
688 _sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
689 {
690    if (!en->sel_end) return;
691    _sel_enable(c, o, en);
692    if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
693
694    evas_textblock_cursor_copy(c, en->sel_end);
695
696    _edje_entry_imf_cursor_info_set(en);
697
698    if (en->selection)
699      {
700         free(en->selection);
701         en->selection = NULL;
702      }
703    _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
704    // TIZEN ONLY - start
705    if (en->cursor_handler_show)
706      {
707         evas_object_hide(en->cursor_handler);
708         en->cursor_handler_show = EINA_FALSE;
709      }
710    // TIZEN ONLY - end
711 }
712
713 static void
714 _sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
715 {
716    if (!en->sel_end) return;
717    _sel_enable(c, o, en);
718    if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
719
720    evas_textblock_cursor_copy(c, en->sel_start);
721
722    _edje_entry_imf_cursor_info_set(en);
723
724    if (en->selection)
725      {
726         free(en->selection);
727         en->selection = NULL;
728      }
729    _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
730    // TIZEN ONLY - start
731    if (en->cursor_handler_show)
732      {
733         evas_object_hide(en->cursor_handler);
734         en->cursor_handler_show = EINA_FALSE;
735      }
736    // TIZEN ONLY - end
737 }
738
739 static void
740 _sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
741 {
742    en->had_sel = EINA_FALSE;
743    if (en->sel_start)
744      {
745         evas_textblock_cursor_free(en->sel_start);
746         evas_textblock_cursor_free(en->sel_end);
747         en->sel_start = NULL;
748         en->sel_end = NULL;
749      }
750    if (en->selection)
751      {
752         free(en->selection);
753         en->selection = NULL;
754      }
755    while (en->sel)
756      {
757         Sel *sel;
758
759         sel = en->sel->data;
760         if (sel->obj_bg) evas_object_del(sel->obj_bg);
761         if (sel->obj_fg) evas_object_del(sel->obj_fg);
762
763         // TIZEN ONLY - START
764         if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
765           {
766              evas_object_hide(en->sel_handler_start);
767              evas_object_hide(en->sel_handler_end);
768
769              evas_object_hide(en->sel_handler_edge_start);
770              evas_object_hide(en->sel_handler_edge_end);
771           }
772         // TIZEN ONLY - END
773         free(sel);
774         en->sel = eina_list_remove_list(en->sel, en->sel);
775      }
776    if (en->have_selection)
777      {
778         en->have_selection = EINA_FALSE;
779         evas_object_show(en->cursor_fg);
780         _edje_emit(en->rp->edje, "selection,cleared", en->rp->part->name);
781      }
782 }
783
784 static void
785 _sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
786 {
787    Eina_List *range = NULL, *l;
788    Sel *sel;
789    Evas_Coord x, y, w, h;
790    Evas_Object *smart, *clip;
791
792    smart = evas_object_smart_parent_get(o);
793    clip = evas_object_clip_get(o);
794    if (en->sel_start)
795      {
796         range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end);
797         if (!range) return;
798      }
799    else
800      return;
801    if (eina_list_count(range) != eina_list_count(en->sel))
802      {
803         while (en->sel)
804           {
805              sel = en->sel->data;
806              if (sel->obj_bg) evas_object_del(sel->obj_bg);
807              if (sel->obj_fg) evas_object_del(sel->obj_fg);
808              free(sel);
809              en->sel = eina_list_remove_list(en->sel, en->sel);
810           }
811         if (en->have_selection)
812           {
813              for (l = range; l; l = eina_list_next(l))
814                {
815                   Evas_Object *ob;
816
817                   sel = calloc(1, sizeof(Sel));
818                   en->sel = eina_list_append(en->sel, sel);
819                   ob = edje_object_add(en->rp->edje->base.evas);
820                   edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source);
821                   evas_object_smart_member_add(ob, smart);
822                   evas_object_stack_below(ob, o);
823                   evas_object_clip_set(ob, clip);
824                   evas_object_pass_events_set(ob, EINA_TRUE);
825                   evas_object_show(ob);
826                   sel->obj_bg = ob;
827                   _edje_subobj_register(en->rp->edje, sel->obj_bg);
828
829                   ob = edje_object_add(en->rp->edje->base.evas);
830                   edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source2);
831                   evas_object_smart_member_add(ob, smart);
832                   evas_object_stack_above(ob, o);
833                   evas_object_clip_set(ob, clip);
834                   evas_object_pass_events_set(ob, EINA_TRUE);
835                   evas_object_show(ob);
836                   sel->obj_fg = ob;
837                   _edje_subobj_register(en->rp->edje, sel->obj_fg);
838                }
839           }
840      }
841    x = y = w = h = -1;
842    evas_object_geometry_get(o, &x, &y, &w, &h);
843    if (en->have_selection)
844      {
845         // TIZEN ONLY - START
846         int list_cnt, list_idx;
847
848         list_cnt = eina_list_count(en->sel);
849         list_idx = 0;
850         evas_object_hide(en->cursor_fg);
851         evas_object_hide(en->cursor_bg);
852         // TIZEN ONLY - END
853
854         EINA_LIST_FOREACH(en->sel, l, sel)
855           {
856              Evas_Textblock_Rectangle *r;
857              list_idx++; // TIZEN ONLY
858
859              r = range->data;
860              if (sel->obj_bg)
861                {
862                   evas_object_move(sel->obj_bg, x + r->x, y + r->y);
863                   evas_object_resize(sel->obj_bg, r->w, r->h);
864                }
865              if (sel->obj_fg)
866                {
867                   evas_object_move(sel->obj_fg, x + r->x, y + r->y);
868                   evas_object_resize(sel->obj_fg, r->w, r->h);
869                }
870              // TIZEN ONLY - START
871              if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
872                {
873                   int fh_idx, eh_idx;
874                   const char *gc = edje_object_data_get(en->sel_handler_start, "gap");
875                   int bh_gap = 0;
876                   if (gc) bh_gap = atoi(gc);
877
878                   if (en->handler_bypassing)
879                     {
880                        fh_idx = list_cnt;
881                        eh_idx = 1;
882                     }
883                   else
884                     {
885                        fh_idx = 1;
886                        eh_idx = list_cnt;
887                     }
888
889                   if (list_idx == fh_idx)
890                     {
891                        Evas_Coord nx, ny, handler_height = 0;
892                        Evas_Coord edge_w;
893                        edje_object_part_geometry_get(en->sel_handler_start, "handle", NULL, NULL, NULL, &handler_height);
894
895                        //keep same touch pos when by passing
896                        if (en->handler_bypassing)
897                          {
898                             nx = x + r->x + r->w;
899                             ny = y + r->y;
900                          }
901                        else
902                          {
903                             nx = x + r->x;
904                             ny = y + r->y;
905                          }
906                        evas_object_hide(en->sel_handler_start);
907
908                        edje_object_size_min_calc(en->sel_handler_edge_start, &edge_w, NULL);
909                        evas_object_move(en->sel_handler_edge_start, nx, ny);
910                        evas_object_resize(en->sel_handler_edge_start, edge_w, r->h);
911
912                        evas_object_hide(en->sel_handler_edge_start);
913
914                        // if viewport region is not set, show handlers
915                        if (en->viewport_region.x == -1 && en->viewport_region.y == -1 &&
916                            en->viewport_region.w == -1 && en->viewport_region.h == -1)
917                          {
918                             evas_object_hide(en->sel_handler_start);
919                             evas_object_move(en->sel_handler_start, nx, ny);
920                             edje_object_signal_emit(en->sel_handler_start, "elm,state,top", "elm");
921                             evas_object_show(en->sel_handler_start);
922
923                             evas_object_show(en->sel_handler_edge_start);
924                          }
925                        else
926                          {
927                             if ((en->viewport_region.w > 0 && en->viewport_region.h > 0) &&
928                                 (nx >= en->viewport_region.x) && (nx <= (en->viewport_region.x + en->viewport_region.w)) &&
929                                 (ny >= en->viewport_region.y) && (ny <= (en->viewport_region.y + en->viewport_region.h)))
930                               {
931                                  if (en->layout_region.w != -1 && en->layout_region.h != -1 &&
932                                      ((ny - handler_height) > en->layout_region.y))
933                                    {
934                                       evas_object_move(en->sel_handler_start, nx, ny);
935                                       if (nx <= en->layout_region.x + bh_gap)
936                                          edje_object_signal_emit(en->sel_handler_start, "elm,state,top,reversed", "elm");
937                                       else
938                                          edje_object_signal_emit(en->sel_handler_start, "elm,state,top", "elm");
939                                    }
940                                  else
941                                    {
942                                       evas_object_move(en->sel_handler_start, nx, ny + r->h);
943                                       if (nx <= en->layout_region.x + bh_gap)
944                                          edje_object_signal_emit(en->sel_handler_start, "elm,state,bottom,reversed", "elm");
945                                       else
946                                          edje_object_signal_emit(en->sel_handler_start, "elm,state,bottom", "elm");
947                                    }
948
949                                  evas_object_show(en->sel_handler_start);
950                                  evas_object_show(en->sel_handler_edge_start);
951                               }
952                          }
953                     }
954                   if (list_idx == eh_idx)
955                     {
956                        Evas_Coord nx, ny, handler_height = 0;
957                        Evas_Coord edge_w;
958
959                        edje_object_part_geometry_get(en->sel_handler_end, "handle", NULL, NULL, NULL, &handler_height);
960
961                        //keep pos when bypassing
962                        if (en->handler_bypassing)
963                          {
964                             nx = x + r->x;
965                             ny = y + r->y + r->h;
966                          }
967                        else
968                          {
969                             nx = x + r->x + r->w;
970                             ny = y + r->y + r->h;
971                          }
972
973                        evas_object_hide(en->sel_handler_end);
974
975                        edje_object_size_min_calc(en->sel_handler_edge_end, &edge_w, NULL);
976                        evas_object_move(en->sel_handler_edge_end, nx, ny - r->h);
977                        evas_object_resize(en->sel_handler_edge_end, edge_w, r->h);
978
979                        evas_object_hide(en->sel_handler_edge_end);
980
981                        // if viewport region is not set, show handlers
982                        if (en->viewport_region.x == -1 && en->viewport_region.y == -1 &&
983                            en->viewport_region.w == -1 && en->viewport_region.h == -1)
984                          {
985                             evas_object_move(en->sel_handler_end, nx, ny);
986                             evas_object_move(en->sel_handler_end, nx, ny);
987                             edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom", "elm");
988                             evas_object_show(en->sel_handler_end);
989
990                             evas_object_show(en->sel_handler_edge_end);
991                          }
992                        else
993                          {
994                             if ((en->viewport_region.w > 0 && en->viewport_region.h > 0) &&
995                                 (nx >= en->viewport_region.x) && (nx <= (en->viewport_region.x + en->viewport_region.w)) &&
996                                 (ny >= en->viewport_region.y) && (ny <= (en->viewport_region.y + en->viewport_region.h)))
997                               {
998                                  evas_object_move(en->sel_handler_end, nx, ny - r->h);
999                                  if (en->layout_region.w != -1 && en->layout_region.h != -1 &&
1000                                      ((ny + handler_height) > (en->layout_region.y + en->layout_region.h)))
1001                                    {
1002                                       if (nx >= en->layout_region.w - bh_gap)
1003                                          edje_object_signal_emit(en->sel_handler_end, "elm,state,top,reversed", "elm");
1004                                       else
1005                                          edje_object_signal_emit(en->sel_handler_end, "elm,state,top", "elm");
1006                                    }
1007                                  else
1008                                    {
1009                                       evas_object_move(en->sel_handler_end, nx, ny);
1010
1011                                       if (nx >= en->layout_region.w - bh_gap)
1012                                          edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom,reversed", "elm");
1013                                       else
1014                                          edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom", "elm");
1015                                    }
1016
1017                                  evas_object_show(en->sel_handler_end);
1018
1019                                  evas_object_show(en->sel_handler_edge_end);
1020                               }
1021                          }
1022                     }
1023                }
1024              // TIZEN ONLY - END
1025
1026              *(&(sel->rect)) = *r;
1027              range = eina_list_remove_list(range, range);
1028              free(r);
1029           }
1030      }
1031    else
1032      {
1033         while (range)
1034           {
1035              free(range->data);
1036              range = eina_list_remove_list(range, range);
1037           }
1038      }
1039 }
1040
1041 static void
1042 _edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1043 {
1044    Anchor *an = data;
1045    Evas_Event_Mouse_Down *ev = event_info;
1046    Edje_Real_Part *rp = an->en->rp;
1047    char *buf, *n;
1048    size_t len;
1049    int ignored;
1050    Entry *en;
1051
1052    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1053        (!rp->typedata.text)) return;
1054    en = rp->typedata.text->entry_data;
1055    if (((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
1056         (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)) &&
1057        (en->select_allow))
1058      return;
1059    ignored = rp->part->ignore_flags & ev->event_flags;
1060    if ((!ev->event_flags) || (!ignored))
1061      {
1062         n = an->name;
1063         if (!n) n = "";
1064         len = 200 + strlen(n);
1065         buf = alloca(len);
1066         if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
1067           snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, n);
1068         else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1069           snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, n);
1070         else
1071           snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
1072         _edje_emit(rp->edje, buf, rp->part->name);
1073      }
1074 }
1075
1076 static void
1077 _edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1078 {
1079    Anchor *an = data;
1080    Evas_Event_Mouse_Up *ev = event_info;
1081    Edje_Real_Part *rp = an->en->rp;
1082    char *buf, *n;
1083    size_t len;
1084    int ignored;
1085    Entry *en;
1086
1087    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1088        (!rp->typedata.text)) return;
1089    en = rp->typedata.text->entry_data;
1090    ignored = rp->part->ignore_flags & ev->event_flags;
1091    if (((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
1092         (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)) &&
1093        (en->select_allow))
1094      return;
1095    n = an->name;
1096    if (!n) n = "";
1097    len = 200 + strlen(n);
1098    buf = alloca(len);
1099    if ((!ev->event_flags) || (!ignored))
1100      {
1101         snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n);
1102         _edje_emit(rp->edje, buf, rp->part->name);
1103      }
1104    if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
1105      {
1106         snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
1107         _edje_emit(rp->edje, buf, rp->part->name);
1108      }
1109 }
1110
1111 static void
1112 _edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1113 {
1114    Anchor *an = data;
1115    Evas_Event_Mouse_Move *ev = event_info;
1116    Edje_Real_Part *rp = an->en->rp;
1117    char *buf, *n;
1118    size_t len;
1119    int ignored;
1120    Entry *en;
1121
1122    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1123        (!rp->typedata.text)) return;
1124    en = rp->typedata.text->entry_data;
1125    if (((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
1126         (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)) &&
1127        (en->select_allow))
1128      return;
1129    ignored = rp->part->ignore_flags & ev->event_flags;
1130    if ((!ev->event_flags) || (!ignored))
1131      {
1132         n = an->name;
1133         if (!n) n = "";
1134         len = 200 + strlen(n);
1135         buf = alloca(len);
1136         snprintf(buf, len, "anchor,mouse,move,%s", n);
1137         _edje_emit(rp->edje, buf, rp->part->name);
1138      }
1139 }
1140
1141 static void
1142 _edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1143 {
1144    Anchor *an = data;
1145    Evas_Event_Mouse_In *ev = event_info;
1146    Edje_Real_Part *rp = an->en->rp;
1147    char *buf, *n;
1148    size_t len;
1149    int ignored;
1150
1151    ignored = rp->part->ignore_flags & ev->event_flags;
1152    if ((!ev->event_flags) || (!ignored))
1153      {
1154         n = an->name;
1155         if (!n) n = "";
1156         len = 200 + strlen(n);
1157         buf = alloca(len);
1158         snprintf(buf, len, "anchor,mouse,in,%s", n);
1159         _edje_emit(rp->edje, buf, rp->part->name);
1160      }
1161 }
1162
1163 static void
1164 _edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1165 {
1166    Anchor *an = data;
1167    Evas_Event_Mouse_Out *ev = event_info;
1168    Edje_Real_Part *rp = an->en->rp;
1169    char *buf, *n;
1170    size_t len;
1171    int ignored;
1172
1173    ignored = rp->part->ignore_flags & ev->event_flags;
1174    if ((!ev->event_flags) || (!ignored))
1175      {
1176         n = an->name;
1177         if (!n) n = "";
1178         len = 200 + strlen(n);
1179         buf = alloca(len);
1180         snprintf(buf, len, "anchor,mouse,out,%s", n);
1181         _edje_emit(rp->edje, buf, rp->part->name);
1182      }
1183 }
1184
1185 static void
1186 _anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
1187 {
1188    Eina_List *l, *ll, *range = NULL;
1189    Evas_Coord x, y, w, h;
1190    Evas_Object *smart, *clip;
1191    Sel *sel;
1192    Anchor *an;
1193
1194    smart = evas_object_smart_parent_get(o);
1195    clip = evas_object_clip_get(o);
1196    x = y = w = h = -1;
1197    evas_object_geometry_get(o, &x, &y, &w, &h);
1198    EINA_LIST_FOREACH(en->anchors, l, an)
1199      {
1200         // for item anchors
1201         if (an->item)
1202           {
1203              Evas_Object *ob;
1204
1205              if (!an->sel)
1206                {
1207                   while (an->sel)
1208                     {
1209                        sel = an->sel->data;
1210                        if (sel->obj_bg) evas_object_del(sel->obj_bg);
1211                        if (sel->obj_fg) evas_object_del(sel->obj_fg);
1212                        if (sel->obj) evas_object_del(sel->obj);
1213                        free(sel);
1214                        an->sel = eina_list_remove_list(an->sel, an->sel);
1215                     }
1216
1217                   sel = calloc(1, sizeof(Sel));
1218                   an->sel = eina_list_append(an->sel, sel);
1219
1220                   if (en->rp->edje->item_provider.func)
1221                     {
1222                        ob = en->rp->edje->item_provider.func
1223                          (en->rp->edje->item_provider.data, smart,
1224                              en->rp->part->name, an->name);
1225                        evas_object_smart_member_add(ob, smart);
1226                        evas_object_stack_above(ob, o);
1227                        evas_object_clip_set(ob, clip);
1228                        evas_object_pass_events_set(ob, EINA_TRUE);
1229                        evas_object_show(ob);
1230                        sel->obj = ob;
1231                     }
1232                }
1233           }
1234         // for link anchors
1235         else
1236           {
1237              range =
1238                evas_textblock_cursor_range_geometry_get(an->start, an->end);
1239              if (eina_list_count(range) != eina_list_count(an->sel))
1240                {
1241                   while (an->sel)
1242                     {
1243                        sel = an->sel->data;
1244                        if (sel->obj_bg) evas_object_del(sel->obj_bg);
1245                        if (sel->obj_fg) evas_object_del(sel->obj_fg);
1246                        if (sel->obj) evas_object_del(sel->obj);
1247                        free(sel);
1248                        an->sel = eina_list_remove_list(an->sel, an->sel);
1249                     }
1250                   for (ll = range; ll; ll = eina_list_next(ll))
1251                     {
1252                        Evas_Object *ob;
1253
1254                        sel = calloc(1, sizeof(Sel));
1255                        an->sel = eina_list_append(an->sel, sel);
1256                        ob = edje_object_add(en->rp->edje->base.evas);
1257                        edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source5);
1258                        evas_object_smart_member_add(ob, smart);
1259                        evas_object_stack_below(ob, o);
1260                        evas_object_clip_set(ob, clip);
1261                        evas_object_pass_events_set(ob, EINA_TRUE);
1262                        evas_object_show(ob);
1263                        sel->obj_bg = ob;
1264                        _edje_subobj_register(en->rp->edje, sel->obj_bg);
1265
1266                        ob = edje_object_add(en->rp->edje->base.evas);
1267                        edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source6);
1268                        evas_object_smart_member_add(ob, smart);
1269                        evas_object_stack_above(ob, o);
1270                        evas_object_clip_set(ob, clip);
1271                        evas_object_pass_events_set(ob, EINA_TRUE);
1272                        evas_object_show(ob);
1273                        sel->obj_fg = ob;
1274                        _edje_subobj_register(en->rp->edje, sel->obj_fg);
1275
1276                        ob = evas_object_rectangle_add(en->rp->edje->base.evas);
1277                        evas_object_color_set(ob, 0, 0, 0, 0);
1278                        evas_object_smart_member_add(ob, smart);
1279                        evas_object_stack_above(ob, o);
1280                        evas_object_clip_set(ob, clip);
1281                        evas_object_repeat_events_set(ob, EINA_TRUE);
1282                        evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an);
1283                        evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an);
1284                        evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an);
1285                        evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an);
1286                        evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an);
1287                        evas_object_show(ob);
1288                        sel->obj = ob;
1289                     }
1290                }
1291           }
1292         EINA_LIST_FOREACH(an->sel, ll, sel)
1293           {
1294              if (an->item)
1295                {
1296                   Evas_Coord cx, cy, cw, ch;
1297
1298                   if (!evas_textblock_cursor_format_item_geometry_get
1299                       (an->start, &cx, &cy, &cw, &ch))
1300                     continue;
1301                   evas_object_move(sel->obj, x + cx, y + cy);
1302                   evas_object_resize(sel->obj, cw, ch);
1303                }
1304              else
1305                {
1306                   Evas_Textblock_Rectangle *r;
1307
1308                   r = range->data;
1309                   *(&(sel->rect)) = *r;
1310                   if (sel->obj_bg)
1311                     {
1312                        evas_object_move(sel->obj_bg, x + r->x, y + r->y);
1313                        evas_object_resize(sel->obj_bg, r->w, r->h);
1314                     }
1315                   if (sel->obj_fg)
1316                     {
1317                        evas_object_move(sel->obj_fg, x + r->x, y + r->y);
1318                        evas_object_resize(sel->obj_fg, r->w, r->h);
1319                     }
1320                   if (sel->obj)
1321                     {
1322                        evas_object_move(sel->obj, x + r->x, y + r->y);
1323                        evas_object_resize(sel->obj, r->w, r->h);
1324                     }
1325                   range = eina_list_remove_list(range, range);
1326                   free(r);
1327                }
1328           }
1329      }
1330 }
1331
1332 static void
1333 _anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1334 {
1335    while (en->anchorlist)
1336      {
1337         free(en->anchorlist->data);
1338         en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
1339      }
1340    while (en->itemlist)
1341      {
1342         free(en->itemlist->data);
1343         en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
1344      }
1345    while (en->anchors)
1346      {
1347         Anchor *an = en->anchors->data;
1348
1349         evas_textblock_cursor_free(an->start);
1350         evas_textblock_cursor_free(an->end);
1351         while (an->sel)
1352           {
1353              Sel *sel = an->sel->data;
1354              if (sel->obj_bg) evas_object_del(sel->obj_bg);
1355              if (sel->obj_fg) evas_object_del(sel->obj_fg);
1356              if (sel->obj) evas_object_del(sel->obj);
1357              free(sel);
1358              an->sel = eina_list_remove_list(an->sel, an->sel);
1359           }
1360         free(an->name);
1361         free(an);
1362         en->anchors = eina_list_remove_list(en->anchors, en->anchors);
1363      }
1364 }
1365
1366 static void
1367 _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1368 {
1369    const Eina_List *anchors_a, *anchors_item;
1370    Anchor *an = NULL;
1371    _anchors_clear(c, o, en);
1372
1373    anchors_a = evas_textblock_node_format_list_get(o, "a");
1374    anchors_item = evas_textblock_node_format_list_get(o, "item");
1375
1376    if (anchors_a)
1377      {
1378         const Evas_Object_Textblock_Node_Format *node;
1379         const Eina_List *itr;
1380         EINA_LIST_FOREACH(anchors_a, itr, node)
1381           {
1382              const char *s = evas_textblock_node_format_text_get(node);
1383              char *p;
1384              an = calloc(1, sizeof(Anchor));
1385              if (!an)
1386                break;
1387
1388              an->en = en;
1389              p = strstr(s, "href=");
1390              if (p)
1391                {
1392                   an->name = strdup(p + 5);
1393                }
1394              en->anchors = eina_list_append(en->anchors, an);
1395              an->start = evas_object_textblock_cursor_new(o);
1396              an->end = evas_object_textblock_cursor_new(o);
1397              evas_textblock_cursor_at_format_set(an->start, node);
1398              evas_textblock_cursor_copy(an->start, an->end);
1399
1400              /* Close the anchor, if the anchor was without text,
1401               * free it as well */
1402              node = evas_textblock_node_format_next_get(node);
1403              for (; node; node = evas_textblock_node_format_next_get(node))
1404                {
1405                   s = evas_textblock_node_format_text_get(node);
1406                   if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
1407                     break;
1408                }
1409
1410              if (node)
1411                {
1412                   evas_textblock_cursor_at_format_set(an->end, node);
1413                }
1414              else if (!evas_textblock_cursor_compare(an->start, an->end))
1415                {
1416                   if (an->name) free(an->name);
1417                   evas_textblock_cursor_free(an->start);
1418                   evas_textblock_cursor_free(an->end);
1419                   en->anchors = eina_list_remove(en->anchors, an);
1420                   free(an);
1421                }
1422              an = NULL;
1423           }
1424      }
1425
1426    if (anchors_item)
1427      {
1428         const Evas_Object_Textblock_Node_Format *node;
1429         const Eina_List *itr;
1430         EINA_LIST_FOREACH(anchors_item, itr, node)
1431           {
1432              const char *s = evas_textblock_node_format_text_get(node);
1433              char *p;
1434              an = calloc(1, sizeof(Anchor));
1435              if (!an)
1436                break;
1437
1438              an->en = en;
1439              an->item = 1;
1440              p = strstr(s, "href=");
1441              if (p)
1442                {
1443                   an->name = strdup(p + 5);
1444                }
1445              en->anchors = eina_list_append(en->anchors, an);
1446              an->start = evas_object_textblock_cursor_new(o);
1447              an->end = evas_object_textblock_cursor_new(o);
1448              evas_textblock_cursor_at_format_set(an->start, node);
1449              evas_textblock_cursor_copy(an->start, an->end);
1450              /* Although needed in textblock, don't bother with finding the end
1451               * here cause it doesn't really matter. */
1452           }
1453      }
1454 }
1455
1456 static void
1457 _free_entry_change_info(void *_info)
1458 {
1459    Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
1460    if (info->insert)
1461      {
1462         eina_stringshare_del(info->change.insert.content);
1463      }
1464    else
1465      {
1466         eina_stringshare_del(info->change.del.content);
1467      }
1468    free(info);
1469 }
1470
1471 static void
1472 _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1473 {
1474    size_t start, end;
1475    char *tmp;
1476    Edje_Entry_Change_Info *info;
1477
1478    start = evas_textblock_cursor_pos_get(en->sel_start);
1479    end = evas_textblock_cursor_pos_get(en->sel_end);
1480    if (start == end)
1481       goto noop;
1482
1483    info = calloc(1, sizeof(*info));
1484    info->insert = EINA_FALSE;
1485    info->change.del.start = start;
1486    info->change.del.end = end;
1487
1488    tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
1489    info->change.del.content = eina_stringshare_add(tmp);
1490    if (tmp) free(tmp);
1491    evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1492    _edje_emit(ed, "entry,changed", en->rp->part->name);
1493    _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
1494                    _free_entry_change_info);
1495 noop:
1496    _sel_clear(en->cursor, en->rp->object, en);
1497 }
1498
1499 static void
1500 _range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1501 {
1502    evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1503    _sel_clear(en->cursor, en->rp->object, en);
1504 }
1505
1506 static void
1507 _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1508              Eina_Bool backspace)
1509 {
1510    if (!evas_textblock_cursor_char_next(c))
1511      {
1512         return;
1513      }
1514    evas_textblock_cursor_char_prev(c);
1515
1516    Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1517    char *tmp = evas_textblock_cursor_content_get(c);
1518
1519    info->insert = EINA_FALSE;
1520    if (backspace)
1521      {
1522         info->change.del.start = pos - 1;
1523         info->change.del.end = pos;
1524      }
1525    else
1526      {
1527         info->change.del.start = pos + 1;
1528         info->change.del.end = pos;
1529      }
1530
1531    info->change.del.content = eina_stringshare_add(tmp);
1532    if (tmp) free(tmp);
1533
1534    evas_textblock_cursor_char_delete(c);
1535    _edje_emit(ed, "entry,changed", en->rp->part->name);
1536    _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1537                    info, _free_entry_change_info);
1538 }
1539
1540 static void
1541 _edje_entry_hide_visible_password(Edje_Real_Part *rp)
1542 {
1543    const Evas_Object_Textblock_Node_Format *node;
1544    node = evas_textblock_node_format_first_get(rp->object);
1545    for (; node; node = evas_textblock_node_format_next_get(node))
1546      {
1547         const char *text = evas_textblock_node_format_text_get(node);
1548         if (text)
1549           {
1550              if (!strcmp(text, "+ password=off"))
1551                {
1552                   evas_textblock_node_format_remove_pair(rp->object,
1553                                                          (Evas_Object_Textblock_Node_Format *) node);
1554                   break;
1555                }
1556           }
1557      }
1558    _edje_entry_real_part_configure(rp);
1559    _edje_emit(rp->edje, "entry,changed", rp->part->name);
1560 }
1561
1562 static Eina_Bool
1563 _password_timer_cb(void *data)
1564 {
1565    Entry *en = (Entry *)data;
1566    _edje_entry_hide_visible_password(en->rp);
1567    en->pw_timer = NULL;
1568    return ECORE_CALLBACK_CANCEL;
1569 }
1570
1571 static Eina_Bool
1572 _is_modifier(const char *key)
1573 {
1574    if ((!strncmp(key, "Shift", 5)) ||
1575        (!strncmp(key, "Control", 7)) ||
1576        (!strncmp(key, "Alt", 3)) ||
1577        (!strncmp(key, "Meta", 4)) ||
1578        (!strncmp(key, "Super", 5)) ||
1579        (!strncmp(key, "Hyper", 5)) ||
1580        (!strcmp(key, "Scroll_Lock")) ||
1581        (!strcmp(key, "Num_Lock")) ||
1582        (!strcmp(key, "Caps_Lock")))
1583      return EINA_TRUE;
1584    return EINA_FALSE;
1585 }
1586
1587 static void
1588 _compose_seq_reset(Entry *en)
1589 {
1590    char *str;
1591    
1592    EINA_LIST_FREE(en->seq, str) eina_stringshare_del(str);
1593    en->composing = EINA_FALSE;
1594 }
1595
1596 static void
1597 _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1598 {
1599    Edje *ed = data;
1600    Evas_Event_Key_Down *ev = event_info;
1601    Edje_Real_Part *rp = ed->focused_part;
1602    Entry *en;
1603    Eina_Bool control, alt, shift;
1604    Eina_Bool multiline;
1605    Eina_Bool cursor_changed;
1606    int old_cur_pos;
1607    if (!rp) return;
1608    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1609        (!rp->typedata.text)) return;
1610    en = rp->typedata.text->entry_data;
1611    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1612        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1613      return;
1614    if (!ev->keyname) return;
1615
1616    // TIZEN ONLY - START
1617    if (en->cursor_handler_show)
1618      {
1619         evas_object_hide(en->cursor_handler);
1620         en->cursor_handler_show = EINA_FALSE;
1621      }
1622    // TIZEN ONLY - END
1623
1624 #ifdef HAVE_ECORE_IMF
1625    if (en->imf_context)
1626      {
1627         Ecore_IMF_Event_Key_Down ecore_ev;
1628         Eina_Bool filter_ret;
1629         ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
1630         if (!en->composing)
1631           {
1632              filter_ret = ecore_imf_context_filter_event(en->imf_context,
1633                                                          ECORE_IMF_EVENT_KEY_DOWN,
1634                                                          (Ecore_IMF_Event *)&ecore_ev);
1635
1636              if (en->have_preedit)
1637                {
1638                   if (!strcmp(ev->keyname, "Down") ||
1639                       (!strcmp(ev->keyname, "KP_Down") && !ev->string) ||
1640                       !strcmp(ev->keyname, "Up") ||
1641                       (!strcmp(ev->keyname, "KP_Up") && !ev->string) ||
1642                       !strcmp(ev->keyname, "Next") ||
1643                       (!strcmp(ev->keyname, "KP_Next") && !ev->string) ||
1644                       !strcmp(ev->keyname, "Prior") ||
1645                       (!strcmp(ev->keyname, "KP_Prior") && !ev->string) ||
1646                       !strcmp(ev->keyname, "Home") ||
1647                       (!strcmp(ev->keyname, "KP_Home") && !ev->string) ||
1648                       !strcmp(ev->keyname, "End") ||
1649                       (!strcmp(ev->keyname, "KP_End") && !ev->string))
1650                     ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1651                }
1652
1653              if (filter_ret)
1654                return;
1655           }
1656      }
1657 #endif
1658
1659    old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1660
1661    control = evas_key_modifier_is_set(ev->modifiers, "Control");
1662    alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
1663    shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1664    multiline = rp->part->multiline;
1665    cursor_changed = EINA_FALSE;
1666    if (!strcmp(ev->keyname, "Escape"))
1667      {
1668         _compose_seq_reset(en);
1669         // dead keys here. Escape for now (should emit these)
1670         _edje_emit(ed, "entry,key,escape", rp->part->name);
1671         // TIZEN ONLY (20130327) : This code is doing nothing for entry now.
1672         //                         And for Tizen "ESC" is used for another purpose.
1673         //ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1674      }
1675    else if (!strcmp(ev->keyname, "Up") ||
1676             (!strcmp(ev->keyname, "KP_Up") && !ev->string))
1677      {
1678         _compose_seq_reset(en);
1679         if (multiline)
1680           {
1681              if (en->have_selection &&
1682                  (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1683                ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1684              if (en->select_allow)
1685                {
1686                   if (shift)
1687                     {
1688                        _sel_start(en->cursor, rp->object, en);
1689                        ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1690                     }
1691                   else _sel_clear(en->cursor, rp->object, en);
1692                }
1693              if (_curs_up(en->cursor, rp->object, en))
1694                ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1695              if (en->select_allow)
1696                {
1697                   if (shift) _sel_extend(en->cursor, rp->object, en);
1698                   else _sel_clear(en->cursor, rp->object, en);
1699                }
1700           }
1701         _edje_emit(ed, "entry,key,up", rp->part->name);
1702         _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1703      }
1704    else if (!strcmp(ev->keyname, "Down") ||
1705             (!strcmp(ev->keyname, "KP_Down") && !ev->string))
1706      {
1707         _compose_seq_reset(en);
1708         if (multiline)
1709           {
1710              if (en->have_selection &&
1711                  (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1712                ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1713              if (en->select_allow)
1714                {
1715                   if (shift)
1716                     {
1717                        _sel_start(en->cursor, rp->object, en);
1718                        ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1719                     }
1720                   else _sel_clear(en->cursor, rp->object, en);
1721                }
1722              if (_curs_down(en->cursor, rp->object, en))
1723                ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1724              if (en->select_allow)
1725                {
1726                   if (shift) _sel_extend(en->cursor, rp->object, en);
1727                   else _sel_clear(en->cursor, rp->object, en);
1728                }
1729           }
1730         _edje_emit(ed, "entry,key,down", rp->part->name);
1731         _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1732      }
1733    else if (!strcmp(ev->keyname, "Left") ||
1734             (!strcmp(ev->keyname, "KP_Left") && !ev->string))
1735      {
1736         _compose_seq_reset(en);
1737         if (en->have_selection &&
1738             (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1739           ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1740         if (en->select_allow)
1741           {
1742              if (shift)
1743                {
1744                   _sel_start(en->cursor, rp->object, en);
1745                   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1746                }
1747              else _sel_clear(en->cursor, rp->object, en);
1748           }
1749         if (evas_textblock_cursor_char_prev(en->cursor))
1750           ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1751         /* If control is pressed, go to the start of the word */
1752         if (control) evas_textblock_cursor_word_start(en->cursor);
1753         if (en->select_allow)
1754           {
1755              if (shift) _sel_extend(en->cursor, rp->object, en);
1756              else _sel_clear(en->cursor, rp->object, en);
1757           }
1758         _edje_emit(ed, "entry,key,left", rp->part->name);
1759         _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1760      }
1761    else if (!strcmp(ev->keyname, "Right") ||
1762             (!strcmp(ev->keyname, "KP_Right") && !ev->string))
1763      {
1764         _compose_seq_reset(en);
1765         if (en->have_selection &&
1766             (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1767           ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1768         if (en->select_allow)
1769           {
1770              if (shift)
1771                {
1772                   _sel_start(en->cursor, rp->object, en);
1773                   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1774                }
1775              else _sel_clear(en->cursor, rp->object, en);
1776           }
1777         /* If control is pressed, go to the end of the word */
1778         if (control) evas_textblock_cursor_word_end(en->cursor);
1779         if (evas_textblock_cursor_char_next(en->cursor))
1780           ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1781         if (en->select_allow)
1782           {
1783              if (shift) _sel_extend(en->cursor, rp->object, en);
1784              else _sel_clear(en->cursor, rp->object, en);
1785           }
1786         _edje_emit(ed, "entry,key,right", rp->part->name);
1787         _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1788      }
1789    else if (!strcmp(ev->keyname, "BackSpace"))
1790      {
1791         _compose_seq_reset(en);
1792         if (control && !en->have_selection)
1793           {
1794              // del to start of previous word
1795              _sel_start(en->cursor, rp->object, en);
1796
1797              evas_textblock_cursor_char_prev(en->cursor);
1798              evas_textblock_cursor_word_start(en->cursor);
1799
1800              _sel_preextend(en->cursor, rp->object, en);
1801
1802              _range_del_emit(ed, en->cursor, rp->object, en);
1803           }
1804         else if ((alt) && (shift))
1805           {
1806              // undo last action
1807           }
1808         else
1809           {
1810              if (en->have_selection)
1811                {
1812                   _range_del_emit(ed, en->cursor, rp->object, en);
1813                }
1814              else
1815                {
1816                   if (evas_textblock_cursor_char_prev(en->cursor))
1817                     {
1818                        _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
1819                     }
1820                }
1821           }
1822         _sel_clear(en->cursor, rp->object, en);
1823         _anchors_get(en->cursor, rp->object, en);
1824         _edje_emit(ed, "entry,key,backspace", rp->part->name);
1825         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1826      }
1827    else if (!strcmp(ev->keyname, "Delete") ||
1828             (!strcmp(ev->keyname, "KP_Delete") && !ev->string))
1829      {
1830         _compose_seq_reset(en);
1831         if (control)
1832           {
1833              // del to end of next word
1834              _sel_start(en->cursor, rp->object, en);
1835
1836              evas_textblock_cursor_word_end(en->cursor);
1837              evas_textblock_cursor_char_next(en->cursor);
1838
1839              _sel_extend(en->cursor, rp->object, en);
1840
1841              _range_del_emit(ed, en->cursor, rp->object, en);
1842           }
1843         else if (shift)
1844           {
1845              // cut
1846           }
1847         else
1848           {
1849              if (en->have_selection)
1850                {
1851                   _range_del_emit(ed, en->cursor, rp->object, en);
1852                }
1853              else
1854                {
1855                   _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
1856                }
1857           }
1858         _sel_clear(en->cursor, rp->object, en);
1859         _anchors_get(en->cursor, rp->object, en);
1860         _edje_emit(ed, "entry,key,delete", rp->part->name);
1861         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1862      }
1863    else if (!strcmp(ev->keyname, "Home") ||
1864             ((!strcmp(ev->keyname, "KP_Home")) && !ev->string))
1865      {
1866         _compose_seq_reset(en);
1867         if (en->select_allow)
1868           {
1869              if (shift) _sel_start(en->cursor, rp->object, en);
1870              else _sel_clear(en->cursor, rp->object, en);
1871           }
1872         if ((control) && (multiline))
1873           _curs_start(en->cursor, rp->object, en);
1874         else
1875           _curs_lin_start(en->cursor, rp->object, en);
1876         if (en->select_allow)
1877           {
1878              if (shift) _sel_extend(en->cursor, rp->object, en);
1879           }
1880         _edje_emit(ed, "entry,key,home", rp->part->name);
1881         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1882      }
1883    else if (!strcmp(ev->keyname, "End") ||
1884             ((!strcmp(ev->keyname, "KP_End")) && !ev->string))
1885      {
1886         _compose_seq_reset(en);
1887         if (en->select_allow)
1888           {
1889              if (shift) _sel_start(en->cursor, rp->object, en);
1890              else _sel_clear(en->cursor, rp->object, en);
1891           }
1892         if ((control) && (multiline))
1893           _curs_end(en->cursor, rp->object, en);
1894         else
1895           _curs_lin_end(en->cursor, rp->object, en);
1896         if (en->select_allow)
1897           {
1898              if (shift) _sel_extend(en->cursor, rp->object, en);
1899           }
1900         _edje_emit(ed, "entry,key,end", rp->part->name);
1901         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1902      }
1903    else if ((control) && (!shift) && (!strcmp(ev->keyname, "v")))
1904      {
1905         _compose_seq_reset(en);
1906         _edje_emit(ed, "entry,paste,request", rp->part->name);
1907         _edje_emit(ed, "entry,paste,request,3", rp->part->name);
1908         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1909      }
1910    else if ((control) && (!strcmp(ev->keyname, "a")))
1911      {
1912         _compose_seq_reset(en);
1913         if (shift)
1914           {
1915              _edje_emit(ed, "entry,selection,none,request", rp->part->name);
1916              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1917           }
1918         else
1919           {
1920              if (en->select_allow) // TIZEN ONLY
1921                 _edje_emit(ed, "entry,selection,all,request", rp->part->name);
1922              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1923           }
1924      }
1925    else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->keyname, "Insert")))
1926      {
1927         _compose_seq_reset(en);
1928         _edje_emit(ed, "entry,copy,notify", rp->part->name);
1929         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1930      }
1931    else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
1932      {
1933         _compose_seq_reset(en);
1934         _edje_emit(ed, "entry,cut,notify", rp->part->name);
1935         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1936      }
1937    else if ((control) && (!strcmp(ev->keyname, "z")))
1938      {
1939         _compose_seq_reset(en);
1940         if (shift)
1941           {
1942              // redo
1943              _edje_emit(ed, "entry,redo,request", rp->part->name);
1944           }
1945         else
1946           {
1947              // undo
1948              _edje_emit(ed, "entry,undo,request", rp->part->name);
1949           }
1950         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1951      }
1952    else if ((control) && (!shift) && (!strcmp(ev->keyname, "y")))
1953      {
1954         _compose_seq_reset(en);
1955         // redo
1956         _edje_emit(ed, "entry,redo,request", rp->part->name);
1957         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1958      }
1959    else if ((control) && (!shift) && (!strcmp(ev->keyname, "w")))
1960      {
1961         _compose_seq_reset(en);
1962         _sel_clear(en->cursor, rp->object, en);
1963         // select current word?
1964         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1965      }
1966    else if (!strcmp(ev->keyname, "Tab"))
1967      {
1968         _compose_seq_reset(en);
1969         if (multiline)
1970           {
1971              if (shift)
1972                {
1973                   // remove a tab
1974                }
1975              else
1976                {
1977                   Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1978                   info->insert = EINA_TRUE;
1979                   info->change.insert.plain_length = 1;
1980
1981                   if (en->have_selection)
1982                     {
1983                        _range_del_emit(ed, en->cursor, rp->object, en);
1984                        info->merge = EINA_TRUE;
1985                     }
1986                   info->change.insert.pos =
1987                      evas_textblock_cursor_pos_get(en->cursor);
1988                   info->change.insert.content = eina_stringshare_add("<tab/>");
1989                   //yy
1990 //                  evas_textblock_cursor_format_prepend(en->cursor, "tab");
1991                   _text_filter_format_prepend(en, en->cursor, "tab");
1992                   _anchors_get(en->cursor, rp->object, en);
1993                   _edje_emit(ed, "entry,changed", rp->part->name);
1994                   _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1995                                   info, _free_entry_change_info);
1996                }
1997              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1998           }
1999         _edje_emit(ed, "entry,key,tab", rp->part->name);
2000      }
2001    else if ((!strcmp(ev->keyname, "ISO_Left_Tab")) && (multiline))
2002      {
2003         _compose_seq_reset(en);
2004         // remove a tab
2005         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2006      }
2007    else if (!strcmp(ev->keyname, "Prior") ||
2008             (!strcmp(ev->keyname, "KP_Prior") && !ev->string))
2009      {
2010         _compose_seq_reset(en);
2011         if (en->select_allow)
2012           {
2013              if (shift) _sel_start(en->cursor, rp->object, en);
2014              else _sel_clear(en->cursor, rp->object, en);
2015           }
2016         _curs_jump_line_by(en->cursor, rp->object, en, -10);
2017         if (en->select_allow)
2018           {
2019              if (shift) _sel_extend(en->cursor, rp->object, en);
2020              else _sel_clear(en->cursor, rp->object, en);
2021           }
2022         _edje_emit(ed, "entry,key,pgup", rp->part->name);
2023         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2024      }
2025    else if (!strcmp(ev->keyname, "Next") ||
2026             (!strcmp(ev->keyname, "KP_Next") && !ev->string))
2027      {
2028         _compose_seq_reset(en);
2029         if (en->select_allow)
2030           {
2031              if (shift) _sel_start(en->cursor, rp->object, en);
2032              else _sel_clear(en->cursor, rp->object, en);
2033           }
2034         _curs_jump_line_by(en->cursor, rp->object, en, 10);
2035         if (en->select_allow)
2036           {
2037              if (shift) _sel_extend(en->cursor, rp->object, en);
2038              else _sel_clear(en->cursor, rp->object, en);
2039           }
2040         _edje_emit(ed, "entry,key,pgdn", rp->part->name);
2041         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2042      }
2043    else if ((!strcmp(ev->keyname, "Return")) || (!strcmp(ev->keyname, "KP_Enter")))
2044      {
2045         _compose_seq_reset(en);
2046         if (multiline)
2047           {
2048              Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2049              info->insert = EINA_TRUE;
2050              info->change.insert.plain_length = 1;
2051              if (en->have_selection)
2052                {
2053                   _range_del_emit(ed, en->cursor, rp->object, en);
2054                   info->merge = EINA_TRUE;
2055                }
2056
2057              info->change.insert.pos =
2058                 evas_textblock_cursor_pos_get(en->cursor);
2059              if (shift ||
2060                  evas_object_textblock_legacy_newline_get(rp->object))
2061                {
2062                   //yy
2063 //                  evas_textblock_cursor_format_prepend(en->cursor, "br");
2064                   _text_filter_format_prepend(en, en->cursor, "br");
2065                   info->change.insert.content = eina_stringshare_add("<br/>");
2066                }
2067              else
2068                {
2069                   //yy
2070 //                  evas_textblock_cursor_format_prepend(en->cursor, "ps");
2071                   _text_filter_format_prepend(en, en->cursor, "ps");
2072                   info->change.insert.content = eina_stringshare_add("<ps/>");
2073                }
2074              _anchors_get(en->cursor, rp->object, en);
2075              _edje_emit(ed, "entry,changed", rp->part->name);
2076              _edje_emit_full(ed, "entry,changed,user", rp->part->name,
2077                              info, _free_entry_change_info);
2078              _edje_emit(ed, "cursor,changed", rp->part->name);
2079              cursor_changed = EINA_TRUE;
2080              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2081           }
2082         _edje_emit(ed, "entry,key,enter", rp->part->name);
2083      }
2084    else
2085      {
2086         char *compres = NULL, *string = (char *)ev->string;
2087         Eina_Bool free_string = EINA_FALSE;
2088         Ecore_Compose_State state;
2089         
2090         if (!en->composing)
2091           {
2092              _compose_seq_reset(en);
2093              en->seq = eina_list_append(en->seq, eina_stringshare_add(ev->key));
2094              state = ecore_compose_get(en->seq, &compres);
2095              if (state == ECORE_COMPOSE_MIDDLE) en->composing = EINA_TRUE;
2096              else en->composing = EINA_FALSE;
2097              if (!en->composing) _compose_seq_reset(en);
2098              else goto end;
2099           }
2100         else
2101           {
2102              if (_is_modifier(ev->key)) goto end;
2103              en->seq = eina_list_append(en->seq, eina_stringshare_add(ev->key));
2104              state = ecore_compose_get(en->seq, &compres);
2105              if (state == ECORE_COMPOSE_NONE) _compose_seq_reset(en);
2106              else if (state == ECORE_COMPOSE_DONE)
2107                {
2108                   _compose_seq_reset(en);
2109                   if (compres)
2110                     {
2111                        string = compres;
2112                        free_string = EINA_TRUE;
2113                     }
2114                }
2115              else goto end;
2116           }
2117         if (string)
2118           {
2119              Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2120              info->insert = EINA_TRUE;
2121              info->change.insert.plain_length = 1;
2122              info->change.insert.content = eina_stringshare_add(string);
2123
2124              if (en->have_selection)
2125                {
2126                   _range_del_emit(ed, en->cursor, rp->object, en);
2127                   info->merge = EINA_TRUE;
2128                }
2129
2130              info->change.insert.pos =
2131                 evas_textblock_cursor_pos_get(en->cursor);
2132              // if PASSWORD_SHOW_LAST mode, appending text with password=off tag
2133              if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2134                  _edje_password_show_last)
2135                {
2136                   _edje_entry_hide_visible_password(en->rp);
2137                   _text_filter_format_prepend(en, en->cursor, "+ password=off");
2138                   _text_filter_text_prepend(en, en->cursor, string);
2139                   _text_filter_format_prepend(en, en->cursor, "- password");
2140                   if (en->pw_timer)
2141                     {
2142                        ecore_timer_del(en->pw_timer);
2143                        en->pw_timer = NULL;
2144                     }
2145                   en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
2146                                                  _password_timer_cb, en);
2147                }
2148              else
2149                _text_filter_text_prepend(en, en->cursor, string);
2150              _anchors_get(en->cursor, rp->object, en);
2151              _edje_emit(ed, "entry,changed", rp->part->name);
2152              _edje_emit_full(ed, "entry,changed,user", rp->part->name,
2153                              info, _free_entry_change_info);
2154              _edje_emit(ed, "cursor,changed", rp->part->name);
2155              cursor_changed = EINA_TRUE;
2156              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2157           }
2158         if (free_string) free(string);
2159      }
2160 end:
2161    if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
2162      _edje_emit(ed, "cursor,changed", rp->part->name);
2163
2164    _edje_entry_imf_cursor_info_set(en);
2165    _edje_entry_real_part_configure(rp);
2166 }
2167
2168 static void
2169 _edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2170 {
2171    Edje *ed = data;
2172    Edje_Real_Part *rp = ed->focused_part;
2173    Entry *en;
2174
2175    if (!rp) return;
2176    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2177        (!rp->typedata.text)) return;
2178    en = rp->typedata.text->entry_data;
2179    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2180        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
2181      return;
2182
2183 #ifdef HAVE_ECORE_IMF
2184    if (en->imf_context)
2185      {
2186         Evas_Event_Key_Up *ev = event_info;
2187         Ecore_IMF_Event_Key_Up ecore_ev;
2188
2189         ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev);
2190         if (ecore_imf_context_filter_event(en->imf_context,
2191                                            ECORE_IMF_EVENT_KEY_UP,
2192                                            (Ecore_IMF_Event *)&ecore_ev))
2193           return;
2194      }
2195 #else
2196    (void) event_info;
2197 #endif
2198 }
2199
2200 // TIZEN ONLY - START
2201 Eina_Bool
2202 _edje_entry_select_word(Edje_Real_Part *rp)
2203 {
2204    Entry *en;
2205    if (!rp) return EINA_FALSE;
2206    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2207        (!rp->typedata.text)) return EINA_FALSE;
2208
2209    en = rp->typedata.text->entry_data;
2210    if (!en) return EINA_FALSE;
2211
2212    if (en->cursor_fg) evas_object_hide(en->cursor_fg);
2213    if (en->cursor_bg) evas_object_hide(en->cursor_bg);
2214
2215    evas_textblock_cursor_word_start(en->cursor);
2216
2217    if (evas_textblock_cursor_eol_get(en->cursor))
2218      {
2219         evas_textblock_cursor_char_prev(en->cursor);
2220         evas_textblock_cursor_word_start(en->cursor);
2221      }
2222
2223    _sel_clear(en->cursor, rp->object, en);
2224    _sel_enable(en->cursor, rp->object, en);
2225    _sel_start(en->cursor, rp->object, en);
2226
2227    evas_textblock_cursor_word_end(en->cursor);
2228    evas_textblock_cursor_char_next(en->cursor);
2229
2230    _sel_extend(en->cursor, rp->object, en);
2231    _edje_entry_real_part_configure(rp);
2232
2233    en->had_sel = EINA_TRUE;
2234    en->selecting = EINA_FALSE;
2235
2236    return EINA_TRUE;
2237 }
2238
2239 static Eina_Bool
2240 _long_press_cb(void *data)
2241 {
2242    Edje_Real_Part *rp = data;
2243    Entry *en;
2244    if (!rp) return ECORE_CALLBACK_CANCEL;
2245    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2246        (!rp->typedata.text)) return ECORE_CALLBACK_CANCEL;
2247
2248    en = rp->typedata.text->entry_data;
2249    if (!en) return ECORE_CALLBACK_CANCEL;
2250
2251    if (en->long_press_timer)
2252      {
2253         ecore_timer_del(en->long_press_timer);
2254         en->long_press_timer = NULL;
2255      }
2256
2257    en->long_press_state = _ENTRY_LONG_PRESSED;
2258    en->long_press_timer = NULL;
2259
2260    _edje_emit(en->rp->edje, "long,pressed", en->rp->part->name);
2261
2262    if ((en->cursor_handler) && (!en->cursor_handler_disabled) && (en->focused))
2263      {
2264         edje_object_signal_emit(en->cursor_handler, "edje,cursor,handle,show", "edje");
2265         evas_object_show(en->cursor_handler);
2266         en->cursor_handler_show = EINA_TRUE;
2267      }
2268    return ECORE_CALLBACK_CANCEL;
2269 }
2270 // TIZEN ONLY - END
2271
2272 static void
2273 _edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2274 {
2275    Edje_Real_Part *rp = data;
2276    Entry *en;
2277    if (!rp) return;
2278    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2279        (!rp->typedata.text)) return;
2280    en = rp->typedata.text->entry_data;
2281    if (!en) return;
2282    _edje_entry_imf_cursor_location_set(en);
2283 }
2284
2285 static void
2286 _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2287 {
2288    Evas_Coord cx, cy;
2289    Edje_Real_Part *rp = data;
2290    Evas_Event_Mouse_Down *ev = event_info;
2291    Entry *en;
2292    Evas_Coord x, y, w, h;
2293    //   Eina_Bool multiline;
2294    Evas_Textblock_Cursor *tc = NULL;
2295    Eina_Bool dosel = EINA_FALSE;
2296    Eina_Bool shift;
2297    if (!rp) return;
2298    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
2299    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2300        (!rp->typedata.text)) return;
2301    en = rp->typedata.text->entry_data;
2302    en->long_press_state = _ENTRY_LONG_PRESSING; // TIZEN ONLY
2303    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2304        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2305      return;
2306    if ((ev->button != 1) && (ev->button != 2)) return;
2307
2308    // TIZEN ONLY - START
2309    en->dx = ev->canvas.x;
2310    en->dy = ev->canvas.y;
2311    // TIZEN ONLY - END
2312
2313 #ifdef HAVE_ECORE_IMF
2314    if (en->imf_context)
2315      {
2316         Ecore_IMF_Event_Mouse_Down ecore_ev;
2317         ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev);
2318         if (ecore_imf_context_filter_event(en->imf_context,
2319                                            ECORE_IMF_EVENT_MOUSE_DOWN,
2320                                            (Ecore_IMF_Event *)&ecore_ev))
2321           return;
2322      }
2323 #endif
2324
2325    _edje_entry_imf_context_reset(rp);
2326
2327    shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
2328    en->select_mod_start = EINA_FALSE;
2329    en->select_mod_end = EINA_FALSE;
2330    if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
2331       dosel = EINA_TRUE;
2332    else if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
2333             (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2334      {
2335         if (en->select_allow) dosel = EINA_TRUE;
2336      }
2337    if (ev->button == 2) dosel = EINA_FALSE;
2338    if (dosel)
2339      {
2340         evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2341         cx = ev->canvas.x - x;
2342         cy = ev->canvas.y - y;
2343         if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
2344           {
2345              if (shift)
2346                {
2347                   tc = evas_object_textblock_cursor_new(rp->object);
2348                   evas_textblock_cursor_copy(en->cursor, tc);
2349                   if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
2350                     evas_textblock_cursor_line_char_first(en->cursor);
2351                   else
2352                     evas_textblock_cursor_line_char_last(en->cursor);
2353                   _sel_extend(en->cursor, rp->object, en);
2354                }
2355              else
2356                {
2357                   en->have_selection = EINA_FALSE;
2358                   en->selecting = EINA_FALSE;
2359                   _sel_clear(en->cursor, rp->object, en);
2360                   tc = evas_object_textblock_cursor_new(rp->object);
2361                   evas_textblock_cursor_copy(en->cursor, tc);
2362                   evas_textblock_cursor_line_char_first(en->cursor);
2363                   _sel_start(en->cursor, rp->object, en);
2364                   evas_textblock_cursor_line_char_last(en->cursor);
2365                   _sel_extend(en->cursor, rp->object, en);
2366                }
2367              goto end;
2368           }
2369         else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
2370           {
2371              if (shift)
2372                {
2373                   tc = evas_object_textblock_cursor_new(rp->object);
2374                   evas_textblock_cursor_copy(en->cursor, tc);
2375                   if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
2376                     evas_textblock_cursor_word_start(en->cursor);
2377                   else
2378                     {
2379                        evas_textblock_cursor_word_end(en->cursor);
2380                        evas_textblock_cursor_char_next(en->cursor);
2381                     }
2382                   _sel_extend(en->cursor, rp->object, en);
2383                }
2384              else
2385                {
2386                   en->have_selection = EINA_FALSE;
2387                   en->selecting = EINA_FALSE;
2388                   _sel_clear(en->cursor, rp->object, en);
2389                   tc = evas_object_textblock_cursor_new(rp->object);
2390                   evas_textblock_cursor_copy(en->cursor, tc);
2391                   evas_textblock_cursor_word_start(en->cursor);
2392                   _sel_start(en->cursor, rp->object, en);
2393                   evas_textblock_cursor_word_end(en->cursor);
2394                   evas_textblock_cursor_char_next(en->cursor);
2395                   _sel_extend(en->cursor, rp->object, en);
2396                }
2397              goto end;
2398           }
2399      }
2400    tc = evas_object_textblock_cursor_new(rp->object);
2401    evas_textblock_cursor_copy(en->cursor, tc);
2402    //   multiline = rp->part->multiline;
2403    evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2404    cx = ev->canvas.x - x;
2405    cy = ev->canvas.y - y;
2406    if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2407      {
2408         evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
2409      }
2410    else
2411      {
2412         if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2413           {
2414              Evas_Coord lx, ly, lw, lh;
2415              int line;
2416
2417              line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2418              if (line == -1)
2419                {
2420                   if (rp->part->multiline)
2421                      _curs_end(en->cursor, rp->object, en);
2422                   else
2423                     {
2424                        evas_textblock_cursor_paragraph_first(en->cursor);
2425                        evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2426                        if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2427                           _curs_end(en->cursor, rp->object, en);
2428                     }
2429                }
2430              else
2431                {
2432                   int lnum;
2433
2434                   lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2435                   if (lnum < 0)
2436                     {
2437                        _curs_lin_start(en->cursor, rp->object, en);
2438                     }
2439                   else
2440                     {
2441                        if (cx <= lx)
2442                           _curs_lin_start(en->cursor, rp->object, en);
2443                        else
2444                           _curs_lin_end(en->cursor, rp->object, en);
2445                     }
2446                }
2447           }
2448      }
2449    if (dosel)
2450      {
2451         if ((en->have_selection) &&
2452             (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2453           {
2454              if (shift)
2455                _sel_extend(en->cursor, rp->object, en);
2456              else
2457                {
2458                   Eina_List *first, *last;
2459                   FLOAT_T sc;
2460
2461                   first = en->sel;
2462                   last = eina_list_last(en->sel);
2463                   if (first && last)
2464                     {
2465                        Evas_Textblock_Rectangle *r1, *r2;
2466                        Evas_Coord d, d1, d2;
2467                        
2468                        r1 = first->data;
2469                        r2 = last->data;
2470                        d = r1->x - cx;
2471                        d1 = d * d;
2472                        d = (r1->y + (r1->h / 2)) - cy;
2473                        d1 += d * d;
2474                        d = r2->x + r2->w - 1 - cx;
2475                        d2 = d * d;
2476                        d = (r2->y + (r2->h / 2)) - cy;
2477                        d2 += d * d;
2478                        sc = rp->edje->scale;
2479                        if (sc == ZERO) sc = _edje_scale;
2480                        d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
2481                        d = d * d;
2482                        if (d1 < d2)
2483                          {
2484                             if (d1 <= d)
2485                               {
2486                                  en->select_mod_start = EINA_TRUE;
2487                                  en->selecting = EINA_TRUE;
2488                               }
2489                          }
2490                        else
2491                          {
2492                             if (d2 <= d)
2493                               {
2494                                  en->select_mod_end = EINA_TRUE;
2495                                  en->selecting = EINA_TRUE;
2496                               }
2497                          }
2498                     }
2499                }
2500           }
2501         else
2502           {
2503              if ((en->have_selection) && (shift))
2504                _sel_extend(en->cursor, rp->object, en);
2505              else
2506                {
2507                   en->selecting = EINA_TRUE;
2508                   _sel_clear(en->cursor, rp->object, en);
2509                   if (en->select_allow)
2510                     {
2511                        _sel_start(en->cursor, rp->object, en);
2512                     }
2513                }
2514           }
2515      }
2516  end:
2517    if (evas_textblock_cursor_compare(tc, en->cursor))
2518      {
2519         _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2520         _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2521      }
2522    evas_textblock_cursor_free(tc);
2523
2524    // TIZEN ONLY - START
2525    if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2526      {
2527         if (en->long_press_timer) ecore_timer_del(en->long_press_timer);
2528         en->long_press_timer = ecore_timer_add(0.5, _long_press_cb, data); //FIXME: timer value
2529      }
2530    else
2531       _edje_entry_real_part_configure(rp);
2532    if (ev->button == 2)
2533      {
2534         _edje_emit(rp->edje, "entry,paste,request", rp->part->name);
2535         _edje_emit(rp->edje, "entry,paste,request,1", rp->part->name);
2536      }
2537 }
2538
2539 static void
2540 _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2541 {
2542    Evas_Coord cx, cy;
2543    Edje_Real_Part *rp = data;
2544    Evas_Event_Mouse_Up *ev = event_info;
2545    Entry *en;
2546    Evas_Coord x, y, w, h;
2547    Evas_Textblock_Cursor *tc;
2548    if (ev->button != 1) return;
2549    if (!rp) return;
2550    //if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; //TIZEN ONLY
2551    //if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return; // TIZEN ONLY
2552    //if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return; // TIZEN ONLY
2553    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2554        (!rp->typedata.text)) return;
2555    en = rp->typedata.text->entry_data;
2556    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2557        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2558      return;
2559
2560    // TIZEN ONLY - START
2561    if (en->long_press_timer)
2562      {
2563         ecore_timer_del(en->long_press_timer);
2564         en->long_press_timer = NULL;
2565      }
2566
2567    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2568      {
2569         _edje_entry_imf_cursor_info_set(en);
2570         return;
2571      }
2572
2573    if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return;
2574    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return;
2575
2576    if (en->long_press_state == _ENTRY_LONG_PRESSED)
2577      {
2578         en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2579         _edje_entry_imf_cursor_info_set(en);
2580
2581         if ((strcmp(_edje_entry_text_get(rp), "") == 0) && (en->cursor_handler_show))
2582           {
2583              evas_object_hide(en->cursor_handler);
2584              en->cursor_handler_show = EINA_FALSE;
2585           }
2586         return;
2587      }
2588    en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2589
2590    if ((en->cursor_handler) && (!en->cursor_handler_disabled) && (!en->have_selection))
2591      {
2592         evas_object_show(en->cursor_handler);
2593         en->cursor_handler_show = EINA_TRUE;
2594      }
2595    // TIZEN ONLY - END
2596
2597 #ifdef HAVE_ECORE_IMF
2598    if (en->imf_context)
2599      {
2600         Ecore_IMF_Event_Mouse_Up ecore_ev;
2601         ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev);
2602         if (ecore_imf_context_filter_event(en->imf_context,
2603                                            ECORE_IMF_EVENT_MOUSE_UP,
2604                                            (Ecore_IMF_Event *)&ecore_ev))
2605           return;
2606      }
2607 #endif
2608
2609    tc = evas_object_textblock_cursor_new(rp->object);
2610    evas_textblock_cursor_copy(en->cursor, tc);
2611    evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2612    cx = ev->canvas.x - x;
2613    cy = ev->canvas.y - y;
2614    if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2615      {
2616         Evas_Coord lx, ly, lw, lh;
2617         int line;
2618
2619         line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2620         if (line == -1)
2621           {
2622              if (rp->part->multiline)
2623                _curs_end(en->cursor, rp->object, en);
2624              else
2625                {
2626                   evas_textblock_cursor_paragraph_first(en->cursor);
2627                   evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2628                   if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2629                     _curs_end(en->cursor, rp->object, en);
2630                }
2631           }
2632         else
2633           {
2634              int lnum;
2635
2636              lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2637              if (lnum < 0)
2638                {
2639                   _curs_lin_start(en->cursor, rp->object, en);
2640                }
2641              else
2642                {
2643                   if (cx <= lx)
2644                     _curs_lin_start(en->cursor, rp->object, en);
2645                   else
2646                     _curs_lin_end(en->cursor, rp->object, en);
2647                }
2648           }
2649      }
2650    if (rp->part->select_mode != EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2651      {
2652        if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2653          {
2654            if (en->select_allow)
2655              {
2656                if (en->had_sel)
2657                  {
2658                    if (en->select_mod_end)
2659                      _sel_extend(en->cursor, rp->object, en);
2660                    else if (en->select_mod_start)
2661                      _sel_preextend(en->cursor, rp->object, en);
2662                  }
2663                else
2664                  _sel_extend(en->cursor, rp->object, en);
2665                //evas_textblock_cursor_copy(en->cursor, en->sel_end);
2666              }
2667          }
2668        else
2669          evas_textblock_cursor_copy(en->cursor, en->sel_end);
2670
2671        if (en->selecting)
2672          {
2673            if (en->have_selection)
2674              en->had_sel = EINA_TRUE;
2675            en->selecting = EINA_FALSE;
2676          }
2677      }
2678
2679    if (evas_textblock_cursor_compare(tc, en->cursor))
2680      {
2681         _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2682         _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2683      }
2684
2685    _edje_entry_imf_cursor_info_set(en);
2686
2687    evas_textblock_cursor_free(tc);
2688
2689    _edje_entry_real_part_configure(rp);
2690 }
2691
2692 static void
2693 _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2694 {
2695    Evas_Coord cx, cy;
2696    Edje_Real_Part *rp = data;
2697    Evas_Event_Mouse_Move *ev = event_info;
2698    Entry *en;
2699    Evas_Coord x, y, w, h;
2700    Evas_Textblock_Cursor *tc;
2701    if (!rp) return;
2702    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2703        (!rp->typedata.text)) return;
2704    en = rp->typedata.text->entry_data;
2705    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2706        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2707      return;
2708
2709 #ifdef HAVE_ECORE_IMF
2710    if (en->imf_context)
2711      {
2712         Ecore_IMF_Event_Mouse_Move ecore_ev;
2713         ecore_imf_evas_event_mouse_move_wrap(ev, &ecore_ev);
2714         if (ecore_imf_context_filter_event(en->imf_context,
2715                                            ECORE_IMF_EVENT_MOUSE_MOVE,
2716                                            (Ecore_IMF_Event *)&ecore_ev))
2717           return;
2718      }
2719 #endif
2720
2721    // TIZEN ONLY - START
2722    if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2723      {
2724         _edje_entry_real_part_configure(rp);
2725
2726         if (en->long_press_state == _ENTRY_LONG_PRESSING)
2727           {
2728              Evas_Coord dx, dy;
2729
2730              dx = en->dx - ev->cur.canvas.x;
2731              dy = en->dy - ev->cur.canvas.y;
2732
2733              /* FIXME: Magic number 40 is used to ignore finger move while detecting long press.              */
2734              /*        This should be replaced with the constant or variable relevant to the elm_finger_size. */
2735              if (((dx*dx) + (dy*dy)) > (40*40))
2736                {
2737                   en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2738                   if (en->long_press_timer)
2739                     {
2740                        ecore_timer_del(en->long_press_timer);
2741                        en->long_press_timer = NULL;
2742                     }
2743                }
2744           }
2745         else if (en->long_press_state == _ENTRY_LONG_PRESSED)
2746           {
2747              Evas_Coord flx, fly, flh;
2748              Evas_Coord cnx, cny;
2749
2750              tc = evas_object_textblock_cursor_new(rp->object);
2751              evas_textblock_cursor_copy(en->cursor, tc);
2752              evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2753
2754              cx = ev->cur.canvas.x - x;
2755              cy = ev->cur.canvas.y - y;
2756              evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
2757
2758              /* handle the special cases in which pressed position is above the first line or below the last line  */
2759              evas_object_textblock_line_number_geometry_get(rp->object, 0, &flx, &fly, NULL, &flh);
2760              evas_textblock_cursor_line_geometry_get(en->cursor, &cnx, &cny, NULL, NULL);
2761              if ((cnx == flx) && (cny == fly))
2762                {
2763                   /* cursor is in the first line */
2764                   evas_textblock_cursor_char_coord_set(en->cursor, cx, fly + flh / 2);
2765                }
2766              else
2767                {
2768                   Evas_Textblock_Cursor *lc;
2769                   Evas_Coord llx, lly, llh;
2770
2771                   lc = evas_object_textblock_cursor_new(rp->object);
2772                   evas_textblock_cursor_copy(en->cursor, lc);
2773                   evas_textblock_cursor_paragraph_last(lc);
2774                   evas_textblock_cursor_line_geometry_get(lc, &llx, &lly, NULL, &llh);
2775                   if ((cnx == llx) && (cny == lly))
2776                     {
2777                        /* cursor is in the last line */
2778                        evas_textblock_cursor_char_coord_set(en->cursor, cx, lly + llh / 2);
2779                     }
2780                   evas_textblock_cursor_free(lc);
2781                }
2782
2783              if (evas_textblock_cursor_compare(tc, en->cursor))
2784                {
2785                   _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2786                }
2787              evas_textblock_cursor_free(tc);
2788
2789              //_edje_emit(en->rp->edje, "magnifier,changed", en->rp->part->name);
2790           }
2791      } // TIZEN ONLY - END
2792    else
2793      {
2794         if (en->selecting)
2795           {
2796              tc = evas_object_textblock_cursor_new(rp->object);
2797              evas_textblock_cursor_copy(en->cursor, tc);
2798              evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2799              cx = ev->cur.canvas.x - x;
2800              cy = ev->cur.canvas.y - y;
2801              if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2802                {
2803                   Evas_Coord lx, ly, lw, lh;
2804
2805                   if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0)
2806                     {
2807                        if (rp->part->multiline)
2808                          _curs_end(en->cursor, rp->object, en);
2809                        else
2810                          {
2811                             evas_textblock_cursor_paragraph_first(en->cursor);
2812                             evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2813                             if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2814                               _curs_end(en->cursor, rp->object, en);
2815                          }
2816                     }
2817                   else
2818                     {
2819                        evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2820                        if (cx <= lx)
2821                          _curs_lin_start(en->cursor, rp->object, en);
2822                        else
2823                          _curs_lin_end(en->cursor, rp->object, en);
2824                     }
2825                }
2826
2827              if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
2828                  (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2829                {
2830                   if (en->select_allow)
2831                     {
2832                        if (en->had_sel)
2833                          {
2834                             if (en->select_mod_end)
2835                               _sel_extend(en->cursor, rp->object, en);
2836                             else if (en->select_mod_start)
2837                               _sel_preextend(en->cursor, rp->object, en);
2838                          }
2839                        else
2840                          _sel_extend(en->cursor, rp->object, en);
2841                     }
2842                }
2843              else
2844                {
2845                   _sel_extend(en->cursor, rp->object, en);
2846                }
2847              if (en->select_allow)
2848                {
2849                   if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0)
2850                     _sel_enable(en->cursor, rp->object, en);
2851                   if (en->have_selection)
2852                     _sel_update(en->cursor, rp->object, en);
2853                }
2854              if (evas_textblock_cursor_compare(tc, en->cursor))
2855                {
2856                   _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2857                   _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2858                }
2859              evas_textblock_cursor_free(tc);
2860
2861              _edje_entry_real_part_configure(rp);
2862           }
2863      }
2864 }
2865
2866 // TIZEN ONLY - START
2867 static Eina_Bool
2868 _cursor_handler_click_cb(void *data)
2869 {
2870    Edje_Real_Part *rp = data;
2871    Entry *en;
2872    if (!rp) return ECORE_CALLBACK_CANCEL;
2873    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2874        (!rp->typedata.text)) return ECORE_CALLBACK_CANCEL;
2875    en = rp->typedata.text->entry_data;
2876    if (!en) return ECORE_CALLBACK_CANCEL;
2877
2878    if (en->cursor_handler_click_timer)
2879      {
2880         ecore_timer_del(en->cursor_handler_click_timer);
2881         en->cursor_handler_click_timer = NULL;
2882      }
2883    en->cursor_handler_click_timer = NULL;
2884
2885    return ECORE_CALLBACK_CANCEL;
2886 }
2887
2888 static void
2889 _edje_entry_cursor_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
2890 {
2891    Entry *en;
2892    Edje_Real_Part *rp = data;
2893    Evas_Event_Mouse_Down *ev = event_info;
2894    Evas_Coord ox, oy, ow, oh;
2895    Evas_Coord lx, ly, lw, lh;
2896
2897    if (!rp) return;
2898    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2899        (!rp->typedata.text)) return;
2900    en = rp->typedata.text->entry_data;
2901
2902    if (ev->button != 1) return;
2903
2904    en->rx = en->sx = ev->canvas.x;
2905    en->ry = en->sy = ev->canvas.y;
2906
2907    evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
2908    edje_object_size_min_calc(obj, &ow, &oh);
2909    evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2910
2911    en->ox = ox + ow/2 - en->rx;
2912    en->oy = oy - en->ry - lh/2;
2913
2914    _edje_emit(rp->edje, "cursor,handler,move,start", en->rp->part->name);
2915
2916    if (en->cursor_handler_click_timer) ecore_timer_del(en->cursor_handler_click_timer);
2917    en->cursor_handler_click_timer = ecore_timer_add(0.1, _cursor_handler_click_cb, data); //FIXME: timer value
2918 }
2919
2920 static void
2921 _edje_entry_cursor_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2922 {
2923    Entry *en;
2924    Edje_Real_Part *rp = data;
2925    Evas_Event_Mouse_Up *ev = event_info;
2926
2927    if (!rp) return;
2928    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2929        (!rp->typedata.text)) return;
2930    en = rp->typedata.text->entry_data;
2931
2932    if (ev->button != 1) return;
2933
2934    if (en->cursor_handler_click_timer)
2935      {
2936         ecore_timer_del(en->cursor_handler_click_timer);
2937         en->cursor_handler_click_timer = NULL;
2938
2939         _edje_emit(rp->edje, "cursor,handler,clicked", rp->part->name);
2940      }
2941    else
2942      {
2943       _edje_entry_imf_cursor_info_set(en);
2944       _edje_emit(rp->edje, "cursor,handler,move,end", en->rp->part->name);
2945      }
2946 }
2947
2948 static void
2949 _edje_entry_cursor_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2950 {
2951    Entry *en;
2952    Edje_Real_Part *rp = data;
2953    Evas_Event_Mouse_Move *ev = event_info;
2954    Evas_Coord x, y, tx, ty, tw, th;
2955    Evas_Coord cx, cy;
2956    Evas_Coord lh;
2957
2958    if (!rp) return;
2959    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2960        (!rp->typedata.text)) return;
2961    en = rp->typedata.text->entry_data;
2962
2963    if (ev->buttons != 1) return;
2964
2965    x = ev->cur.canvas.x;
2966    y = ev->cur.canvas.y;
2967
2968    en->rx += (x - en->sx);
2969    en->ry += (y - en->sy);
2970    en->sx = ev->cur.canvas.x;
2971    en->sy = ev->cur.canvas.y;
2972
2973    evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
2974    evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
2975
2976    cx = en->rx + en->ox - tx;
2977    cy = en->ry + en->oy - ty;
2978
2979    evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, &lh);
2980    if (cx <= 0) cx = 1;
2981    if (cy <= 0) cy = lh / 2;
2982    if (cy > th) cy = th - 1;
2983
2984    evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
2985
2986    //_edje_entry_imf_cursor_info_set(en);
2987    _edje_emit(rp->edje, "cursor,changed", rp->part->name); //to scroll scroller
2988    _edje_entry_real_part_configure(rp);
2989
2990    _edje_emit(rp->edje, "cursor,handler,moving", rp->part->name);
2991 }
2992
2993 static void
2994 _edje_entry_start_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
2995 {
2996    Evas_Event_Mouse_Down *ev = event_info;
2997    Evas_Coord ox, oy, ow, oh;
2998    Evas_Coord lx, ly, lw, lh;
2999    Edje_Real_Part *rp = data;
3000    Entry *en = rp->typedata.text->entry_data;
3001
3002    if (ev->button != 1) return;
3003
3004    en->rx = en->sx = ev->canvas.x;
3005    en->ry = en->sy = ev->canvas.y;
3006
3007    evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
3008    edje_object_size_min_calc(obj, &ow, &oh);
3009    evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
3010
3011    en->ox = ox + ow/2 - en->rx;
3012    //en->oy = oy + oh - en->ry + lh/2;
3013    en->oy = oy + oh - en->ry - lh/2;
3014
3015    en->select_mod_start = EINA_TRUE;
3016    en->selecting = EINA_TRUE;
3017
3018    _edje_emit(en->rp->edje, "handler,move,start", en->rp->part->name);
3019 }
3020
3021 static void
3022 _edje_entry_start_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3023 {
3024    Edje_Real_Part *rp = data;
3025    Entry *en = rp->typedata.text->entry_data;
3026
3027    //switch sel_start,end
3028    if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) >= 0)
3029      {
3030         Evas_Textblock_Cursor *tc;
3031         tc = evas_object_textblock_cursor_new(rp->object);
3032         evas_textblock_cursor_copy(en->sel_start, tc);
3033         evas_textblock_cursor_copy(en->sel_end, en->sel_start);
3034         evas_textblock_cursor_copy(tc, en->sel_end);
3035         evas_textblock_cursor_free(tc);
3036      }
3037    //update handlers
3038    en->handler_bypassing = EINA_FALSE;
3039    _edje_entry_real_part_configure(rp);
3040
3041    _edje_emit(en->rp->edje, "handler,move,end", en->rp->part->name);
3042 }
3043
3044 static void
3045 _edje_entry_start_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3046 {
3047    Evas_Event_Mouse_Move *ev = event_info;
3048    Edje_Real_Part *rp = data;
3049    Entry *en = rp->typedata.text->entry_data;
3050    Evas_Coord x, y, tx, ty, tw, th;
3051    Evas_Coord cx, cy;
3052    Evas_Coord lh;
3053    Evas_Textblock_Cursor_Type cur_type;
3054    Evas_Coord sx, sy;
3055
3056    if (ev->buttons != 1) return;
3057
3058    x = ev->cur.canvas.x;
3059    y = ev->cur.canvas.y;
3060
3061    en->rx += (x - en->sx);
3062    en->ry += (y - en->sy);
3063    en->sx = ev->cur.canvas.x;
3064    en->sy = ev->cur.canvas.y;
3065
3066    evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3067    evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3068
3069    cx = en->rx + en->ox - tx;
3070    cy = en->ry + en->oy - ty;
3071
3072    evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, &lh);
3073    if (cx <= 0) cx = 1;
3074    if (cy <= 0) cy = lh / 2;
3075    if (cy > th) cy = th - 1;
3076
3077    switch (rp->part->cursor_mode)
3078      {
3079       case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3080          cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3081          break;
3082       case EDJE_ENTRY_CURSOR_MODE_UNDER:
3083       default:
3084          cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3085      }
3086
3087    evas_textblock_cursor_geometry_get(en->sel_end, &sx, &sy, NULL, NULL, NULL, cur_type);
3088
3089    evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
3090
3091    // by passing
3092    if (evas_textblock_cursor_compare(en->cursor, en->sel_end) >= 0)
3093       en->handler_bypassing = EINA_TRUE;
3094    else
3095       en->handler_bypassing = EINA_FALSE;
3096    //
3097
3098    if (en->select_allow)
3099      {
3100         if (en->had_sel)
3101           {
3102              if (en->select_mod_start)
3103                _sel_preextend(en->cursor, rp->object, en);
3104           }
3105      }
3106    _edje_entry_real_part_configure(rp);
3107    _edje_emit(en->rp->edje, "handler,moving", en->rp->part->name);
3108 }
3109
3110 static void
3111 _edje_entry_end_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3112 {
3113    Evas_Event_Mouse_Down *ev = event_info;
3114    Evas_Coord ox, oy, ow, oh;
3115    Evas_Coord lx, ly, lw, lh;
3116    Edje_Real_Part *rp = data;
3117    Entry *en = rp->typedata.text->entry_data;
3118
3119    if (ev->button != 1) return;
3120
3121    en->rx = en->sx = ev->canvas.x;
3122    en->ry = en->sy = ev->canvas.y;
3123
3124    evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
3125    edje_object_size_min_calc(obj, &ow, &oh);
3126    evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
3127
3128    en->ox = ox + ow/2 - en->rx;
3129    en->oy = oy - en->ry - lh/2;
3130
3131    en->select_mod_end = EINA_TRUE;
3132    en->selecting = EINA_TRUE;
3133
3134    _edje_emit(en->rp->edje, "handler,move,start", en->rp->part->name);
3135 }
3136
3137 static void
3138 _edje_entry_end_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3139 {
3140    Edje_Real_Part *rp = data;
3141    Entry *en = rp->typedata.text->entry_data;
3142
3143    //switch sel_start,end
3144    if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) >= 0)
3145      {
3146         Evas_Textblock_Cursor *tc;
3147         tc = evas_object_textblock_cursor_new(rp->object);
3148         evas_textblock_cursor_copy(en->sel_start, tc);
3149         evas_textblock_cursor_copy(en->sel_end, en->sel_start);
3150         evas_textblock_cursor_copy(tc, en->sel_end);
3151         // first char case
3152         if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) == 0)
3153           {
3154              evas_textblock_cursor_char_next(en->sel_end);
3155           }
3156         evas_textblock_cursor_free(tc);
3157      }
3158    //update handlers
3159    en->handler_bypassing = EINA_FALSE;
3160    _edje_entry_real_part_configure(rp);
3161
3162    _edje_emit(en->rp->edje, "handler,move,end", en->rp->part->name);
3163 }
3164
3165 static void
3166 _edje_entry_end_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3167 {
3168    Evas_Event_Mouse_Move *ev = event_info;
3169    Edje_Real_Part *rp = data;
3170    Entry *en = rp->typedata.text->entry_data;
3171    Evas_Coord x, y, tx, ty, tw, th;
3172    Evas_Coord cx, cy;
3173    Evas_Textblock_Cursor_Type cur_type;
3174    Evas_Coord sx, sy;
3175
3176    if (ev->buttons != 1) return;
3177
3178    x = ev->cur.canvas.x;
3179    y = ev->cur.canvas.y;
3180
3181    en->rx += (x - en->sx);
3182    en->ry += (y - en->sy);
3183    en->sx = ev->cur.canvas.x;
3184    en->sy = ev->cur.canvas.y;
3185
3186    evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3187    evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3188
3189    cx = en->rx + en->ox - tx;
3190    cy = en->ry + en->oy - ty;
3191
3192    if (cx < 0) cx = 0;
3193    if (cy < 0) cy = 0;
3194    if (cy > th) cy = th - 1;
3195
3196    switch (rp->part->cursor_mode)
3197      {
3198       case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3199          cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3200          break;
3201       case EDJE_ENTRY_CURSOR_MODE_UNDER:
3202       default:
3203          cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3204      }
3205
3206    evas_textblock_cursor_geometry_get(en->sel_start, &sx, &sy, NULL, NULL, NULL, cur_type);
3207    evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
3208
3209    // by passing
3210    if (evas_textblock_cursor_compare(en->cursor, en->sel_start) <= 0)
3211       en->handler_bypassing = EINA_TRUE;
3212    else
3213       en->handler_bypassing = EINA_FALSE;
3214    //
3215
3216    if (en->select_allow)
3217      {
3218         if (en->had_sel)
3219           {
3220              if (en->select_mod_end)
3221                _sel_extend(en->cursor, rp->object, en);
3222           }
3223      }
3224    _edje_entry_real_part_configure(rp);
3225    _edje_emit(en->rp->edje, "handler,moving", en->rp->part->name);
3226 }
3227 // TIZEN ONLY - END
3228
3229 static void
3230 _evas_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info)
3231 {
3232    Edje *ed = (Edje *)data;
3233
3234    if (evas_focus_get(e) == ed->obj)
3235      {
3236         _edje_focus_in_cb(data, NULL, NULL, NULL);
3237      }
3238 }
3239
3240 static void
3241 _evas_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info)
3242 {
3243    Edje *ed = (Edje *)data;
3244
3245    if (evas_focus_get(e) == ed->obj)
3246      {
3247         _edje_focus_out_cb(data, NULL, NULL, NULL);
3248      }
3249 }
3250
3251 /***************************************************************/
3252 void
3253 _edje_entry_init(Edje *ed)
3254 {
3255    if (!ed->has_entries)
3256      return;
3257    if (ed->entries_inited)
3258      return;
3259    ed->entries_inited = EINA_TRUE;
3260
3261    evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed);
3262    evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed);
3263    evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed);
3264    evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed);
3265    evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed);
3266    evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed);
3267 }
3268
3269 void
3270 _edje_entry_shutdown(Edje *ed)
3271 {
3272    if (!ed->has_entries)
3273      return;
3274    if (!ed->entries_inited)
3275      return;
3276    ed->entries_inited = EINA_FALSE;
3277
3278    evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb);
3279    evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb);
3280    evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb);
3281    evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb);
3282    if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed)
3283      ERR("could not unregister EVAS_CALLBACK_FOCUS_IN");
3284    if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed)
3285      ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT");
3286 }
3287
3288 void
3289 _edje_entry_real_part_init(Edje_Real_Part *rp)
3290 {
3291    Entry *en;
3292 #ifdef HAVE_ECORE_IMF
3293    const char *ctx_id;
3294    const Ecore_IMF_Context_Info *ctx_info;
3295 #endif
3296
3297    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3298        (!rp->typedata.text)) return;
3299    en = calloc(1, sizeof(Entry));
3300    if (!en) return;
3301    rp->typedata.text->entry_data = en;
3302    en->rp = rp;
3303
3304    evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp);
3305
3306    evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp);
3307    evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp);
3308    evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp);
3309
3310    if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
3311      en->select_allow = EINA_TRUE;
3312
3313    if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
3314      {
3315         Edje_Part_Description_Text *txt;
3316
3317         txt = (Edje_Part_Description_Text *)rp->chosen_description;
3318
3319         en->select_allow = EINA_FALSE;
3320         if (txt && edje_string_get(&txt->text.repch))
3321           evas_object_textblock_replace_char_set(rp->object, edje_string_get(&txt->text.repch));
3322         else
3323           evas_object_textblock_replace_char_set(rp->object, "*");
3324      }
3325
3326    en->cursor_bg = edje_object_add(rp->edje->base.evas);
3327    edje_object_file_set(en->cursor_bg, rp->edje->path, rp->part->source3);
3328    evas_object_smart_member_add(en->cursor_bg, rp->edje->obj);
3329    evas_object_stack_below(en->cursor_bg, rp->object);
3330    evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object));
3331    evas_object_pass_events_set(en->cursor_bg, EINA_TRUE);
3332    _edje_subobj_register(en->rp->edje, en->cursor_bg);
3333
3334    en->cursor_fg = edje_object_add(rp->edje->base.evas);
3335    edje_object_file_set(en->cursor_fg, rp->edje->path, rp->part->source4);
3336    evas_object_smart_member_add(en->cursor_fg, rp->edje->obj);
3337    evas_object_stack_above(en->cursor_fg, rp->object);
3338    evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object));
3339    evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
3340    _edje_subobj_register(en->rp->edje, en->cursor_fg);
3341
3342    /* A proxy to the main cursor. */
3343    if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
3344      {
3345         en->cursor_fg2 = evas_object_image_add(rp->edje->base.evas);
3346         evas_object_image_source_set(en->cursor_fg2, en->cursor_fg);
3347         evas_object_image_fill_set(en->cursor_fg2, 0, 0, 1, 1);
3348         evas_object_smart_member_add(en->cursor_fg2, rp->edje->obj);
3349         evas_object_stack_above(en->cursor_fg2, rp->object);
3350         evas_object_clip_set(en->cursor_fg2, evas_object_clip_get(rp->object));
3351         evas_object_pass_events_set(en->cursor_fg2, EINA_TRUE);
3352         _edje_subobj_register(en->rp->edje, en->cursor_fg2);
3353      }
3354
3355    // TIZEN ONLY - START
3356    //cursor handler
3357    en->cursor_handler_disabled = EINA_FALSE;
3358    en->cursor_handler = NULL;
3359    if (rp->part->source9)
3360      {
3361         en->cursor_handler = edje_object_add(en->rp->edje->base.evas);
3362         edje_object_file_set(en->cursor_handler , en->rp->edje->path, rp->part->source9);
3363
3364         evas_object_layer_set(en->cursor_handler , EVAS_LAYER_MAX - 2);
3365         en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->cursor_handler );
3366
3367         evas_object_event_callback_add(en->cursor_handler , EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_cursor_handler_mouse_down_cb, en->rp);
3368         evas_object_event_callback_add(en->cursor_handler , EVAS_CALLBACK_MOUSE_UP, _edje_entry_cursor_handler_mouse_up_cb, en->rp);
3369         evas_object_event_callback_add(en->cursor_handler , EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_cursor_handler_mouse_move_cb, en->rp);
3370      }
3371    en->cursor_handler_show = EINA_FALSE;
3372    // TIZEN ONLY - END
3373    en->focused = EINA_FALSE;
3374
3375    evas_object_textblock_legacy_newline_set(rp->object, EINA_TRUE);
3376
3377    if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
3378      {
3379         evas_object_show(en->cursor_bg);
3380         evas_object_show(en->cursor_fg);
3381         evas_object_show(en->cursor_fg2);
3382         en->input_panel_enable = EINA_TRUE;
3383
3384 #ifdef HAVE_ECORE_IMF
3385         ecore_imf_init();
3386
3387         en->commit_cancel = EINA_FALSE;
3388
3389         edje_object_signal_callback_add(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
3390         edje_object_signal_callback_add(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
3391
3392         ctx_id = ecore_imf_context_default_id_get();
3393         if (ctx_id)
3394           {
3395              ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
3396              if (!ctx_info->canvas_type ||
3397                  strcmp(ctx_info->canvas_type, "evas") == 0)
3398                {
3399                   en->imf_context = ecore_imf_context_add(ctx_id);
3400                }
3401              else
3402                {
3403                   ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
3404                   if (ctx_id)
3405                     {
3406                        en->imf_context = ecore_imf_context_add(ctx_id);
3407                     }
3408                }
3409           }
3410         else
3411           en->imf_context = NULL;
3412
3413         if (!en->imf_context) goto done;
3414
3415         ecore_imf_context_client_window_set
3416            (en->imf_context,
3417                (void *)ecore_evas_window_get
3418                (ecore_evas_ecore_evas_get(rp->edje->base.evas)));
3419         ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->base.evas);
3420
3421         ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
3422                                                             _edje_entry_imf_retrieve_surrounding_cb, rp->edje);
3423         ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
3424         ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje);
3425         ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje);
3426         ecore_imf_context_input_mode_set(en->imf_context,
3427                                          rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
3428                                          ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
3429
3430         if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
3431           ecore_imf_context_input_panel_language_set(en->imf_context, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
3432 #endif
3433      }
3434 #ifdef HAVE_ECORE_IMF
3435 done:
3436 #endif
3437    en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
3438 }
3439
3440 void
3441 _edje_entry_real_part_shutdown(Edje_Real_Part *rp)
3442 {
3443    Entry *en;
3444    
3445    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3446        (!rp->typedata.text)) return;
3447    en = rp->typedata.text->entry_data;
3448    if (!en) return;
3449    rp->typedata.text->entry_data = NULL;
3450    _sel_clear(en->cursor, rp->object, en);
3451    _anchors_clear(en->cursor, rp->object, en);
3452 #ifdef HAVE_ECORE_IMF
3453    _preedit_clear(en);
3454 #endif
3455    // TIZEN ONLY - START
3456    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_bg);
3457    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_fg);
3458    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_start);
3459    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_end);
3460    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_edge_start);
3461    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_edge_end);
3462    rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_handler);
3463    // TIZEN ONLY - END
3464    evas_object_del(en->cursor_bg);
3465    evas_object_del(en->cursor_fg);
3466    evas_object_del(en->cursor_fg2);
3467
3468    // TIZEN ONLY - START
3469    if (en->sel_handler_start)
3470      {
3471         evas_object_del(en->sel_handler_start);
3472         en->sel_handler_start = NULL;
3473      }
3474    if (en->sel_handler_end)
3475      {
3476         evas_object_del(en->sel_handler_end);
3477         en->sel_handler_end = NULL;
3478      }
3479    if (en->cursor_handler)
3480      {
3481         evas_object_del(en->cursor_handler);
3482         en->cursor_handler = NULL;
3483      }
3484    if (en->sel_handler_edge_start)
3485      {
3486         evas_object_del(en->sel_handler_edge_start);
3487         en->sel_handler_edge_start = NULL;
3488      }
3489    if (en->sel_handler_edge_end)
3490      {
3491         evas_object_del(en->sel_handler_edge_end);
3492         en->sel_handler_edge_end = NULL;
3493      }
3494
3495    if (en->long_press_timer)
3496      {
3497         ecore_timer_del(en->long_press_timer);
3498         en->long_press_timer = NULL;
3499      }
3500    if (en->cursor_handler_click_timer)
3501      {
3502         ecore_timer_del(en->cursor_handler_click_timer);
3503         en->cursor_handler_click_timer = NULL;
3504      }
3505    // TIZEN ONLY - END
3506
3507    if (en->pw_timer)
3508      {
3509         ecore_timer_del(en->pw_timer);
3510         en->pw_timer = NULL;
3511      }
3512
3513 #ifdef HAVE_ECORE_IMF
3514    if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
3515      {
3516         if (en->imf_context)
3517           {
3518              ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb);
3519              ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb);
3520              ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
3521
3522              ecore_imf_context_del(en->imf_context);
3523              en->imf_context = NULL;
3524           }
3525
3526         edje_object_signal_callback_del(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
3527         edje_object_signal_callback_del(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb);
3528         ecore_imf_shutdown();
3529      }
3530 #endif
3531    _compose_seq_reset(en);
3532    
3533    free(en);
3534 }
3535
3536 void
3537 _edje_entry_real_part_configure(Edje_Real_Part *rp)
3538 {
3539    Evas_Coord x, y, w, h, xx, yy, ww, hh, xx2, yy2;
3540    Entry *en;
3541    Evas_Textblock_Cursor_Type cur_type;
3542    Eina_Bool bidi_cursor = EINA_FALSE;
3543    
3544    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3545        (!rp->typedata.text)) return;
3546    en = rp->typedata.text->entry_data;
3547    if (!en) return;
3548    switch (rp->part->cursor_mode)
3549      {
3550       case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3551          cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3552          break;
3553       case EDJE_ENTRY_CURSOR_MODE_UNDER:
3554          /* no break for a resaon */
3555       default:
3556          cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3557      }
3558
3559    _sel_update(en->cursor, rp->object, en);
3560    _anchors_update(en->cursor, rp->object, en);
3561    x = y = w = h = -1;
3562    xx = yy = ww = hh = -1;
3563    evas_object_geometry_get(rp->object, &x, &y, &w, &h);
3564    /* For split cursor need to assign return value to bidi_cursor.
3565     * bidi_cursor = evas_textblock_geometry_bidi_get() */
3566    evas_textblock_cursor_geometry_bidi_get(en->cursor, &xx, &yy, &ww, &hh, &xx2, &yy2, NULL, NULL, cur_type);
3567    if (ww < 1) ww = 1;
3568    if (hh < 1) hh = 1;
3569    if (en->cursor_bg)
3570      {
3571         evas_object_move(en->cursor_bg, x + xx, y + yy);
3572         evas_object_resize(en->cursor_bg, ww, hh);
3573      }
3574    if (en->cursor_fg)
3575      {
3576         evas_object_move(en->cursor_fg, x + xx, y + yy);
3577         evas_object_resize(en->cursor_fg, ww, hh);
3578      }
3579
3580    if (en->cursor_fg2)
3581      {
3582         if (bidi_cursor)
3583           {
3584              evas_object_image_fill_set(en->cursor_fg2, 0, 0, ww, hh / 2);
3585              evas_object_move(en->cursor_fg2, x + xx2, y + yy2 + (hh / 2));
3586              evas_object_resize(en->cursor_fg, ww, hh / 2);
3587              evas_object_resize(en->cursor_fg2, ww, hh / 2);
3588
3589              evas_object_show(en->cursor_fg2);
3590           }
3591         else
3592           {
3593              evas_object_hide(en->cursor_fg2);
3594           }
3595      }
3596
3597    if (en->cursor_handler && (!en->cursor_handler_disabled || en->long_press_state == _ENTRY_LONG_PRESSED || en->long_press_state == _ENTRY_LONG_PRESSING))
3598      {
3599         Evas_Coord chx, chy;
3600         chx = x + xx;
3601         chy = y + yy + hh;
3602         evas_object_move(en->cursor_handler, chx, chy);
3603         if (((chx < en->viewport_region.x) || (chy < en->viewport_region.y) ||
3604              (chx > en->viewport_region.x + en->viewport_region.w) || (chy > en->viewport_region.y + en->viewport_region.h))
3605             && (en->cursor_handler_show))
3606           {
3607              evas_object_hide(en->cursor_handler);
3608              en->cursor_handler_show = EINA_FALSE;
3609           }
3610      }
3611 }
3612
3613 const char *
3614 _edje_entry_selection_get(Edje_Real_Part *rp)
3615 {
3616    Entry *en;
3617    
3618    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3619        (!rp->typedata.text)) return NULL;
3620    en = rp->typedata.text->entry_data;
3621    if (!en) return NULL;
3622    // get selection - convert to markup
3623    if ((!en->selection) && (en->have_selection))
3624      en->selection = evas_textblock_cursor_range_text_get
3625         (en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
3626    return en->selection;
3627 }
3628
3629 const char *
3630 _edje_entry_text_get(Edje_Real_Part *rp)
3631 {
3632    Entry *en;
3633    
3634    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3635        (!rp->typedata.text)) return NULL;
3636    en = rp->typedata.text->entry_data;
3637    if (!en) return NULL;
3638    // get text - convert to markup
3639    return evas_object_textblock_text_markup_get(rp->object);
3640 }
3641
3642 void
3643 _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
3644 {
3645    Entry *en;
3646    
3647    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3648        (!rp->typedata.text)) return;
3649    en = rp->typedata.text->entry_data;
3650    if (!en) return;
3651    _edje_entry_imf_context_reset(rp);
3652    // set text as markup
3653    _sel_clear(en->cursor, rp->object, en);
3654    evas_object_textblock_text_markup_set(rp->object, text);
3655    _edje_entry_set_cursor_start(rp);
3656
3657    _anchors_get(en->cursor, rp->object, en);
3658    _edje_emit(rp->edje, "entry,changed", rp->part->name);
3659
3660    // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
3661    if (!en->freeze)
3662      {
3663         _edje_entry_imf_cursor_info_set(en);
3664         _edje_entry_real_part_configure(rp);
3665      }
3666    //
3667
3668 #if 0
3669    /* Don't emit cursor changed cause it didn't. It's just init to 0. */
3670    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
3671 #endif
3672 }
3673
3674 void
3675 _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
3676 {
3677    Entry *en;
3678    
3679    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3680        (!rp->typedata.text)) return;
3681    en = rp->typedata.text->entry_data;
3682    Evas_Textblock_Cursor *end_cur;
3683    if (!en) return;
3684    end_cur = evas_object_textblock_cursor_new(rp->object);
3685    evas_textblock_cursor_paragraph_last(end_cur);
3686
3687    _text_filter_markup_prepend(en, end_cur, text);
3688    evas_textblock_cursor_free(end_cur);
3689
3690    /* We are updating according to the real cursor on purpose */
3691    _anchors_get(en->cursor, rp->object, en);
3692    _edje_emit(rp->edje, "entry,changed", rp->part->name);
3693
3694    _edje_entry_real_part_configure(rp);
3695 }
3696
3697 void
3698 _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
3699 {
3700    Entry *en;
3701    
3702    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3703        (!rp->typedata.text)) return;
3704    en = rp->typedata.text->entry_data;
3705    if (!en) return;
3706    _edje_entry_imf_context_reset(rp);
3707
3708    // prepend markup @ cursor pos
3709    if (en->have_selection)
3710      _range_del(en->cursor, rp->object, en);
3711    //xx
3712 //   evas_object_textblock_text_markup_prepend(en->cursor, text);
3713    _text_filter_markup_prepend(en, en->cursor, text);
3714    _anchors_get(en->cursor, rp->object, en);
3715    // TIZEN ONLY - START
3716    if (en->cursor_handler_show)
3717      {
3718         evas_object_hide(en->cursor_handler);
3719         en->cursor_handler_show = EINA_FALSE;
3720      }
3721    // TIZEN ONLY - END
3722    _edje_emit(rp->edje, "entry,changed", rp->part->name);
3723    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
3724
3725    _edje_entry_imf_cursor_info_set(en);
3726    _edje_entry_real_part_configure(rp);
3727 }
3728
3729 void
3730 _edje_entry_set_cursor_start(Edje_Real_Part *rp)
3731 {
3732    Entry *en;
3733    
3734    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3735        (!rp->typedata.text)) return;
3736    en = rp->typedata.text->entry_data;
3737    if (!en) return;
3738    _curs_start(en->cursor, rp->object, en);
3739
3740    // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
3741    if (!en->freeze)
3742       _edje_entry_imf_cursor_info_set(en);
3743 }
3744
3745 void
3746 _edje_entry_set_cursor_end(Edje_Real_Part *rp)
3747 {
3748    Entry *en;
3749    
3750    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3751        (!rp->typedata.text)) return;
3752    en = rp->typedata.text->entry_data;
3753    if (!en) return;
3754    _curs_end(en->cursor, rp->object, en);
3755
3756    _edje_entry_imf_cursor_info_set(en);
3757 }
3758
3759 void
3760 _edje_entry_select_none(Edje_Real_Part *rp)
3761 {
3762    Entry *en;
3763    
3764    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3765        (!rp->typedata.text)) return;
3766    en = rp->typedata.text->entry_data;
3767    if (!en) return;
3768    _sel_clear(en->cursor, rp->object, en);
3769 }
3770
3771 void
3772 _edje_entry_select_all(Edje_Real_Part *rp)
3773 {
3774    Entry *en;
3775    
3776    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3777        (!rp->typedata.text)) return;
3778    en = rp->typedata.text->entry_data;
3779    if (!en) return;
3780
3781    _edje_entry_imf_context_reset(rp);
3782
3783    _sel_clear(en->cursor, rp->object, en);
3784    _curs_start(en->cursor, rp->object, en);
3785    _sel_enable(en->cursor, rp->object, en);
3786    _sel_start(en->cursor, rp->object, en);
3787    _curs_end(en->cursor, rp->object, en);
3788    _sel_extend(en->cursor, rp->object, en);
3789
3790    _edje_entry_real_part_configure(rp);
3791
3792    // TIZEN ONLY - START
3793    en->select_allow = EINA_TRUE;
3794    en->had_sel = EINA_TRUE;
3795
3796    _edje_emit(en->rp->edje, "selection,end", en->rp->part->name);
3797    // TIZEN ONLY - END
3798 }
3799
3800 void
3801 _edje_entry_select_begin(Edje_Real_Part *rp)
3802 {
3803    Entry *en;
3804    
3805    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3806        (!rp->typedata.text)) return;
3807    en = rp->typedata.text->entry_data;
3808    if (!en) return;
3809
3810    _sel_clear(en->cursor, rp->object, en);
3811    _sel_enable(en->cursor, rp->object, en);
3812    _sel_start(en->cursor, rp->object, en);
3813    _sel_extend(en->cursor, rp->object, en);
3814
3815    _edje_entry_real_part_configure(rp);
3816 }
3817
3818 void
3819 _edje_entry_select_extend(Edje_Real_Part *rp)
3820 {
3821    Entry *en;
3822    
3823    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3824        (!rp->typedata.text)) return;
3825    en = rp->typedata.text->entry_data;
3826    if (!en) return;
3827    _sel_extend(en->cursor, rp->object, en);
3828
3829    _edje_entry_real_part_configure(rp);
3830 }
3831
3832 const Eina_List *
3833 _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
3834 {
3835    Entry *en;
3836    Eina_List *l;
3837    Anchor *an;
3838
3839    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3840        (!rp->typedata.text)) return NULL;
3841    en = rp->typedata.text->entry_data;
3842    if (!en) return NULL;
3843    EINA_LIST_FOREACH(en->anchors, l, an)
3844      {
3845         if (an->item) continue;
3846         if (!strcmp(anchor, an->name))
3847           return an->sel;
3848      }
3849    return NULL;
3850 }
3851
3852 const Eina_List *
3853 _edje_entry_anchors_list(Edje_Real_Part *rp)
3854 {
3855    Entry *en;
3856    Eina_List *l, *anchors = NULL;
3857    Anchor *an;
3858
3859    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3860        (!rp->typedata.text)) return NULL;
3861    en = rp->typedata.text->entry_data;
3862    if (!en) return NULL;
3863    if (!en->anchorlist)
3864      {
3865         EINA_LIST_FOREACH(en->anchors, l, an)
3866           {
3867              const char *n = an->name;
3868              if (an->item) continue;
3869              if (!n) n = "";
3870              anchors = eina_list_append(anchors, strdup(n));
3871           }
3872         en->anchorlist = anchors;
3873      }
3874    return en->anchorlist;
3875 }
3876
3877 Eina_Bool
3878 _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
3879 {
3880    Entry *en;
3881    Eina_List *l;
3882    Anchor *an;
3883
3884    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3885        (!rp->typedata.text)) return EINA_FALSE;
3886    en = rp->typedata.text->entry_data;
3887    if (!en) return EINA_FALSE;
3888    EINA_LIST_FOREACH(en->anchors, l, an)
3889      {
3890         if (an->item) continue;
3891         if (!strcmp(item, an->name))
3892           {
3893              evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
3894              return EINA_TRUE;
3895           }
3896      }
3897    return EINA_FALSE;
3898 }
3899
3900 const Eina_List *
3901 _edje_entry_items_list(Edje_Real_Part *rp)
3902 {
3903    Entry *en;
3904    Eina_List *l, *items = NULL;
3905    Anchor *an;
3906
3907    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3908        (!rp->typedata.text)) return NULL;
3909    en = rp->typedata.text->entry_data;
3910    if (!en) return NULL;
3911    if (!en->itemlist)
3912      {
3913         EINA_LIST_FOREACH(en->anchors, l, an)
3914           {
3915              const char *n = an->name;
3916              if (an->item) continue;
3917              if (!n) n = "";
3918              items = eina_list_append(items, strdup(n));
3919           }
3920         en->itemlist = items;
3921      }
3922    return en->itemlist;
3923 }
3924
3925 // TIZEN ONLY - START
3926 void
3927 _edje_entry_layout_region_set(Edje_Real_Part *rp, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
3928 {
3929    Entry *en;
3930
3931    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3932        (!rp->typedata.text)) return;
3933    en = rp->typedata.text->entry_data;
3934    if (!en) return;
3935
3936    en->layout_region.x = x;
3937    en->layout_region.y = y;
3938    en->layout_region.w = w;
3939    en->layout_region.h = h;
3940    _sel_update(en->cursor, rp->object, en);
3941 }
3942
3943 void
3944 _edje_entry_viewport_region_set(Edje_Real_Part *rp, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
3945 {
3946    Entry *en;
3947    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3948        (!rp->typedata.text)) return;
3949    en = rp->typedata.text->entry_data;
3950    if (!en) return;
3951
3952    en->viewport_region.x = x;
3953    en->viewport_region.y = y;
3954    en->viewport_region.w = w;
3955    en->viewport_region.h = h;
3956    _sel_update(en->cursor, rp->object, en);
3957 }
3958
3959 void
3960 _edje_entry_selection_handler_geometry_get(Edje_Real_Part *rp, Edje_Selection_Handler type, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3961 {
3962    Entry *en;
3963    Evas_Coord ex, ey, hx, hy, edx, edy, edw, edh;
3964    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3965        (!rp->typedata.text)) return;
3966    en = rp->typedata.text->entry_data;
3967    if (!en) return;
3968
3969    evas_object_geometry_get(rp->object, &ex, &ey, NULL, NULL);
3970    switch (type)
3971      {
3972       case EDJE_SELECTION_HANDLER_START:
3973          if (en->sel_handler_start)
3974            {
3975               evas_object_geometry_get(en->sel_handler_start, &hx, &hy, NULL, NULL);
3976               edje_object_part_geometry_get(en->sel_handler_start, "handle", &edx, &edy, &edw, &edh);
3977               hx = hx - ex + edx;
3978               hy = hy - ey + edy;
3979            }
3980          break;
3981       case EDJE_SELECTION_HANDLER_END:
3982          if (en->sel_handler_end)
3983            {
3984               evas_object_geometry_get(en->sel_handler_end, &hx, &hy, NULL, NULL);
3985               edje_object_part_geometry_get(en->sel_handler_end, "handle", &edx, &edy, &edw, &edh);
3986               hx = hx - ex + edx;
3987               hy = hy - ey + edy;
3988            }
3989          break;
3990       default:
3991          break;
3992      }
3993
3994    if (x) *x = hx;
3995    if (y) *y = hy;
3996    if (w) *w = edw;
3997    if (h) *h = edh;
3998 }
3999
4000 Eina_Bool
4001 _edje_entry_cursor_handler_disabled_get(Edje_Real_Part *rp)
4002 {
4003    Entry *en;
4004    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4005        (!rp->typedata.text)) return EINA_FALSE;
4006    en = rp->typedata.text->entry_data;
4007    if (!en) return EINA_FALSE;
4008    return en->cursor_handler_disabled;
4009 }
4010
4011 void
4012 _edje_entry_cursor_handler_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
4013 {
4014    Entry *en;
4015    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4016        (!rp->typedata.text)) return;
4017    en = rp->typedata.text->entry_data;
4018    if (!en) return;
4019
4020    en->cursor_handler_disabled = disabled;
4021 }
4022 // TIZEN ONLY - END
4023
4024 void
4025 _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
4026 {
4027    Evas_Coord x, y, w, h, xx, yy, ww, hh;
4028    Entry *en;
4029    Evas_Textblock_Cursor_Type cur_type;
4030    
4031    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4032        (!rp->typedata.text)) return;
4033    en = rp->typedata.text->entry_data;
4034    if (!en) return;
4035    switch (rp->part->cursor_mode)
4036      {
4037       case EDJE_ENTRY_CURSOR_MODE_BEFORE:
4038          cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
4039          break;
4040       case EDJE_ENTRY_CURSOR_MODE_UNDER:
4041          /* no break for a resaon */
4042       default:
4043          cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
4044      }
4045
4046    x = y = w = h = -1;
4047    xx = yy = ww = hh = -1;
4048    evas_object_geometry_get(rp->object, &x, &y, &w, &h);
4049    evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
4050    if (ww < 1) ww = 1;
4051    if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
4052      edje_object_size_min_restricted_calc(en->cursor_fg, &ww, NULL, ww, 0);
4053    if (hh < 1) hh = 1;
4054    if (cx) *cx = x + xx;
4055    if (cy) *cy = y + yy;
4056    if (cw) *cw = ww;
4057    if (ch) *ch = hh;
4058 }
4059
4060 void
4061 _edje_entry_user_insert(Edje_Real_Part *rp, const char *text)
4062 {
4063    Entry *en;
4064    Edje_Entry_Change_Info *info;
4065
4066    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4067        (!rp->typedata.text)) return;
4068    en = rp->typedata.text->entry_data;
4069    if (!en) return;
4070    info = calloc(1, sizeof(*info));
4071    if (!info) return;
4072    info->insert = EINA_TRUE;
4073    info->change.insert.plain_length = 1;
4074    info->change.insert.content = eina_stringshare_add(text);
4075      {
4076         char *tmp;
4077         tmp = evas_textblock_text_markup_to_utf8(rp->object,
4078                                                  info->change.insert.content);
4079         info->change.insert.plain_length = eina_unicode_utf8_get_len(tmp);
4080         free(tmp);
4081      }
4082
4083    if (en->have_selection)
4084      {
4085         _range_del_emit(rp->edje, en->cursor, rp->object, en);
4086         info->merge = EINA_TRUE;
4087      }
4088    info->change.insert.pos = evas_textblock_cursor_pos_get(en->cursor);
4089    _text_filter_markup_prepend(en, en->cursor, text);
4090    _anchors_get(en->cursor, rp->object, en);
4091    // TIZEN ONLY - START
4092    if (en->cursor_handler_show)
4093      {
4094         evas_object_hide(en->cursor_handler);
4095         en->cursor_handler_show = EINA_FALSE;
4096      }
4097    // TIZEN ONLY - END
4098    _edje_emit(rp->edje, "entry,changed", rp->part->name);
4099    _edje_emit_full(rp->edje, "entry,changed,user", rp->part->name,
4100                    info, _free_entry_change_info);
4101    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4102
4103    _edje_entry_imf_cursor_info_set(en);
4104    _edje_entry_real_part_configure(rp);
4105 }
4106
4107 void
4108 _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
4109 {
4110    Entry *en;
4111    
4112    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4113        (!rp->typedata.text)) return;
4114    en = rp->typedata.text->entry_data;
4115    if (!en) return;
4116    if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
4117      return;
4118    en->select_allow = allow;
4119 }
4120
4121 Eina_Bool
4122 _edje_entry_select_allow_get(const Edje_Real_Part *rp)
4123 {
4124    Entry *en;
4125    
4126    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4127        (!rp->typedata.text)) return EINA_FALSE;
4128    en = rp->typedata.text->entry_data;
4129    if (!en) return EINA_FALSE;
4130    return en->select_allow;
4131 }
4132
4133 void
4134 _edje_entry_select_abort(Edje_Real_Part *rp)
4135 {
4136    Entry *en;
4137    
4138    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4139        (!rp->typedata.text)) return;
4140    en = rp->typedata.text->entry_data;
4141    if (!en) return;
4142    if (en->selecting)
4143      {
4144         en->selecting = EINA_FALSE;
4145
4146         _edje_entry_imf_context_reset(rp);
4147         _edje_entry_imf_cursor_info_set(en);
4148         _edje_entry_real_part_configure(rp);
4149      }
4150 }
4151
4152 // TIZEN ONLY - START
4153 Eina_Bool
4154 _edje_entry_selection_geometry_get(Edje_Real_Part *rp, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
4155 {
4156    Entry *en = rp->typedata.text->entry_data;
4157    if (!en || !en->have_selection || !en->sel)
4158      return EINA_FALSE;
4159
4160    Sel *sel;
4161    Eina_List *l;
4162    Evas_Textblock_Rectangle rect;
4163    Evas_Coord tx, ty, tw, th;
4164
4165    l = en->sel;
4166    if (!l) return EINA_FALSE;
4167    sel = eina_list_data_get(l);
4168    if (!sel) return EINA_FALSE;
4169    rect = sel->rect;
4170    ty = rect.y;
4171    tw = rect.w;
4172
4173    l = eina_list_last(en->sel);
4174    if (!l) return EINA_FALSE;
4175    sel = eina_list_data_get(l);
4176    if (!sel) return EINA_FALSE;
4177    rect = sel->rect;
4178
4179    tx = rect.x;
4180    th = rect.y - ty + rect.h;
4181
4182    EINA_LIST_FOREACH(en->sel, l, sel)
4183      {
4184         if (sel)
4185           {
4186              if (tw < sel->rect.w) tw = sel->rect.w;
4187              if (sel->rect.x < tx) tx = sel->rect.x;
4188           }
4189      }
4190
4191    Evas_Coord vx, vy;
4192    evas_object_geometry_get(rp->object, &vx, &vy, NULL, NULL);
4193    tx += vx;
4194    ty += vy;
4195
4196    if (x) *x = tx;
4197    if (y) *y = ty;
4198    if (w) *w = tw;
4199    if (h) *h = th;
4200
4201    return EINA_TRUE;
4202 }
4203 // TIZEN ONLY - END
4204
4205 void *
4206 _edje_entry_imf_context_get(Edje_Real_Part *rp)
4207 {
4208    Entry *en;
4209    
4210    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4211        (!rp->typedata.text)) return NULL;
4212    en = rp->typedata.text->entry_data;
4213    if (!en) return NULL;
4214
4215 #ifdef HAVE_ECORE_IMF
4216    return en->imf_context;
4217 #else
4218    return NULL;
4219 #endif
4220 }
4221
4222 void
4223 _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type)
4224 {
4225    Entry *en;
4226    
4227    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4228        (!rp->typedata.text)) return;
4229    en = rp->typedata.text->entry_data;
4230    if (!en) return;
4231
4232    if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
4233      autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4234
4235 #ifdef HAVE_ECORE_IMF
4236    if (en->imf_context)
4237      ecore_imf_context_autocapital_type_set(en->imf_context, autocapital_type);
4238 #endif
4239 }
4240
4241 Edje_Text_Autocapital_Type
4242 _edje_entry_autocapital_type_get(Edje_Real_Part *rp)
4243 {
4244    Entry *en;
4245    
4246    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4247        (!rp->typedata.text)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4248    en = rp->typedata.text->entry_data;
4249    if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4250
4251 #ifdef HAVE_ECORE_IMF
4252    if (en->imf_context)
4253      return ecore_imf_context_autocapital_type_get(en->imf_context);
4254 #endif
4255
4256    return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4257 }
4258
4259 void
4260 _edje_entry_prediction_allow_set(Edje_Real_Part *rp, Eina_Bool prediction)
4261 {
4262    Entry *en;
4263    
4264    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4265        (!rp->typedata.text)) return;
4266    en = rp->typedata.text->entry_data;
4267    if (!en) return;
4268    en->prediction_allow = prediction;
4269 #ifdef HAVE_ECORE_IMF
4270    if (en->imf_context)
4271      ecore_imf_context_prediction_allow_set(en->imf_context, prediction);
4272 #endif
4273 }
4274
4275 Eina_Bool
4276 _edje_entry_prediction_allow_get(Edje_Real_Part *rp)
4277 {
4278    Entry *en;
4279    
4280    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4281        (!rp->typedata.text)) return EINA_FALSE;
4282    en = rp->typedata.text->entry_data;
4283    if (!en) return EINA_FALSE;
4284    return en->prediction_allow;
4285 }
4286
4287 void
4288 _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled)
4289 {
4290    Entry *en;
4291    
4292    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4293        (!rp->typedata.text)) return;
4294    en = rp->typedata.text->entry_data;
4295    if (!en) return;
4296    en->input_panel_enable = enabled;
4297 #ifdef HAVE_ECORE_IMF
4298    if (en->imf_context)
4299      ecore_imf_context_input_panel_enabled_set(en->imf_context, enabled);
4300 #endif
4301 }
4302
4303 Eina_Bool
4304 _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp)
4305 {
4306    Entry *en;
4307    
4308    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4309        (!rp->typedata.text)) return EINA_FALSE;
4310    en = rp->typedata.text->entry_data;
4311    if (!en) return EINA_FALSE;
4312    return en->input_panel_enable;
4313 }
4314
4315 void
4316 _edje_entry_input_panel_show(Edje_Real_Part *rp)
4317 {
4318    Entry *en;
4319    
4320    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4321        (!rp->typedata.text)) return;
4322    en = rp->typedata.text->entry_data;
4323    if (!en) return;
4324 #ifdef HAVE_ECORE_IMF
4325    if (en->imf_context)
4326      ecore_imf_context_input_panel_show(en->imf_context);
4327 #endif
4328 }
4329
4330 void
4331 _edje_entry_input_panel_hide(Edje_Real_Part *rp)
4332 {
4333    Entry *en;
4334    
4335    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4336        (!rp->typedata.text)) return;
4337    en = rp->typedata.text->entry_data;
4338    if (!en) return;
4339 #ifdef HAVE_ECORE_IMF
4340    if (en->imf_context)
4341      ecore_imf_context_input_panel_hide(en->imf_context);
4342 #endif
4343 }
4344
4345 void
4346 _edje_entry_input_panel_language_set(Edje_Real_Part *rp, Edje_Input_Panel_Lang lang)
4347 {
4348    Entry *en;
4349    
4350    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4351        (!rp->typedata.text)) return;
4352    en = rp->typedata.text->entry_data;
4353    if (!en) return;
4354    en->input_panel_lang = lang;
4355 #ifdef HAVE_ECORE_IMF
4356    if (en->imf_context)
4357      ecore_imf_context_input_panel_language_set(en->imf_context, lang);
4358 #endif
4359 }
4360
4361 Edje_Input_Panel_Lang
4362 _edje_entry_input_panel_language_get(Edje_Real_Part *rp)
4363 {
4364    Entry *en;
4365    
4366    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4367        (!rp->typedata.text)) return EDJE_INPUT_PANEL_LANG_AUTOMATIC;
4368    en = rp->typedata.text->entry_data;
4369    if (!en) return EDJE_INPUT_PANEL_LANG_AUTOMATIC;
4370    return en->input_panel_lang;
4371 }
4372
4373 #ifdef HAVE_ECORE_IMF
4374 void
4375 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data, int len)
4376 #else
4377 void
4378 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data __UNUSED__, int len __UNUSED__)
4379 #endif
4380 {
4381    Entry *en;
4382    
4383    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4384        (!rp->typedata.text)) return;
4385    en = rp->typedata.text->entry_data;
4386    if (!en) return;
4387 #ifdef HAVE_ECORE_IMF
4388    if (en->imf_context)
4389      ecore_imf_context_input_panel_imdata_set(en->imf_context, data, len);
4390 #endif
4391 }
4392
4393 #ifdef HAVE_ECORE_IMF
4394 void
4395 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data, int *len)
4396 #else
4397 void
4398 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data __UNUSED__, int *len __UNUSED__)
4399 #endif
4400 {
4401    Entry *en;
4402    
4403    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4404        (!rp->typedata.text)) return;
4405    en = rp->typedata.text->entry_data;
4406    if (!en) return;
4407 #ifdef HAVE_ECORE_IMF
4408    if (en->imf_context)
4409      ecore_imf_context_input_panel_imdata_get(en->imf_context, data, len);
4410 #endif
4411 }
4412
4413 #ifdef HAVE_ECORE_IMF
4414 void
4415 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type)
4416 #else
4417 void
4418 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type __UNUSED__)
4419 #endif
4420 {
4421    Entry *en;
4422    
4423    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4424        (!rp->typedata.text)) return;
4425    en = rp->typedata.text->entry_data;
4426    if (!en) return;
4427 #ifdef HAVE_ECORE_IMF
4428    if (en->imf_context)
4429      ecore_imf_context_input_panel_return_key_type_set(en->imf_context, return_key_type);
4430 #endif
4431 }
4432
4433 Edje_Input_Panel_Return_Key_Type
4434 _edje_entry_input_panel_return_key_type_get(Edje_Real_Part *rp)
4435 {
4436    Entry *en;
4437    
4438    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4439        (!rp->typedata.text)) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4440    en = rp->typedata.text->entry_data;
4441    if (!en) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4442 #ifdef HAVE_ECORE_IMF
4443    if (en->imf_context)
4444      return ecore_imf_context_input_panel_return_key_type_get(en->imf_context);
4445 #endif
4446    return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4447 }
4448
4449 #ifdef HAVE_ECORE_IMF
4450 void
4451 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
4452 #else
4453 void
4454 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled __UNUSED__)
4455 #endif
4456 {
4457    Entry *en;
4458    
4459    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4460        (!rp->typedata.text)) return;
4461    en = rp->typedata.text->entry_data;
4462    if (!en) return;
4463 #ifdef HAVE_ECORE_IMF
4464    if (en->imf_context)
4465      ecore_imf_context_input_panel_return_key_disabled_set(en->imf_context, disabled);
4466 #endif
4467 }
4468
4469 Eina_Bool
4470 _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp)
4471 {
4472    Entry *en;
4473    
4474    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4475        (!rp->typedata.text)) return EINA_FALSE;
4476    en = rp->typedata.text->entry_data;
4477    if (!en) return EINA_FALSE;
4478 #ifdef HAVE_ECORE_IMF
4479    if (en->imf_context)
4480      return ecore_imf_context_input_panel_return_key_disabled_get(en->imf_context);
4481 #endif
4482    return EINA_FALSE;
4483 }
4484
4485 static Evas_Textblock_Cursor *
4486 _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
4487 {
4488    Entry *en;
4489    
4490    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4491        (!rp->typedata.text)) return NULL;
4492    en = rp->typedata.text->entry_data;
4493    if (!en) return NULL;
4494    switch (cur)
4495      {
4496       case EDJE_CURSOR_MAIN:
4497          return en->cursor;
4498       case EDJE_CURSOR_SELECTION_BEGIN:
4499          return en->sel_start;
4500       case EDJE_CURSOR_SELECTION_END:
4501          return en->sel_end;
4502       case EDJE_CURSOR_PREEDIT_START:
4503          if (!en->preedit_start)
4504            en->preedit_start = evas_object_textblock_cursor_new(rp->object);
4505          return en->preedit_start;
4506       case EDJE_CURSOR_PREEDIT_END:
4507          if (!en->preedit_end)
4508            en->preedit_end = evas_object_textblock_cursor_new(rp->object);
4509          return en->preedit_end;
4510       case EDJE_CURSOR_USER:
4511          if (!en->cursor_user)
4512            en->cursor_user = evas_object_textblock_cursor_new(rp->object);
4513          return en->cursor_user;
4514       case EDJE_CURSOR_USER_EXTRA:
4515          if (!en->cursor_user_extra)
4516            en->cursor_user_extra = evas_object_textblock_cursor_new(rp->object);
4517          return en->cursor_user_extra;
4518       default:
4519          break;
4520      }
4521    return NULL;
4522 }
4523
4524 Eina_Bool
4525 _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
4526 {
4527    Entry *en;
4528    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4529    
4530    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4531        (!rp->typedata.text)) return EINA_FALSE;
4532    en = rp->typedata.text->entry_data;
4533    if (!en) return EINA_FALSE;
4534    
4535    if (!c) return EINA_FALSE;
4536
4537    _edje_entry_imf_context_reset(rp);
4538
4539    if (!evas_textblock_cursor_char_next(c))
4540      {
4541         return EINA_FALSE;
4542      }
4543    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4544    _edje_entry_imf_cursor_info_set(en);
4545
4546    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4547    _edje_entry_real_part_configure(rp);
4548    return EINA_TRUE;
4549 }
4550
4551 Eina_Bool
4552 _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
4553 {
4554    Entry *en;
4555    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4556    
4557    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4558        (!rp->typedata.text)) return EINA_FALSE;
4559    en = rp->typedata.text->entry_data;
4560    if (!en) return EINA_FALSE;
4561    if (!c) return EINA_FALSE;
4562
4563    _edje_entry_imf_context_reset(rp);
4564
4565    if (!evas_textblock_cursor_char_prev(c))
4566      {
4567         if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
4568         else return EINA_FALSE;
4569      }
4570 ok:
4571    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4572
4573    _edje_entry_imf_cursor_info_set(en);
4574
4575    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4576    _edje_entry_real_part_configure(rp);
4577    return EINA_TRUE;
4578 }
4579
4580 Eina_Bool
4581 _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
4582 {
4583    Entry *en;
4584    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4585    Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
4586    int ln;
4587    
4588    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4589        (!rp->typedata.text)) return EINA_FALSE;
4590    en = rp->typedata.text->entry_data;
4591    if (!en) return EINA_FALSE;
4592    if (!c) return EINA_FALSE;
4593
4594    _edje_entry_imf_context_reset(rp);
4595
4596    ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
4597    ln--;
4598    if (ln < 0) return EINA_FALSE;
4599    if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
4600                                                        &lx, &ly, &lw, &lh))
4601      return EINA_FALSE;
4602    evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
4603    if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
4604      {
4605         if (cx < (lx + (lw / 2)))
4606           evas_textblock_cursor_line_char_last(c);
4607         else
4608           evas_textblock_cursor_line_char_last(c);
4609      }
4610    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4611
4612    _edje_entry_imf_cursor_info_set(en);
4613
4614    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4615    _edje_entry_real_part_configure(rp);
4616    return EINA_TRUE;
4617 }
4618
4619 Eina_Bool
4620 _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
4621 {
4622    Entry *en;
4623    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4624    Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
4625    int ln;
4626
4627    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4628        (!rp->typedata.text)) return EINA_FALSE;
4629    en = rp->typedata.text->entry_data;
4630    if (!en) return EINA_FALSE;
4631    if (!c) return EINA_FALSE;
4632
4633    _edje_entry_imf_context_reset(rp);
4634
4635    ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
4636    ln++;
4637    if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
4638                                                        &lx, &ly, &lw, &lh))
4639      return EINA_FALSE;
4640    evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
4641    if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
4642      {
4643         if (cx < (lx + (lw / 2)))
4644           evas_textblock_cursor_line_char_last(c);
4645         else
4646           evas_textblock_cursor_line_char_last(c);
4647      }
4648    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4649
4650    _edje_entry_imf_cursor_info_set(en);
4651    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4652    _edje_entry_real_part_configure(rp);
4653    return EINA_TRUE;
4654 }
4655
4656 void
4657 _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
4658 {
4659    Entry *en;
4660    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4661    
4662    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4663        (!rp->typedata.text)) return;
4664    en = rp->typedata.text->entry_data;
4665    if (!en) return;
4666    if (!c) return;
4667
4668    _edje_entry_imf_context_reset(rp);
4669
4670    evas_textblock_cursor_paragraph_first(c);
4671    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4672
4673    _edje_entry_imf_cursor_info_set(en);
4674    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4675    _edje_entry_real_part_configure(rp);
4676 }
4677
4678 void
4679 _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
4680 {
4681    Entry *en;
4682    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4683    
4684    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4685        (!rp->typedata.text)) return;
4686    en = rp->typedata.text->entry_data;
4687    if (!en) return;
4688    if (!c) return;
4689
4690    _edje_entry_imf_context_reset(rp);
4691
4692    _curs_end(c, rp->object, rp->typedata.text->entry_data);
4693    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4694
4695    _edje_entry_imf_cursor_info_set(en);
4696
4697    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4698    _edje_entry_real_part_configure(rp);
4699 }
4700
4701 void
4702 _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
4703 {
4704    Entry *en;
4705    Evas_Textblock_Cursor *c;
4706    Evas_Textblock_Cursor *d;
4707
4708    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4709        (!rp->typedata.text)) return;
4710    en = rp->typedata.text->entry_data;
4711    if (!en) return;
4712    c = _cursor_get(rp, cur);
4713    if (!c) return;
4714    d = _cursor_get(rp, dst);
4715    if (!d) return;
4716    evas_textblock_cursor_copy(c, d);
4717    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4718
4719    _edje_entry_imf_context_reset(rp);
4720    _edje_entry_imf_cursor_info_set(en);
4721    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4722    _edje_entry_real_part_configure(rp);
4723 }
4724
4725 void
4726 _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
4727 {
4728    Entry *en;
4729    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4730    
4731    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4732        (!rp->typedata.text)) return;
4733    en = rp->typedata.text->entry_data;
4734    if (!en) return;
4735    if (!c) return;
4736    _edje_entry_imf_context_reset(rp);
4737
4738    evas_textblock_cursor_line_char_first(c);
4739    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4740
4741    _edje_entry_imf_cursor_info_set(en);
4742
4743    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4744    _edje_entry_real_part_configure(rp);
4745 }
4746
4747 void
4748 _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
4749 {
4750    Entry *en;
4751    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4752    
4753    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4754        (!rp->typedata.text)) return;
4755    en = rp->typedata.text->entry_data;
4756    if (!en) return;
4757    if (!c) return;
4758    _edje_entry_imf_context_reset(rp);
4759    evas_textblock_cursor_line_char_last(c);
4760    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4761
4762    _edje_entry_imf_cursor_info_set(en);
4763    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4764    _edje_entry_real_part_configure(rp);
4765 }
4766
4767 Eina_Bool
4768 _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
4769                              Evas_Coord x, Evas_Coord y)
4770 {
4771    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4772    if (!c) return EINA_FALSE;
4773    return evas_textblock_cursor_char_coord_set(c, x, y);
4774 }
4775
4776 Eina_Bool
4777 _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
4778 {
4779    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4780    if (!c) return EINA_FALSE;
4781    if (evas_textblock_cursor_is_format(c)) return EINA_TRUE;
4782    return EINA_FALSE;
4783 }
4784
4785 Eina_Bool
4786 _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
4787 {
4788    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4789    if (!c) return EINA_FALSE;
4790    return evas_textblock_cursor_format_is_visible_get(c);
4791 }
4792
4793 char *
4794 _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
4795 {
4796    static char *s = NULL;
4797    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4798
4799    if (!c) return NULL;
4800    if (s)
4801      {
4802         free(s);
4803         s = NULL;
4804      }
4805
4806    s = evas_textblock_cursor_content_get(c);
4807    return s;
4808 }
4809
4810 void
4811 _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
4812 {
4813    Entry *en;
4814    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4815    
4816    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4817        (!rp->typedata.text)) return;
4818    en = rp->typedata.text->entry_data;
4819    if (!en) return;
4820    if (!c) return;
4821    /* Abort if cursor position didn't really change */
4822    if (evas_textblock_cursor_pos_get(c) == pos)
4823      return;
4824
4825    _edje_entry_imf_context_reset(rp);
4826    evas_textblock_cursor_pos_set(c, pos);
4827    _sel_update(c, rp->object, rp->typedata.text->entry_data);
4828
4829    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4830    // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
4831    if (!en->freeze)
4832      {
4833         _edje_entry_imf_cursor_info_set(en);
4834         _edje_entry_real_part_configure(rp);
4835      }
4836    //
4837 }
4838
4839 int
4840 _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur)
4841 {
4842    Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4843    if (!c) return 0;
4844    return evas_textblock_cursor_pos_get(c);
4845 }
4846
4847 void
4848 _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout)
4849 {
4850    Entry *en;
4851    
4852    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4853        (!rp->typedata.text)) return;
4854    en = rp->typedata.text->entry_data;
4855    if (!en) return;
4856 #ifdef HAVE_ECORE_IMF
4857    if (en->imf_context)
4858      ecore_imf_context_input_panel_layout_set(en->imf_context, layout);
4859 #else
4860    (void) layout;
4861 #endif
4862 }
4863
4864 Edje_Input_Panel_Layout
4865 _edje_entry_input_panel_layout_get(Edje_Real_Part *rp)
4866 {
4867    Entry *en;
4868    
4869    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4870        (!rp->typedata.text)) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4871    en = rp->typedata.text->entry_data;
4872    if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4873 #ifdef HAVE_ECORE_IMF
4874    if (en->imf_context)
4875      return ecore_imf_context_input_panel_layout_get(en->imf_context);
4876 #endif
4877
4878    return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4879 }
4880
4881 void
4882 _edje_entry_input_panel_layout_variation_set(Edje_Real_Part *rp, int variation)
4883 {
4884    Entry *en;
4885
4886    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4887        (!rp->typedata.text)) return;
4888    en = rp->typedata.text->entry_data;
4889    if (!en) return;
4890 #ifdef HAVE_ECORE_IMF
4891    if (en->imf_context)
4892      ecore_imf_context_input_panel_layout_variation_set(en->imf_context, variation);
4893 #else
4894    (void) variation;
4895 #endif
4896 }
4897
4898 int
4899 _edje_entry_input_panel_layout_variation_get(Edje_Real_Part *rp)
4900 {
4901    Entry *en;
4902
4903    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4904        (!rp->typedata.text)) return 0;
4905    en = rp->typedata.text->entry_data;
4906    if (!en) return 0;
4907 #ifdef HAVE_ECORE_IMF
4908    if (en->imf_context)
4909      return ecore_imf_context_input_panel_layout_variation_get(en->imf_context);
4910 #endif
4911
4912    return 0;
4913 }
4914
4915 void
4916 _edje_entry_imf_context_reset(Edje_Real_Part *rp)
4917 {
4918    Entry *en;
4919    
4920    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4921        (!rp->typedata.text)) return;
4922    en = rp->typedata.text->entry_data;
4923    if (!en) return;
4924 #ifdef HAVE_ECORE_IMF
4925    if (en->imf_context)
4926      ecore_imf_context_reset(en->imf_context);
4927    if (en->commit_cancel)
4928       en->commit_cancel = EINA_FALSE;
4929 #endif
4930 }
4931
4932 static void
4933 _edje_entry_imf_cursor_location_set(Entry *en)
4934 {
4935 #ifdef HAVE_ECORE_IMF
4936    Evas_Coord cx, cy, cw, ch;
4937    if (!en || !en->rp || !en->imf_context) return;
4938
4939    _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch);
4940    ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch);
4941 #else
4942    (void) en;
4943 #endif
4944 }
4945
4946 static void
4947 _edje_entry_imf_cursor_info_set(Entry *en)
4948 {
4949    int cursor_pos;
4950
4951 #ifdef HAVE_ECORE_IMF
4952    if (!en || !en->rp || !en->imf_context) return;
4953
4954    if (en->have_selection)
4955      {
4956         if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
4957           cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
4958         else
4959           cursor_pos = evas_textblock_cursor_pos_get(en->sel_end);
4960      }
4961    else
4962      cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
4963
4964    ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos);
4965
4966    _edje_entry_imf_cursor_location_set(en);
4967 #else
4968    (void) en;
4969 #endif
4970 }
4971
4972 #ifdef HAVE_ECORE_IMF
4973 static Eina_Bool
4974 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos)
4975 {
4976    Edje *ed = data;
4977    Edje_Real_Part *rp = ed->focused_part;
4978    Entry *en = NULL;
4979    const char *str;
4980    char *plain_text;
4981    Eina_Strbuf *buf = NULL;
4982
4983    if (!rp) return EINA_FALSE;
4984    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4985        (!rp->typedata.text)) return EINA_FALSE;
4986    else
4987      en = rp->typedata.text->entry_data;
4988    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4989        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4990      return EINA_FALSE;
4991
4992    if (text)
4993      {
4994         str = _edje_entry_text_get(rp);
4995         if (str)
4996           {
4997              plain_text = evas_textblock_text_markup_to_utf8(NULL, str);
4998
4999              if (plain_text)
5000                {
5001                   if (en->have_selection)
5002                     {
5003                        buf = eina_strbuf_new();
5004
5005                        if (en->sel_start)
5006                          eina_strbuf_append_n(buf, plain_text, evas_textblock_cursor_pos_get(en->sel_start));
5007                        else
5008                          eina_strbuf_append(buf, plain_text);
5009
5010                        *text = strdup(eina_strbuf_string_get(buf));
5011                        eina_strbuf_free(buf);
5012                     }
5013                   else
5014                     *text = strdup(plain_text);
5015
5016                   free(plain_text);
5017                   plain_text = NULL;
5018                }
5019              else
5020                *text = strdup("");
5021           }
5022         else
5023           *text = strdup("");
5024      }
5025
5026    if (cursor_pos)
5027      {
5028         if (en->have_selection && en->sel_start)
5029           *cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
5030         else if (en->cursor)
5031           *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
5032         else
5033           *cursor_pos = 0;
5034      }
5035
5036    return EINA_TRUE;
5037 }
5038
5039 static void
5040 _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
5041 {
5042    Edje *ed = data;
5043    Edje_Real_Part *rp = ed->focused_part;
5044    Entry *en = NULL;
5045    char *commit_str = event_info;
5046    int start_pos;
5047
5048    if ((!rp)) return;
5049    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5050        (!rp->typedata.text)) return;
5051    else
5052      en = rp->typedata.text->entry_data;
5053    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5054        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5055      return;
5056
5057    if (en->have_selection)
5058      {
5059         if (strcmp(commit_str, ""))
5060           {
5061              /* delete selected characters */
5062              _range_del_emit(ed, en->cursor, rp->object, en);
5063              _sel_clear(en->cursor, rp->object, en);
5064           }
5065      }
5066
5067    start_pos = evas_textblock_cursor_pos_get(en->cursor);
5068
5069    /* delete preedit characters */
5070    _preedit_del(en);
5071    _preedit_clear(en);
5072
5073    // Skipping commit process when it is useless
5074    if (en->commit_cancel)
5075      {
5076         en->commit_cancel = EINA_FALSE;
5077         return;
5078      }
5079
5080    if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5081        _edje_password_show_last)
5082      _edje_entry_hide_visible_password(en->rp);
5083    if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5084        _edje_password_show_last && (!en->preedit_start))
5085      {
5086         _text_filter_format_prepend(en, en->cursor, "+ password=off");
5087         _text_filter_text_prepend(en, en->cursor, commit_str);
5088         _text_filter_format_prepend(en, en->cursor, "- password");
5089
5090         if (en->pw_timer)
5091           {
5092              ecore_timer_del(en->pw_timer);
5093              en->pw_timer = NULL;
5094           }
5095         en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
5096                                        _password_timer_cb, en);
5097      }
5098    else
5099      _text_filter_text_prepend(en, en->cursor, commit_str);
5100
5101
5102    _edje_entry_imf_cursor_info_set(en);
5103    _anchors_get(en->cursor, rp->object, en);
5104    // TIZEN ONLY - START
5105    if (en->cursor_handler_show)
5106      {
5107         evas_object_hide(en->cursor_handler);
5108         en->cursor_handler_show = EINA_FALSE;
5109      }
5110    // TIZEN ONLY - END
5111    _edje_emit(rp->edje, "entry,changed", rp->part->name);
5112
5113      {
5114         Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
5115         info->insert = EINA_TRUE;
5116         info->change.insert.pos = start_pos;
5117         info->change.insert.content = eina_stringshare_add(commit_str);
5118         info->change.insert.plain_length =
5119            eina_unicode_utf8_get_len(info->change.insert.content);
5120         _edje_emit_full(ed, "entry,changed,user", rp->part->name,
5121                         info, _free_entry_change_info);
5122         _edje_emit(ed, "cursor,changed", rp->part->name);
5123      }
5124
5125    _edje_entry_imf_cursor_info_set(en);
5126    _edje_entry_real_part_configure(rp);
5127 }
5128
5129 static void
5130 _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info __UNUSED__)
5131 {
5132    Edje *ed = data;
5133    Edje_Real_Part *rp = ed->focused_part;
5134    Entry *en = NULL;
5135    int cursor_pos;
5136    int preedit_start_pos, preedit_end_pos;
5137    char *preedit_string;
5138    char *preedit_tag_index;
5139    char *pretag = NULL;
5140    char *markup_txt = NULL;
5141    char *tagname[] = {NULL, "preedit", "preedit_sel", "preedit_sel",
5142                       "preedit_sub1", "preedit_sub2", "preedit_sub3", "preedit_sub4"};
5143    int i;
5144    size_t preedit_type_size = sizeof(tagname) / sizeof(tagname[0]);
5145    Eina_Bool preedit_end_state = EINA_FALSE;
5146    Eina_List *attrs = NULL, *l = NULL;
5147    Ecore_IMF_Preedit_Attr *attr;
5148    Eina_Strbuf *buf;
5149    Eina_Strbuf *preedit_attr_str;
5150
5151    if ((!rp)) return;
5152
5153    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5154        (!rp->typedata.text)) return;
5155    else
5156      en = rp->typedata.text->entry_data;
5157    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5158        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5159      return;
5160
5161    if (!en->imf_context) return;
5162    // TIZEN ONLY - START
5163    if (en->cursor_handler_show)
5164      {
5165         evas_object_hide(en->cursor_handler);
5166         en->cursor_handler_show = EINA_FALSE;
5167      }
5168    // TIZEN ONLY - END
5169
5170    ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
5171                                                         &preedit_string,
5172                                                         &attrs, &cursor_pos);
5173    if (!preedit_string) return;
5174
5175    if (!strcmp(preedit_string, ""))
5176      preedit_end_state = EINA_TRUE;
5177
5178    if (en->have_selection && !preedit_end_state)
5179      {
5180         /* delete selected characters */
5181         _range_del_emit(ed, en->cursor, rp->object, en);
5182      }
5183
5184    if (en->preedit_start && en->preedit_end)
5185      {
5186         /* extract the tag string */
5187         char *str = evas_textblock_cursor_range_text_get(en->preedit_start, en->preedit_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
5188
5189         if (str)
5190           {
5191              preedit_tag_index = strstr(str, "<preedit");
5192
5193              if ((preedit_tag_index - str) > 0)
5194                {
5195                   pretag = calloc(1, sizeof(char)*(preedit_tag_index-str+1));
5196                   if (preedit_tag_index)
5197                     {
5198                        strncpy(pretag, str, preedit_tag_index-str);
5199                     }
5200                }
5201              free(str);
5202           }
5203      }
5204
5205    /* delete preedit characters */
5206    _preedit_del(en);
5207
5208    preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
5209
5210    /* restore previous tag */
5211    if (pretag)
5212      {
5213         _text_filter_markup_prepend(en, en->cursor, pretag);
5214         free(pretag);
5215      }
5216
5217    /* insert preedit character(s) */
5218    if (strlen(preedit_string) > 0)
5219      {
5220         buf = eina_strbuf_new();
5221         if (attrs)
5222           {
5223              EINA_LIST_FOREACH(attrs, l, attr)
5224                {
5225                   if (attr->preedit_type <= preedit_type_size &&
5226                       tagname[attr->preedit_type])
5227                     {
5228                        preedit_attr_str = eina_strbuf_new();
5229                        if (preedit_attr_str)
5230                          {
5231                             eina_strbuf_append_n(preedit_attr_str, preedit_string + attr->start_index, attr->end_index - attr->start_index);
5232                             markup_txt = evas_textblock_text_utf8_to_markup(NULL, eina_strbuf_string_get(preedit_attr_str));
5233
5234                             if (markup_txt)
5235                               {
5236                                  eina_strbuf_append_printf(buf, "<%s>%s</%s>", tagname[attr->preedit_type], markup_txt, tagname[attr->preedit_type]);
5237                                  free(markup_txt);
5238                               }
5239                             eina_strbuf_free(preedit_attr_str);
5240                          }
5241                     }
5242                   else
5243                     eina_strbuf_append(buf, preedit_string);
5244                }
5245           }
5246         else
5247           {
5248              eina_strbuf_append(buf, preedit_string);
5249           }
5250
5251         // For skipping useless commit
5252         if (!preedit_end_state)
5253            en->have_preedit = EINA_TRUE;
5254
5255         if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5256             _edje_password_show_last)
5257           {
5258              _edje_entry_hide_visible_password(en->rp);
5259              _text_filter_format_prepend(en, en->cursor, "+ password=off");
5260              _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
5261              _text_filter_format_prepend(en, en->cursor, "- password");
5262              if (en->pw_timer)
5263                {
5264                   ecore_timer_del(en->pw_timer);
5265                   en->pw_timer = NULL;
5266                }
5267              en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
5268                                             _password_timer_cb, en);
5269           }
5270         else
5271           {
5272              _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
5273           }
5274         eina_strbuf_free(buf);
5275      }
5276
5277    if (!preedit_end_state)
5278      {
5279         /* set preedit start cursor */
5280         if (!en->preedit_start)
5281           en->preedit_start = evas_object_textblock_cursor_new(rp->object);
5282         evas_textblock_cursor_copy(en->cursor, en->preedit_start);
5283
5284         /* set preedit end cursor */
5285         if (!en->preedit_end)
5286           en->preedit_end = evas_object_textblock_cursor_new(rp->object);
5287         evas_textblock_cursor_copy(en->cursor, en->preedit_end);
5288
5289         preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor);
5290
5291         for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++)
5292           {
5293              evas_textblock_cursor_char_prev(en->preedit_start);
5294           }
5295
5296         en->have_preedit = EINA_TRUE;
5297
5298         /* set cursor position */
5299         evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos);
5300      }
5301
5302    _edje_entry_imf_cursor_info_set(en);
5303    _anchors_get(en->cursor, rp->object, en);
5304    _edje_emit(rp->edje, "preedit,changed", rp->part->name);
5305    _edje_emit(ed, "cursor,changed", rp->part->name);
5306
5307    /* delete attribute list */
5308    if (attrs)
5309      {
5310         EINA_LIST_FREE(attrs, attr) free(attr);
5311      }
5312
5313    free(preedit_string);
5314 }
5315
5316 static void
5317 _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
5318 {
5319    Edje *ed = data;
5320    Edje_Real_Part *rp = ed->focused_part;
5321    Entry *en = NULL;
5322    Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
5323    Evas_Textblock_Cursor *del_start, *del_end;
5324    int cursor_pos;
5325
5326    if ((!rp) || (!ev)) return;
5327    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5328        (!rp->typedata.text)) return;
5329    else
5330      en = rp->typedata.text->entry_data;
5331    if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5332        (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5333      return;
5334
5335    cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
5336
5337    del_start = evas_object_textblock_cursor_new(en->rp->object);
5338    evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
5339
5340    del_end = evas_object_textblock_cursor_new(en->rp->object);
5341    evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars);
5342
5343    evas_textblock_cursor_range_delete(del_start, del_end);
5344
5345    evas_textblock_cursor_free(del_start);
5346    evas_textblock_cursor_free(del_end);
5347 }
5348 #endif
5349
5350
5351 //////////////////////////////////////  TIZEN ONLY(130129)  : START //////////////////////////////////
5352 void _edje_entry_freeze(Edje_Real_Part *rp)
5353 {
5354    Entry *en = NULL;
5355
5356    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5357        (!rp->typedata.text)) return;
5358
5359    en = rp->typedata.text->entry_data;
5360    if (!en) return;
5361
5362    en->freeze = EINA_TRUE;
5363 }
5364
5365 void _edje_entry_thaw(Edje_Real_Part *rp)
5366 {
5367    Entry *en = NULL;
5368
5369    if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5370        (!rp->typedata.text)) return;
5371
5372    en = rp->typedata.text->entry_data;
5373    if (!en) return;
5374
5375    en->freeze = EINA_FALSE;
5376
5377    _edje_entry_imf_cursor_info_set(en);
5378    _edje_entry_real_part_configure(rp);
5379 }
5380 ///////////////////////////////////////////  TIZEN ONLY : END   ////////////////////////////////////////
5381
5382 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/