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