1 #include "edje_private.h"
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);
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);
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);
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);
25 typedef struct _Entry Entry;
26 typedef struct _Sel Sel;
27 typedef struct _Anchor Anchor;
30 typedef enum _Entry_Long_Press_State
34 _ENTRY_LONG_PRESS_RELEASED
35 } Entry_Long_Press_State;
38 static void _edje_entry_imf_cursor_location_set(Entry *en);
39 static void _edje_entry_imf_cursor_info_set(Entry *en);
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;
64 Eina_List *anchorlist;
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.
85 int select_dragging_state;
88 Eina_Bool have_preedit : 1;
89 Eina_Bool commit_cancel : 1; // For skipping useless commit
90 Ecore_IMF_Context *imf_context;
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
100 Evas_Textblock_Rectangle rect;
101 Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
108 Evas_Textblock_Cursor *start, *end;
113 #ifdef HAVE_ECORE_IMF
115 _preedit_clear(Entry *en)
117 if (en->preedit_start)
119 evas_textblock_cursor_free(en->preedit_start);
120 en->preedit_start = NULL;
125 evas_textblock_cursor_free(en->preedit_end);
126 en->preedit_end = NULL;
129 en->have_preedit = EINA_FALSE;
133 _preedit_del(Entry *en)
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;
139 /* delete the preedit characters */
140 evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end);
144 _edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
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;
154 en = rp->typedata.text->entry_data;
155 if (!en || !en->imf_context) return;
157 if (evas_object_focus_get(rp->edje->obj))
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))
163 if (rp->part->source8)
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);
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);
175 if (rp->part->source7)
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);
187 if (rp->part->source10)
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));
197 if (rp->part->source11)
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));
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");
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;
226 _edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
232 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
233 (!rp->typedata.text)) return;
234 if (!rp || !rp->typedata.text->entry_data) return;
236 en = rp->typedata.text->entry_data;
237 if (!en || !en->imf_context) return;
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");
252 ecore_imf_context_reset(en->imf_context);
253 ecore_imf_context_focus_out(en->imf_context);
258 _edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
261 #ifdef HAVE_ECORE_IMF
266 _edje_emit(ed, "focus,in", "");
268 rp = ed->focused_part;
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
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))
282 if (rp->part->source8)
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);
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);
294 if (rp->part->source7)
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);
306 if (rp->part->source10)
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));
316 if (rp->part->source11)
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));
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");
336 en->focused = EINA_TRUE;
337 if (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE) return;
340 #ifdef HAVE_ECORE_IMF
341 if (!en->imf_context) return;
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);
350 _edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
353 #ifdef HAVE_ECORE_IMF
354 Edje_Real_Part *rp = ed->focused_part;
358 _edje_emit(ed, "focus,out", "");
360 #ifdef HAVE_ECORE_IMF
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
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;
384 if (!en->imf_context) return;
386 ecore_imf_context_reset(en->imf_context);
387 ecore_imf_context_focus_out(en->imf_context);
392 _text_filter_markup_prepend_internal(Entry *en, Evas_Textblock_Cursor *c, char *text)
394 Edje_Markup_Filter_Callback *cb;
397 EINA_LIST_FOREACH(en->rp->edje->markup_filter_callbacks, l, cb)
399 if (!strcmp(cb->part, en->rp->part->name))
401 cb->func(cb->data, en->rp->edje->obj, cb->part, &text);
405 #ifdef HAVE_ECORE_IMF
406 // For skipping useless commit
407 if (en->have_preedit && (!text || !strcmp(text, "")))
408 en->commit_cancel = EINA_TRUE;
412 evas_object_textblock_text_markup_prepend(c, text);
418 _text_filter_text_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
421 Edje_Text_Insert_Filter_Callback *cb;
424 text2 = strdup(text);
425 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
427 if (!strcmp(cb->part, en->rp->part->name))
429 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2);
436 markup_text = evas_textblock_text_utf8_to_markup(NULL, text2);
439 _text_filter_markup_prepend_internal(en, c, markup_text);
444 _text_filter_format_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
447 Edje_Text_Insert_Filter_Callback *cb;
450 text2 = strdup(text);
451 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
453 if (!strcmp(cb->part, en->rp->part->name))
455 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2);
461 char *s, *markup_text;
467 while (*s == ' ') s++;
473 markup_text = (char*) malloc(strlen(s) + 3);
476 *(markup_text) = '<';
477 strncpy((markup_text + 1), s, strlen(s));
478 *(markup_text + strlen(s) + 1) = '>';
479 *(markup_text + strlen(s) + 2) = '\0';
482 else if (s[0] == '-')
485 while (*s == ' ') s++;
491 markup_text = (char*) malloc(strlen(s) + 4);
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';
503 markup_text = (char*) malloc(strlen(s) + 4);
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';
515 _text_filter_markup_prepend_internal(en, c, markup_text);
520 _text_filter_markup_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
523 Edje_Text_Insert_Filter_Callback *cb;
526 text2 = strdup(text);
527 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
529 if (!strcmp(cb->part, en->rp->part->name))
531 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2);
536 _text_filter_markup_prepend_internal(en, c, text2);
540 _curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en, Evas_Coord *cx, Evas_Coord *cy)
543 Evas_Textblock_Cursor_Type cur_type;
544 if (c != en->cursor) return;
545 switch (en->rp->part->cursor_mode)
547 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
548 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
550 case EDJE_ENTRY_CURSOR_MODE_UNDER:
551 /* no break for a resaon */
553 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
555 evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type);
561 _curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
563 Evas_Textblock_Cursor *cc;
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);
574 _curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
575 Entry *en __UNUSED__)
577 evas_textblock_cursor_line_char_first(c);
581 _curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
582 Entry *en __UNUSED__)
584 evas_textblock_cursor_line_char_last(c);
588 _curs_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
589 Entry *en __UNUSED__)
591 evas_textblock_cursor_paragraph_first(c);
595 _curs_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__)
597 evas_textblock_cursor_paragraph_last(c);
601 _curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
604 Evas_Coord lx, ly, lw, lh;
605 int last = _curs_line_last_get(c, o, en);
607 if (ln < 0) return EINA_FALSE;
608 if (ln > last) return EINA_FALSE;
610 _curs_update_from_curs(c, o, en, &cx, &cy);
612 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
614 if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
616 evas_textblock_cursor_line_set(c, ln);
617 if (cx < (lx + (lw / 2)))
619 if (ln == last) _curs_end(c, o, en);
620 _curs_lin_start(c, o, en);
627 _curs_lin_end(c, o, en);
633 _curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
637 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
638 return _curs_jump_line(c, o, en, ln);
642 _curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
644 return _curs_jump_line_by(c, o, en, -1);
648 _curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
650 return _curs_jump_line_by(c, o, en, 1);
654 _sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
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);
662 en->have_selection = EINA_FALSE;
666 en->selection = NULL;
671 _sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
673 if (en->have_selection) return;
674 en->have_selection = EINA_TRUE;
678 en->selection = NULL;
681 _edje_entry_imf_context_reset(en->rp);
682 _edje_emit(en->rp->edje, "selection,start", en->rp->part->name);
686 _sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
688 if (!en->sel_end) return;
689 _sel_enable(c, o, en);
690 if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
692 evas_textblock_cursor_copy(c, en->sel_end);
694 _edje_entry_imf_cursor_info_set(en);
699 en->selection = NULL;
701 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
702 // TIZEN ONLY - start
703 if (en->cursor_handler_show)
705 evas_object_hide(en->cursor_handler);
706 en->cursor_handler_show = EINA_FALSE;
712 _sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
714 if (!en->sel_end) return;
715 _sel_enable(c, o, en);
716 if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
718 evas_textblock_cursor_copy(c, en->sel_start);
720 _edje_entry_imf_cursor_info_set(en);
725 en->selection = NULL;
727 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
728 // TIZEN ONLY - start
729 if (en->cursor_handler_show)
731 evas_object_hide(en->cursor_handler);
732 en->cursor_handler_show = EINA_FALSE;
738 _sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
740 en->had_sel = EINA_FALSE;
743 evas_textblock_cursor_free(en->sel_start);
744 evas_textblock_cursor_free(en->sel_end);
745 en->sel_start = NULL;
751 en->selection = NULL;
758 if (sel->obj_bg) evas_object_del(sel->obj_bg);
759 if (sel->obj_fg) evas_object_del(sel->obj_fg);
761 // TIZEN ONLY - START
762 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
764 evas_object_hide(en->sel_handler_start);
765 evas_object_hide(en->sel_handler_end);
767 evas_object_hide(en->sel_handler_edge_start);
768 evas_object_hide(en->sel_handler_edge_end);
772 en->sel = eina_list_remove_list(en->sel, en->sel);
774 if (en->have_selection)
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);
783 _sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
785 Eina_List *range = NULL, *l;
787 Evas_Coord x, y, w, h;
788 Evas_Object *smart, *clip;
790 smart = evas_object_smart_parent_get(o);
791 clip = evas_object_clip_get(o);
794 range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end);
799 if (eina_list_count(range) != eina_list_count(en->sel))
804 if (sel->obj_bg) evas_object_del(sel->obj_bg);
805 if (sel->obj_fg) evas_object_del(sel->obj_fg);
807 en->sel = eina_list_remove_list(en->sel, en->sel);
809 if (en->have_selection)
811 for (l = range; l; l = eina_list_next(l))
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);
825 _edje_subobj_register(en->rp->edje, sel->obj_bg);
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);
835 _edje_subobj_register(en->rp->edje, sel->obj_fg);
840 evas_object_geometry_get(o, &x, &y, &w, &h);
841 if (en->have_selection)
843 // TIZEN ONLY - START
844 int list_cnt, list_idx;
846 list_cnt = eina_list_count(en->sel);
848 evas_object_hide(en->cursor_fg);
849 evas_object_hide(en->cursor_bg);
852 EINA_LIST_FOREACH(en->sel, l, sel)
854 Evas_Textblock_Rectangle *r;
855 list_idx++; // TIZEN ONLY
860 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
861 evas_object_resize(sel->obj_bg, r->w, r->h);
865 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
866 evas_object_resize(sel->obj_fg, r->w, r->h);
868 // TIZEN ONLY - START
869 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
872 const char *gc = edje_object_data_get(en->sel_handler_start, "gap");
874 if (gc) bh_gap = atoi(gc);
876 if (en->handler_bypassing)
887 if (list_idx == fh_idx)
889 Evas_Coord nx, ny, handler_height = 0;
891 edje_object_part_geometry_get(en->sel_handler_start, "handle", NULL, NULL, NULL, &handler_height);
893 //keep same touch pos when by passing
894 if (en->handler_bypassing)
896 nx = x + r->x + r->w;
904 evas_object_hide(en->sel_handler_start);
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);
910 evas_object_hide(en->sel_handler_edge_start);
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)
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);
921 evas_object_show(en->sel_handler_edge_start);
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)))
929 if (en->layout_region.w != -1 && en->layout_region.h != -1 &&
930 ((ny - handler_height) > en->layout_region.y))
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");
936 edje_object_signal_emit(en->sel_handler_start, "elm,state,top", "elm");
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");
944 edje_object_signal_emit(en->sel_handler_start, "elm,state,bottom", "elm");
947 evas_object_show(en->sel_handler_start);
948 evas_object_show(en->sel_handler_edge_start);
952 if (list_idx == eh_idx)
954 Evas_Coord nx, ny, handler_height = 0;
957 edje_object_part_geometry_get(en->sel_handler_end, "handle", NULL, NULL, NULL, &handler_height);
959 //keep pos when bypassing
960 if (en->handler_bypassing)
963 ny = y + r->y + r->h;
967 nx = x + r->x + r->w;
968 ny = y + r->y + r->h;
971 evas_object_hide(en->sel_handler_end);
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);
977 evas_object_hide(en->sel_handler_edge_end);
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)
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);
988 evas_object_show(en->sel_handler_edge_end);
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)))
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)))
1000 if (nx >= en->layout_region.w - bh_gap)
1001 edje_object_signal_emit(en->sel_handler_end, "elm,state,top,reversed", "elm");
1003 edje_object_signal_emit(en->sel_handler_end, "elm,state,top", "elm");
1007 evas_object_move(en->sel_handler_end, nx, ny);
1009 if (nx >= en->layout_region.w - bh_gap)
1010 edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom,reversed", "elm");
1012 edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom", "elm");
1015 evas_object_show(en->sel_handler_end);
1017 evas_object_show(en->sel_handler_edge_end);
1024 *(&(sel->rect)) = *r;
1025 range = eina_list_remove_list(range, range);
1034 range = eina_list_remove_list(range, range);
1040 _edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1043 Evas_Event_Mouse_Down *ev = event_info;
1044 Edje_Real_Part *rp = an->en->rp;
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)) &&
1057 ignored = rp->part->ignore_flags & ev->event_flags;
1058 if ((!ev->event_flags) || (!ignored))
1062 len = 200 + strlen(n);
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);
1069 snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
1070 _edje_emit(rp->edje, buf, rp->part->name);
1075 _edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1078 Evas_Event_Mouse_Up *ev = event_info;
1079 Edje_Real_Part *rp = an->en->rp;
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)) &&
1095 len = 200 + strlen(n);
1097 if ((!ev->event_flags) || (!ignored))
1099 snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n);
1100 _edje_emit(rp->edje, buf, rp->part->name);
1102 if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
1104 snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
1105 _edje_emit(rp->edje, buf, rp->part->name);
1110 _edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1113 Evas_Event_Mouse_Move *ev = event_info;
1114 Edje_Real_Part *rp = an->en->rp;
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)) &&
1127 ignored = rp->part->ignore_flags & ev->event_flags;
1128 if ((!ev->event_flags) || (!ignored))
1132 len = 200 + strlen(n);
1134 snprintf(buf, len, "anchor,mouse,move,%s", n);
1135 _edje_emit(rp->edje, buf, rp->part->name);
1140 _edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1143 Evas_Event_Mouse_In *ev = event_info;
1144 Edje_Real_Part *rp = an->en->rp;
1149 ignored = rp->part->ignore_flags & ev->event_flags;
1150 if ((!ev->event_flags) || (!ignored))
1154 len = 200 + strlen(n);
1156 snprintf(buf, len, "anchor,mouse,in,%s", n);
1157 _edje_emit(rp->edje, buf, rp->part->name);
1162 _edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1165 Evas_Event_Mouse_Out *ev = event_info;
1166 Edje_Real_Part *rp = an->en->rp;
1171 ignored = rp->part->ignore_flags & ev->event_flags;
1172 if ((!ev->event_flags) || (!ignored))
1176 len = 200 + strlen(n);
1178 snprintf(buf, len, "anchor,mouse,out,%s", n);
1179 _edje_emit(rp->edje, buf, rp->part->name);
1184 _anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
1186 Eina_List *l, *ll, *range = NULL;
1187 Evas_Coord x, y, w, h;
1188 Evas_Object *smart, *clip;
1192 smart = evas_object_smart_parent_get(o);
1193 clip = evas_object_clip_get(o);
1195 evas_object_geometry_get(o, &x, &y, &w, &h);
1196 EINA_LIST_FOREACH(en->anchors, l, an)
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);
1212 an->sel = eina_list_remove_list(an->sel, an->sel);
1215 sel = calloc(1, sizeof(Sel));
1216 an->sel = eina_list_append(an->sel, sel);
1218 if (en->rp->edje->item_provider.func)
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);
1236 evas_textblock_cursor_range_geometry_get(an->start, an->end);
1237 if (eina_list_count(range) != eina_list_count(an->sel))
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);
1246 an->sel = eina_list_remove_list(an->sel, an->sel);
1248 for (ll = range; ll; ll = eina_list_next(ll))
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);
1262 _edje_subobj_register(en->rp->edje, sel->obj_bg);
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);
1272 _edje_subobj_register(en->rp->edje, sel->obj_fg);
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);
1290 EINA_LIST_FOREACH(an->sel, ll, sel)
1294 Evas_Coord cx, cy, cw, ch;
1296 if (!evas_textblock_cursor_format_item_geometry_get
1297 (an->start, &cx, &cy, &cw, &ch))
1299 evas_object_move(sel->obj, x + cx, y + cy);
1300 evas_object_resize(sel->obj, cw, ch);
1304 Evas_Textblock_Rectangle *r;
1307 *(&(sel->rect)) = *r;
1310 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
1311 evas_object_resize(sel->obj_bg, r->w, r->h);
1315 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
1316 evas_object_resize(sel->obj_fg, r->w, r->h);
1320 evas_object_move(sel->obj, x + r->x, y + r->y);
1321 evas_object_resize(sel->obj, r->w, r->h);
1323 range = eina_list_remove_list(range, range);
1331 _anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1333 while (en->anchorlist)
1335 free(en->anchorlist->data);
1336 en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
1338 while (en->itemlist)
1340 free(en->itemlist->data);
1341 en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
1345 Anchor *an = en->anchors->data;
1347 evas_textblock_cursor_free(an->start);
1348 evas_textblock_cursor_free(an->end);
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);
1356 an->sel = eina_list_remove_list(an->sel, an->sel);
1360 en->anchors = eina_list_remove_list(en->anchors, en->anchors);
1365 _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1367 const Eina_List *anchors_a, *anchors_item;
1369 _anchors_clear(c, o, en);
1371 anchors_a = evas_textblock_node_format_list_get(o, "a");
1372 anchors_item = evas_textblock_node_format_list_get(o, "item");
1376 const Evas_Object_Textblock_Node_Format *node;
1377 const Eina_List *itr;
1378 EINA_LIST_FOREACH(anchors_a, itr, node)
1380 const char *s = evas_textblock_node_format_text_get(node);
1382 an = calloc(1, sizeof(Anchor));
1387 p = strstr(s, "href=");
1390 an->name = strdup(p + 5);
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);
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))
1403 s = evas_textblock_node_format_text_get(node);
1404 if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
1410 evas_textblock_cursor_at_format_set(an->end, node);
1412 else if (!evas_textblock_cursor_compare(an->start, an->end))
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);
1426 const Evas_Object_Textblock_Node_Format *node;
1427 const Eina_List *itr;
1428 EINA_LIST_FOREACH(anchors_item, itr, node)
1430 const char *s = evas_textblock_node_format_text_get(node);
1432 an = calloc(1, sizeof(Anchor));
1438 p = strstr(s, "href=");
1441 an->name = strdup(p + 5);
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. */
1455 _free_entry_change_info(void *_info)
1457 Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
1460 eina_stringshare_del(info->change.insert.content);
1464 eina_stringshare_del(info->change.del.content);
1470 _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1474 Edje_Entry_Change_Info *info;
1476 start = evas_textblock_cursor_pos_get(en->sel_start);
1477 end = evas_textblock_cursor_pos_get(en->sel_end);
1481 info = calloc(1, sizeof(*info));
1482 info->insert = EINA_FALSE;
1483 info->change.del.start = start;
1484 info->change.del.end = end;
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);
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);
1494 _sel_clear(en->cursor, en->rp->object, en);
1498 _range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1500 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1501 _sel_clear(en->cursor, en->rp->object, en);
1505 _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1506 Eina_Bool backspace)
1508 if (!evas_textblock_cursor_char_next(c))
1512 evas_textblock_cursor_char_prev(c);
1514 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1515 char *tmp = evas_textblock_cursor_content_get(c);
1517 info->insert = EINA_FALSE;
1520 info->change.del.start = pos - 1;
1521 info->change.del.end = pos;
1525 info->change.del.start = pos + 1;
1526 info->change.del.end = pos;
1529 info->change.del.content = eina_stringshare_add(tmp);
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);
1539 _edje_entry_hide_visible_password(Edje_Real_Part *rp)
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))
1545 const char *text = evas_textblock_node_format_text_get(node);
1548 if (!strcmp(text, "+ password=off"))
1550 evas_textblock_node_format_remove_pair(rp->object,
1551 (Evas_Object_Textblock_Node_Format *) node);
1556 _edje_entry_real_part_configure(rp);
1557 _edje_emit(rp->edje, "entry,changed", rp->part->name);
1561 _password_timer_cb(void *data)
1563 Entry *en = (Entry *)data;
1564 _edje_entry_hide_visible_password(en->rp);
1565 en->pw_timer = NULL;
1566 return ECORE_CALLBACK_CANCEL;
1570 _is_modifier(const char *key)
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")))
1586 _compose_seq_reset(Entry *en)
1590 EINA_LIST_FREE(en->seq, str) eina_stringshare_del(str);
1591 en->composing = EINA_FALSE;
1595 _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1598 Evas_Event_Key_Down *ev = event_info;
1599 Edje_Real_Part *rp = ed->focused_part;
1601 Eina_Bool control, alt, shift;
1602 Eina_Bool multiline;
1603 Eina_Bool cursor_changed;
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))
1612 if (!ev->keyname) return;
1614 // TIZEN ONLY - START
1615 if (en->cursor_handler_show)
1617 evas_object_hide(en->cursor_handler);
1618 en->cursor_handler_show = EINA_FALSE;
1622 #ifdef HAVE_ECORE_IMF
1623 if (en->imf_context)
1625 Ecore_IMF_Event_Key_Down ecore_ev;
1626 Eina_Bool filter_ret;
1627 ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
1630 filter_ret = ecore_imf_context_filter_event(en->imf_context,
1631 ECORE_IMF_EVENT_KEY_DOWN,
1632 (Ecore_IMF_Event *)&ecore_ev);
1634 if (en->have_preedit)
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;
1657 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
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"))
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;
1673 else if (!strcmp(ev->keyname, "Up") ||
1674 (!strcmp(ev->keyname, "KP_Up") && !ev->string))
1676 _compose_seq_reset(en);
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)
1686 _sel_start(en->cursor, rp->object, en);
1687 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1689 else _sel_clear(en->cursor, rp->object, en);
1691 if (_curs_up(en->cursor, rp->object, en))
1692 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1693 if (en->select_allow)
1695 if (shift) _sel_extend(en->cursor, rp->object, en);
1696 else _sel_clear(en->cursor, rp->object, en);
1699 _edje_emit(ed, "entry,key,up", rp->part->name);
1700 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1702 else if (!strcmp(ev->keyname, "Down") ||
1703 (!strcmp(ev->keyname, "KP_Down") && !ev->string))
1705 _compose_seq_reset(en);
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)
1715 _sel_start(en->cursor, rp->object, en);
1716 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1718 else _sel_clear(en->cursor, rp->object, en);
1720 if (_curs_down(en->cursor, rp->object, en))
1721 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1722 if (en->select_allow)
1724 if (shift) _sel_extend(en->cursor, rp->object, en);
1725 else _sel_clear(en->cursor, rp->object, en);
1728 _edje_emit(ed, "entry,key,down", rp->part->name);
1729 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1731 else if (!strcmp(ev->keyname, "Left") ||
1732 (!strcmp(ev->keyname, "KP_Left") && !ev->string))
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)
1742 _sel_start(en->cursor, rp->object, en);
1743 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1745 else _sel_clear(en->cursor, rp->object, en);
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)
1753 if (shift) _sel_extend(en->cursor, rp->object, en);
1754 else _sel_clear(en->cursor, rp->object, en);
1756 _edje_emit(ed, "entry,key,left", rp->part->name);
1757 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1759 else if (!strcmp(ev->keyname, "Right") ||
1760 (!strcmp(ev->keyname, "KP_Right") && !ev->string))
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)
1770 _sel_start(en->cursor, rp->object, en);
1771 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1773 else _sel_clear(en->cursor, rp->object, en);
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)
1781 if (shift) _sel_extend(en->cursor, rp->object, en);
1782 else _sel_clear(en->cursor, rp->object, en);
1784 _edje_emit(ed, "entry,key,right", rp->part->name);
1785 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1787 else if (!strcmp(ev->keyname, "BackSpace"))
1789 _compose_seq_reset(en);
1790 if (control && !en->have_selection)
1792 // del to start of previous word
1793 _sel_start(en->cursor, rp->object, en);
1795 evas_textblock_cursor_char_prev(en->cursor);
1796 evas_textblock_cursor_word_start(en->cursor);
1798 _sel_preextend(en->cursor, rp->object, en);
1800 _range_del_emit(ed, en->cursor, rp->object, en);
1802 else if ((alt) && (shift))
1808 if (en->have_selection)
1810 _range_del_emit(ed, en->cursor, rp->object, en);
1814 if (evas_textblock_cursor_char_prev(en->cursor))
1816 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
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;
1825 else if (!strcmp(ev->keyname, "Delete") ||
1826 (!strcmp(ev->keyname, "KP_Delete") && !ev->string))
1828 _compose_seq_reset(en);
1831 // del to end of next word
1832 _sel_start(en->cursor, rp->object, en);
1834 evas_textblock_cursor_word_end(en->cursor);
1835 evas_textblock_cursor_char_next(en->cursor);
1837 _sel_extend(en->cursor, rp->object, en);
1839 _range_del_emit(ed, en->cursor, rp->object, en);
1847 if (en->have_selection)
1849 _range_del_emit(ed, en->cursor, rp->object, en);
1853 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
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;
1861 else if (!strcmp(ev->keyname, "Home") ||
1862 ((!strcmp(ev->keyname, "KP_Home")) && !ev->string))
1864 _compose_seq_reset(en);
1865 if (en->select_allow)
1867 if (shift) _sel_start(en->cursor, rp->object, en);
1868 else _sel_clear(en->cursor, rp->object, en);
1870 if ((control) && (multiline))
1871 _curs_start(en->cursor, rp->object, en);
1873 _curs_lin_start(en->cursor, rp->object, en);
1874 if (en->select_allow)
1876 if (shift) _sel_extend(en->cursor, rp->object, en);
1878 _edje_emit(ed, "entry,key,home", rp->part->name);
1879 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1881 else if (!strcmp(ev->keyname, "End") ||
1882 ((!strcmp(ev->keyname, "KP_End")) && !ev->string))
1884 _compose_seq_reset(en);
1885 if (en->select_allow)
1887 if (shift) _sel_start(en->cursor, rp->object, en);
1888 else _sel_clear(en->cursor, rp->object, en);
1890 if ((control) && (multiline))
1891 _curs_end(en->cursor, rp->object, en);
1893 _curs_lin_end(en->cursor, rp->object, en);
1894 if (en->select_allow)
1896 if (shift) _sel_extend(en->cursor, rp->object, en);
1898 _edje_emit(ed, "entry,key,end", rp->part->name);
1899 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1901 else if ((control) && (!shift) && (!strcmp(ev->keyname, "v")))
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;
1908 else if ((control) && (!strcmp(ev->keyname, "a")))
1910 _compose_seq_reset(en);
1913 _edje_emit(ed, "entry,selection,none,request", rp->part->name);
1914 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
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;
1923 else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->keyname, "Insert")))
1925 _compose_seq_reset(en);
1926 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1927 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1929 else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
1931 _compose_seq_reset(en);
1932 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1933 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1935 else if ((control) && (!strcmp(ev->keyname, "z")))
1937 _compose_seq_reset(en);
1941 _edje_emit(ed, "entry,redo,request", rp->part->name);
1946 _edje_emit(ed, "entry,undo,request", rp->part->name);
1948 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1950 else if ((control) && (!shift) && (!strcmp(ev->keyname, "y")))
1952 _compose_seq_reset(en);
1954 _edje_emit(ed, "entry,redo,request", rp->part->name);
1955 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1957 else if ((control) && (!shift) && (!strcmp(ev->keyname, "w")))
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;
1964 else if (!strcmp(ev->keyname, "Tab"))
1966 _compose_seq_reset(en);
1975 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1976 info->insert = EINA_TRUE;
1977 info->change.insert.plain_length = 1;
1979 if (en->have_selection)
1981 _range_del_emit(ed, en->cursor, rp->object, en);
1982 info->merge = EINA_TRUE;
1984 info->change.insert.pos =
1985 evas_textblock_cursor_pos_get(en->cursor);
1986 info->change.insert.content = eina_stringshare_add("<tab/>");
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);
1995 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1997 _edje_emit(ed, "entry,key,tab", rp->part->name);
1999 else if ((!strcmp(ev->keyname, "ISO_Left_Tab")) && (multiline))
2001 _compose_seq_reset(en);
2003 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2005 else if (!strcmp(ev->keyname, "Prior") ||
2006 (!strcmp(ev->keyname, "KP_Prior") && !ev->string))
2008 _compose_seq_reset(en);
2009 if (en->select_allow)
2011 if (shift) _sel_start(en->cursor, rp->object, en);
2012 else _sel_clear(en->cursor, rp->object, en);
2014 _curs_jump_line_by(en->cursor, rp->object, en, -10);
2015 if (en->select_allow)
2017 if (shift) _sel_extend(en->cursor, rp->object, en);
2018 else _sel_clear(en->cursor, rp->object, en);
2020 _edje_emit(ed, "entry,key,pgup", rp->part->name);
2021 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2023 else if (!strcmp(ev->keyname, "Next") ||
2024 (!strcmp(ev->keyname, "KP_Next") && !ev->string))
2026 _compose_seq_reset(en);
2027 if (en->select_allow)
2029 if (shift) _sel_start(en->cursor, rp->object, en);
2030 else _sel_clear(en->cursor, rp->object, en);
2032 _curs_jump_line_by(en->cursor, rp->object, en, 10);
2033 if (en->select_allow)
2035 if (shift) _sel_extend(en->cursor, rp->object, en);
2036 else _sel_clear(en->cursor, rp->object, en);
2038 _edje_emit(ed, "entry,key,pgdn", rp->part->name);
2039 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2041 else if ((!strcmp(ev->keyname, "Return")) || (!strcmp(ev->keyname, "KP_Enter")))
2043 _compose_seq_reset(en);
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)
2051 _range_del_emit(ed, en->cursor, rp->object, en);
2052 info->merge = EINA_TRUE;
2055 info->change.insert.pos =
2056 evas_textblock_cursor_pos_get(en->cursor);
2058 evas_object_textblock_legacy_newline_get(rp->object))
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/>");
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/>");
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;
2080 _edje_emit(ed, "entry,key,enter", rp->part->name);
2084 char *compres = NULL, *string = (char *)ev->string;
2085 Eina_Bool free_string = EINA_FALSE;
2086 Ecore_Compose_State state;
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);
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)
2106 _compose_seq_reset(en);
2110 free_string = EINA_TRUE;
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);
2122 if (en->have_selection)
2124 _range_del_emit(ed, en->cursor, rp->object, en);
2125 info->merge = EINA_TRUE;
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)
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");
2140 ecore_timer_del(en->pw_timer);
2141 en->pw_timer = NULL;
2143 en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
2144 _password_timer_cb, en);
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;
2156 if (free_string) free(string);
2159 if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
2160 _edje_emit(ed, "cursor,changed", rp->part->name);
2162 _edje_entry_imf_cursor_info_set(en);
2163 _edje_entry_real_part_configure(rp);
2167 _edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2170 Edje_Real_Part *rp = ed->focused_part;
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))
2181 #ifdef HAVE_ECORE_IMF
2182 if (en->imf_context)
2184 Evas_Event_Key_Up *ev = event_info;
2185 Ecore_IMF_Event_Key_Up ecore_ev;
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))
2198 // TIZEN ONLY - START
2200 _edje_entry_select_word(Edje_Real_Part *rp)
2203 if (!rp) return EINA_FALSE;
2204 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2205 (!rp->typedata.text)) return EINA_FALSE;
2207 en = rp->typedata.text->entry_data;
2208 if (!en) return EINA_FALSE;
2210 if (en->cursor_fg) evas_object_hide(en->cursor_fg);
2211 if (en->cursor_bg) evas_object_hide(en->cursor_bg);
2213 evas_textblock_cursor_word_start(en->cursor);
2215 if (evas_textblock_cursor_eol_get(en->cursor))
2217 evas_textblock_cursor_char_prev(en->cursor);
2218 evas_textblock_cursor_word_start(en->cursor);
2221 _sel_clear(en->cursor, rp->object, en);
2222 _sel_enable(en->cursor, rp->object, en);
2223 _sel_start(en->cursor, rp->object, en);
2225 evas_textblock_cursor_word_end(en->cursor);
2226 evas_textblock_cursor_char_next(en->cursor);
2228 _sel_extend(en->cursor, rp->object, en);
2229 _edje_entry_real_part_configure(rp);
2231 en->had_sel = EINA_TRUE;
2232 en->selecting = EINA_FALSE;
2238 _long_press_cb(void *data)
2240 Edje_Real_Part *rp = data;
2242 if (!rp) return ECORE_CALLBACK_CANCEL;
2243 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2244 (!rp->typedata.text)) return ECORE_CALLBACK_CANCEL;
2246 en = rp->typedata.text->entry_data;
2247 if (!en) return ECORE_CALLBACK_CANCEL;
2249 if (en->long_press_timer)
2251 ecore_timer_del(en->long_press_timer);
2252 en->long_press_timer = NULL;
2255 en->long_press_state = _ENTRY_LONG_PRESSED;
2256 en->long_press_timer = NULL;
2258 _edje_emit(en->rp->edje, "long,pressed", en->rp->part->name);
2260 if ((en->cursor_handler) && (!en->cursor_handler_disabled) && (en->focused))
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;
2266 return ECORE_CALLBACK_CANCEL;
2271 _edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2273 Edje_Real_Part *rp = data;
2276 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2277 (!rp->typedata.text)) return;
2278 en = rp->typedata.text->entry_data;
2280 _edje_entry_imf_cursor_location_set(en);
2284 _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2287 Edje_Real_Part *rp = data;
2288 Evas_Event_Mouse_Down *ev = event_info;
2290 Evas_Coord x, y, w, h;
2291 // Eina_Bool multiline;
2292 Evas_Textblock_Cursor *tc = NULL;
2293 Eina_Bool dosel = EINA_FALSE;
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))
2304 if ((ev->button != 1) && (ev->button != 2)) return;
2306 // TIZEN ONLY - START
2307 en->dx = ev->canvas.x;
2308 en->dy = ev->canvas.y;
2311 #ifdef HAVE_ECORE_IMF
2312 if (en->imf_context)
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))
2323 _edje_entry_imf_context_reset(rp);
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)
2330 else if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
2331 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2333 if (en->select_allow) dosel = EINA_TRUE;
2335 if (ev->button == 2) dosel = EINA_FALSE;
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)
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);
2350 evas_textblock_cursor_line_char_last(en->cursor);
2351 _sel_extend(en->cursor, rp->object, en);
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);
2367 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
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);
2377 evas_textblock_cursor_word_end(en->cursor);
2378 evas_textblock_cursor_char_next(en->cursor);
2380 _sel_extend(en->cursor, rp->object, en);
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);
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)
2406 evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
2410 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2412 Evas_Coord lx, ly, lw, lh;
2415 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2418 if (rp->part->multiline)
2419 _curs_end(en->cursor, rp->object, en);
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);
2432 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2435 _curs_lin_start(en->cursor, rp->object, en);
2440 _curs_lin_start(en->cursor, rp->object, en);
2442 _curs_lin_end(en->cursor, rp->object, en);
2449 if ((en->have_selection) &&
2450 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2453 _sel_extend(en->cursor, rp->object, en);
2456 Eina_List *first, *last;
2460 last = eina_list_last(en->sel);
2463 Evas_Textblock_Rectangle *r1, *r2;
2464 Evas_Coord d, d1, d2;
2470 d = (r1->y + (r1->h / 2)) - cy;
2472 d = r2->x + r2->w - 1 - cx;
2474 d = (r2->y + (r2->h / 2)) - cy;
2476 sc = rp->edje->scale;
2477 if (sc == ZERO) sc = _edje_scale;
2478 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
2484 en->select_mod_start = EINA_TRUE;
2485 en->selecting = EINA_TRUE;
2492 en->select_mod_end = EINA_TRUE;
2493 en->selecting = EINA_TRUE;
2501 if ((en->have_selection) && (shift))
2502 _sel_extend(en->cursor, rp->object, en);
2505 en->selecting = EINA_TRUE;
2506 _sel_clear(en->cursor, rp->object, en);
2507 if (en->select_allow)
2509 _sel_start(en->cursor, rp->object, en);
2515 if (evas_textblock_cursor_compare(tc, en->cursor))
2517 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2518 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2520 evas_textblock_cursor_free(tc);
2522 // TIZEN ONLY - START
2523 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
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
2529 _edje_entry_real_part_configure(rp);
2530 if (ev->button == 2)
2532 _edje_emit(rp->edje, "entry,paste,request", rp->part->name);
2533 _edje_emit(rp->edje, "entry,paste,request,1", rp->part->name);
2538 _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2541 Edje_Real_Part *rp = data;
2542 Evas_Event_Mouse_Up *ev = event_info;
2544 Evas_Coord x, y, w, h;
2545 Evas_Textblock_Cursor *tc;
2546 if (ev->button != 1) 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))
2558 // TIZEN ONLY - START
2559 if (en->long_press_timer)
2561 ecore_timer_del(en->long_press_timer);
2562 en->long_press_timer = NULL;
2565 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2567 _edje_entry_imf_cursor_info_set(en);
2571 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return;
2572 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return;
2574 if (en->long_press_state == _ENTRY_LONG_PRESSED)
2576 en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2577 _edje_entry_imf_cursor_info_set(en);
2579 if ((strcmp(_edje_entry_text_get(rp), "") == 0) && (en->cursor_handler_show))
2581 evas_object_hide(en->cursor_handler);
2582 en->cursor_handler_show = EINA_FALSE;
2586 en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2588 if ((en->cursor_handler) && (!en->cursor_handler_disabled) && (!en->have_selection))
2590 evas_object_show(en->cursor_handler);
2591 en->cursor_handler_show = EINA_TRUE;
2595 #ifdef HAVE_ECORE_IMF
2596 if (en->imf_context)
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))
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))
2614 Evas_Coord lx, ly, lw, lh;
2617 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2620 if (rp->part->multiline)
2621 _curs_end(en->cursor, rp->object, en);
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);
2634 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2637 _curs_lin_start(en->cursor, rp->object, en);
2642 _curs_lin_start(en->cursor, rp->object, en);
2644 _curs_lin_end(en->cursor, rp->object, en);
2648 if (rp->part->select_mode != EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2650 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2652 if (en->select_allow)
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);
2662 _sel_extend(en->cursor, rp->object, en);
2663 //evas_textblock_cursor_copy(en->cursor, en->sel_end);
2667 evas_textblock_cursor_copy(en->cursor, en->sel_end);
2671 if (en->have_selection)
2672 en->had_sel = EINA_TRUE;
2673 en->selecting = EINA_FALSE;
2677 if (evas_textblock_cursor_compare(tc, en->cursor))
2679 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2680 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2683 _edje_entry_imf_cursor_info_set(en);
2685 evas_textblock_cursor_free(tc);
2687 _edje_entry_real_part_configure(rp);
2691 _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2694 Edje_Real_Part *rp = data;
2695 Evas_Event_Mouse_Move *ev = event_info;
2697 Evas_Coord x, y, w, h;
2698 Evas_Textblock_Cursor *tc;
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))
2707 #ifdef HAVE_ECORE_IMF
2708 if (en->imf_context)
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))
2719 // TIZEN ONLY - START
2720 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2722 _edje_entry_real_part_configure(rp);
2724 if (en->long_press_state == _ENTRY_LONG_PRESSING)
2728 dx = en->dx - ev->cur.canvas.x;
2729 dy = en->dy - ev->cur.canvas.y;
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))
2735 en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2736 if (en->long_press_timer)
2738 ecore_timer_del(en->long_press_timer);
2739 en->long_press_timer = NULL;
2743 else if (en->long_press_state == _ENTRY_LONG_PRESSED)
2745 Evas_Coord flx, fly, flh;
2746 Evas_Coord cnx, cny;
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);
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);
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))
2761 /* cursor is in the first line */
2762 evas_textblock_cursor_char_coord_set(en->cursor, cx, fly + flh / 2);
2766 Evas_Textblock_Cursor *lc;
2767 Evas_Coord llx, lly, llh;
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))
2775 /* cursor is in the last line */
2776 evas_textblock_cursor_char_coord_set(en->cursor, cx, lly + llh / 2);
2778 evas_textblock_cursor_free(lc);
2781 if (evas_textblock_cursor_compare(tc, en->cursor))
2783 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2785 evas_textblock_cursor_free(tc);
2787 //_edje_emit(en->rp->edje, "magnifier,changed", en->rp->part->name);
2789 } // TIZEN ONLY - END
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))
2801 Evas_Coord lx, ly, lw, lh;
2803 if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0)
2805 if (rp->part->multiline)
2806 _curs_end(en->cursor, rp->object, en);
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);
2817 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2819 _curs_lin_start(en->cursor, rp->object, en);
2821 _curs_lin_end(en->cursor, rp->object, en);
2825 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
2826 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2828 if (en->select_allow)
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);
2838 _sel_extend(en->cursor, rp->object, en);
2843 _sel_extend(en->cursor, rp->object, en);
2845 if (en->select_allow)
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);
2852 if (evas_textblock_cursor_compare(tc, en->cursor))
2854 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2855 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2857 evas_textblock_cursor_free(tc);
2859 _edje_entry_real_part_configure(rp);
2864 // TIZEN ONLY - START
2866 _cursor_handler_click_cb(void *data)
2868 Edje_Real_Part *rp = data;
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;
2876 if (en->cursor_handler_click_timer)
2878 ecore_timer_del(en->cursor_handler_click_timer);
2879 en->cursor_handler_click_timer = NULL;
2881 en->cursor_handler_click_timer = NULL;
2883 return ECORE_CALLBACK_CANCEL;
2887 _edje_entry_cursor_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
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;
2896 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2897 (!rp->typedata.text)) return;
2898 en = rp->typedata.text->entry_data;
2900 if (ev->button != 1) return;
2902 en->rx = en->sx = ev->canvas.x;
2903 en->ry = en->sy = ev->canvas.y;
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);
2909 en->ox = ox + ow/2 - en->rx;
2910 en->oy = oy - en->ry - lh/2;
2912 _edje_emit(rp->edje, "cursor,handler,move,start", en->rp->part->name);
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
2919 _edje_entry_cursor_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2922 Edje_Real_Part *rp = data;
2923 Evas_Event_Mouse_Up *ev = event_info;
2926 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2927 (!rp->typedata.text)) return;
2928 en = rp->typedata.text->entry_data;
2930 if (ev->button != 1) return;
2932 if (en->cursor_handler_click_timer)
2934 ecore_timer_del(en->cursor_handler_click_timer);
2935 en->cursor_handler_click_timer = NULL;
2937 _edje_emit(rp->edje, "cursor,handler,clicked", rp->part->name);
2941 _edje_entry_imf_cursor_info_set(en);
2942 _edje_emit(rp->edje, "cursor,handler,move,end", en->rp->part->name);
2947 _edje_entry_cursor_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2950 Edje_Real_Part *rp = data;
2951 Evas_Event_Mouse_Move *ev = event_info;
2952 Evas_Coord x, y, tx, ty, tw, th;
2957 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2958 (!rp->typedata.text)) return;
2959 en = rp->typedata.text->entry_data;
2961 if (ev->buttons != 1) return;
2963 x = ev->cur.canvas.x;
2964 y = ev->cur.canvas.y;
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;
2971 evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
2972 evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
2974 cx = en->rx + en->ox - tx;
2975 cy = en->ry + en->oy - ty;
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;
2982 evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
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);
2988 _edje_emit(rp->edje, "cursor,handler,moving", rp->part->name);
2992 _edje_entry_start_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
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;
3000 if (ev->button != 1) return;
3002 en->rx = en->sx = ev->canvas.x;
3003 en->ry = en->sy = ev->canvas.y;
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);
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;
3013 en->select_mod_start = EINA_TRUE;
3014 en->selecting = EINA_TRUE;
3016 _edje_emit(en->rp->edje, "handler,move,start", en->rp->part->name);
3020 _edje_entry_start_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3022 Edje_Real_Part *rp = data;
3023 Entry *en = rp->typedata.text->entry_data;
3025 //switch sel_start,end
3026 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) >= 0)
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);
3036 en->handler_bypassing = EINA_FALSE;
3037 _edje_entry_real_part_configure(rp);
3039 _edje_emit(en->rp->edje, "handler,move,end", en->rp->part->name);
3043 _edje_entry_start_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
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;
3051 Evas_Textblock_Cursor_Type cur_type;
3054 if (ev->buttons != 1) return;
3056 x = ev->cur.canvas.x;
3057 y = ev->cur.canvas.y;
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;
3064 evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3065 evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3067 cx = en->rx + en->ox - tx;
3068 cy = en->ry + en->oy - ty;
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;
3075 switch (rp->part->cursor_mode)
3077 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3078 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3080 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3082 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3085 evas_textblock_cursor_geometry_get(en->sel_end, &sx, &sy, NULL, NULL, NULL, cur_type);
3087 evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
3090 if (evas_textblock_cursor_compare(en->cursor, en->sel_end) >= 0)
3091 en->handler_bypassing = EINA_TRUE;
3093 en->handler_bypassing = EINA_FALSE;
3096 if (en->select_allow)
3100 if (en->select_mod_start)
3101 _sel_preextend(en->cursor, rp->object, en);
3104 _edje_entry_real_part_configure(rp);
3105 _edje_emit(en->rp->edje, "handler,moving", en->rp->part->name);
3109 _edje_entry_end_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
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;
3117 if (ev->button != 1) return;
3119 en->rx = en->sx = ev->canvas.x;
3120 en->ry = en->sy = ev->canvas.y;
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);
3126 en->ox = ox + ow/2 - en->rx;
3127 en->oy = oy - en->ry - lh/2;
3129 en->select_mod_end = EINA_TRUE;
3130 en->selecting = EINA_TRUE;
3132 _edje_emit(en->rp->edje, "handler,move,start", en->rp->part->name);
3136 _edje_entry_end_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3138 Edje_Real_Part *rp = data;
3139 Entry *en = rp->typedata.text->entry_data;
3141 //switch sel_start,end
3142 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) >= 0)
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);
3150 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) == 0)
3152 evas_textblock_cursor_char_next(en->sel_end);
3154 evas_textblock_cursor_free(tc);
3157 en->handler_bypassing = EINA_FALSE;
3158 _edje_entry_real_part_configure(rp);
3160 _edje_emit(en->rp->edje, "handler,move,end", en->rp->part->name);
3164 _edje_entry_end_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
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;
3171 Evas_Textblock_Cursor_Type cur_type;
3174 if (ev->buttons != 1) return;
3176 x = ev->cur.canvas.x;
3177 y = ev->cur.canvas.y;
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;
3184 evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3185 evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3187 cx = en->rx + en->ox - tx;
3188 cy = en->ry + en->oy - ty;
3192 if (cy > th) cy = th - 1;
3194 switch (rp->part->cursor_mode)
3196 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3197 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3199 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3201 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
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);
3208 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) <= 0)
3209 en->handler_bypassing = EINA_TRUE;
3211 en->handler_bypassing = EINA_FALSE;
3214 if (en->select_allow)
3218 if (en->select_mod_end)
3219 _sel_extend(en->cursor, rp->object, en);
3222 _edje_entry_real_part_configure(rp);
3223 _edje_emit(en->rp->edje, "handler,moving", en->rp->part->name);
3228 _evas_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info)
3230 Edje *ed = (Edje *)data;
3232 if (evas_focus_get(e) == ed->obj)
3234 _edje_focus_in_cb(data, NULL, NULL, NULL);
3239 _evas_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info)
3241 Edje *ed = (Edje *)data;
3243 if (evas_focus_get(e) == ed->obj)
3245 _edje_focus_out_cb(data, NULL, NULL, NULL);
3249 /***************************************************************/
3251 _edje_entry_init(Edje *ed)
3253 if (!ed->has_entries)
3255 if (ed->entries_inited)
3257 ed->entries_inited = EINA_TRUE;
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);
3268 _edje_entry_shutdown(Edje *ed)
3270 if (!ed->has_entries)
3272 if (!ed->entries_inited)
3274 ed->entries_inited = EINA_FALSE;
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");
3287 _edje_entry_real_part_init(Edje_Real_Part *rp)
3290 #ifdef HAVE_ECORE_IMF
3292 const Ecore_IMF_Context_Info *ctx_info;
3295 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3296 (!rp->typedata.text)) return;
3297 en = calloc(1, sizeof(Entry));
3299 rp->typedata.text->entry_data = en;
3302 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp);
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);
3308 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
3309 en->select_allow = EINA_TRUE;
3311 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
3313 Edje_Part_Description_Text *txt;
3315 txt = (Edje_Part_Description_Text *)rp->chosen_description;
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));
3321 evas_object_textblock_replace_char_set(rp->object, "*");
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);
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);
3340 /* A proxy to the main cursor. */
3341 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
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);
3353 // TIZEN ONLY - START
3355 en->cursor_handler_disabled = EINA_FALSE;
3356 en->cursor_handler = NULL;
3357 if (rp->part->source9)
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);
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 );
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);
3369 en->cursor_handler_show = EINA_FALSE;
3371 en->focused = EINA_FALSE;
3373 evas_object_textblock_legacy_newline_set(rp->object, EINA_TRUE);
3375 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
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;
3382 #ifdef HAVE_ECORE_IMF
3385 en->commit_cancel = EINA_FALSE;
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);
3390 ctx_id = ecore_imf_context_default_id_get();
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)
3397 en->imf_context = ecore_imf_context_add(ctx_id);
3401 ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
3404 en->imf_context = ecore_imf_context_add(ctx_id);
3409 en->imf_context = NULL;
3411 if (!en->imf_context) goto done;
3413 ecore_imf_context_client_window_set
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);
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);
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);
3432 #ifdef HAVE_ECORE_IMF
3435 en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
3439 _edje_entry_real_part_shutdown(Edje_Real_Part *rp)
3443 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3444 (!rp->typedata.text)) return;
3445 en = rp->typedata.text->entry_data;
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
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);
3462 evas_object_del(en->cursor_bg);
3463 evas_object_del(en->cursor_fg);
3464 evas_object_del(en->cursor_fg2);
3466 // TIZEN ONLY - START
3467 if (en->sel_handler_start)
3469 evas_object_del(en->sel_handler_start);
3470 en->sel_handler_start = NULL;
3472 if (en->sel_handler_end)
3474 evas_object_del(en->sel_handler_end);
3475 en->sel_handler_end = NULL;
3477 if (en->cursor_handler)
3479 evas_object_del(en->cursor_handler);
3480 en->cursor_handler = NULL;
3482 if (en->sel_handler_edge_start)
3484 evas_object_del(en->sel_handler_edge_start);
3485 en->sel_handler_edge_start = NULL;
3487 if (en->sel_handler_edge_end)
3489 evas_object_del(en->sel_handler_edge_end);
3490 en->sel_handler_edge_end = NULL;
3493 if (en->long_press_timer)
3495 ecore_timer_del(en->long_press_timer);
3496 en->long_press_timer = NULL;
3498 if (en->cursor_handler_click_timer)
3500 ecore_timer_del(en->cursor_handler_click_timer);
3501 en->cursor_handler_click_timer = NULL;
3507 ecore_timer_del(en->pw_timer);
3508 en->pw_timer = NULL;
3511 #ifdef HAVE_ECORE_IMF
3512 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
3514 if (en->imf_context)
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);
3520 ecore_imf_context_del(en->imf_context);
3521 en->imf_context = NULL;
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();
3529 _compose_seq_reset(en);
3535 _edje_entry_real_part_configure(Edje_Real_Part *rp)
3537 Evas_Coord x, y, w, h, xx, yy, ww, hh, xx2, yy2;
3539 Evas_Textblock_Cursor_Type cur_type;
3540 Eina_Bool bidi_cursor = EINA_FALSE;
3542 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3543 (!rp->typedata.text)) return;
3544 en = rp->typedata.text->entry_data;
3546 switch (rp->part->cursor_mode)
3548 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3549 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3551 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3552 /* no break for a resaon */
3554 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3557 _sel_update(en->cursor, rp->object, en);
3558 _anchors_update(en->cursor, rp->object, en);
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);
3569 evas_object_move(en->cursor_bg, x + xx, y + yy);
3570 evas_object_resize(en->cursor_bg, ww, hh);
3574 evas_object_move(en->cursor_fg, x + xx, y + yy);
3575 evas_object_resize(en->cursor_fg, ww, hh);
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);
3587 evas_object_show(en->cursor_fg2);
3591 evas_object_hide(en->cursor_fg2);
3595 if (en->cursor_handler && (!en->cursor_handler_disabled || en->long_press_state == _ENTRY_LONG_PRESSED || en->long_press_state == _ENTRY_LONG_PRESSING))
3597 Evas_Coord chx, chy;
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))
3605 evas_object_hide(en->cursor_handler);
3606 en->cursor_handler_show = EINA_FALSE;
3612 _edje_entry_selection_get(Edje_Real_Part *rp)
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;
3628 _edje_entry_text_get(Edje_Real_Part *rp)
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);
3641 _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
3645 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3646 (!rp->typedata.text)) return;
3647 en = rp->typedata.text->entry_data;
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);
3655 _anchors_get(en->cursor, rp->object, en);
3656 _edje_emit(rp->edje, "entry,changed", rp->part->name);
3658 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
3661 _edje_entry_imf_cursor_info_set(en);
3662 _edje_entry_real_part_configure(rp);
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);
3673 _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
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;
3682 end_cur = evas_object_textblock_cursor_new(rp->object);
3683 evas_textblock_cursor_paragraph_last(end_cur);
3685 _text_filter_markup_prepend(en, end_cur, text);
3686 evas_textblock_cursor_free(end_cur);
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);
3692 _edje_entry_real_part_configure(rp);
3696 _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
3700 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3701 (!rp->typedata.text)) return;
3702 en = rp->typedata.text->entry_data;
3704 _edje_entry_imf_context_reset(rp);
3706 // prepend markup @ cursor pos
3707 if (en->have_selection)
3708 _range_del(en->cursor, rp->object, en);
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)
3716 evas_object_hide(en->cursor_handler);
3717 en->cursor_handler_show = EINA_FALSE;
3720 _edje_emit(rp->edje, "entry,changed", rp->part->name);
3721 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
3723 _edje_entry_imf_cursor_info_set(en);
3724 _edje_entry_real_part_configure(rp);
3728 _edje_entry_set_cursor_start(Edje_Real_Part *rp)
3732 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3733 (!rp->typedata.text)) return;
3734 en = rp->typedata.text->entry_data;
3736 _curs_start(en->cursor, rp->object, en);
3738 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
3740 _edje_entry_imf_cursor_info_set(en);
3744 _edje_entry_set_cursor_end(Edje_Real_Part *rp)
3748 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3749 (!rp->typedata.text)) return;
3750 en = rp->typedata.text->entry_data;
3752 _curs_end(en->cursor, rp->object, en);
3754 _edje_entry_imf_cursor_info_set(en);
3758 _edje_entry_select_none(Edje_Real_Part *rp)
3762 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3763 (!rp->typedata.text)) return;
3764 en = rp->typedata.text->entry_data;
3766 _sel_clear(en->cursor, rp->object, en);
3770 _edje_entry_select_all(Edje_Real_Part *rp)
3774 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3775 (!rp->typedata.text)) return;
3776 en = rp->typedata.text->entry_data;
3779 _edje_entry_imf_context_reset(rp);
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);
3788 _edje_entry_real_part_configure(rp);
3790 // TIZEN ONLY - START
3791 en->select_allow = EINA_TRUE;
3792 en->had_sel = EINA_TRUE;
3794 _edje_emit(en->rp->edje, "selection,end", en->rp->part->name);
3799 _edje_entry_select_begin(Edje_Real_Part *rp)
3803 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3804 (!rp->typedata.text)) return;
3805 en = rp->typedata.text->entry_data;
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);
3813 _edje_entry_real_part_configure(rp);
3817 _edje_entry_select_extend(Edje_Real_Part *rp)
3821 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3822 (!rp->typedata.text)) return;
3823 en = rp->typedata.text->entry_data;
3825 _sel_extend(en->cursor, rp->object, en);
3827 _edje_entry_real_part_configure(rp);
3831 _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
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)
3843 if (an->item) continue;
3844 if (!strcmp(anchor, an->name))
3851 _edje_entry_anchors_list(Edje_Real_Part *rp)
3854 Eina_List *l, *anchors = NULL;
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)
3863 EINA_LIST_FOREACH(en->anchors, l, an)
3865 const char *n = an->name;
3866 if (an->item) continue;
3868 anchors = eina_list_append(anchors, strdup(n));
3870 en->anchorlist = anchors;
3872 return en->anchorlist;
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)
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)
3888 if (an->item) continue;
3889 if (!strcmp(item, an->name))
3891 evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
3899 _edje_entry_items_list(Edje_Real_Part *rp)
3902 Eina_List *l, *items = NULL;
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;
3911 EINA_LIST_FOREACH(en->anchors, l, an)
3913 const char *n = an->name;
3914 if (an->item) continue;
3916 items = eina_list_append(items, strdup(n));
3918 en->itemlist = items;
3920 return en->itemlist;
3923 // TIZEN ONLY - START
3925 _edje_entry_layout_region_set(Edje_Real_Part *rp, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
3929 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3930 (!rp->typedata.text)) return;
3931 en = rp->typedata.text->entry_data;
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);
3942 _edje_entry_viewport_region_set(Edje_Real_Part *rp, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
3945 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3946 (!rp->typedata.text)) return;
3947 en = rp->typedata.text->entry_data;
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);
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)
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;
3967 evas_object_geometry_get(rp->object, &ex, &ey, NULL, NULL);
3970 case EDJE_SELECTION_HANDLER_START:
3971 if (en->sel_handler_start)
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);
3979 case EDJE_SELECTION_HANDLER_END:
3980 if (en->sel_handler_end)
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);
3999 _edje_entry_cursor_handler_disabled_get(Edje_Real_Part *rp)
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;
4010 _edje_entry_cursor_handler_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
4013 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4014 (!rp->typedata.text)) return;
4015 en = rp->typedata.text->entry_data;
4018 en->cursor_handler_disabled = disabled;
4023 _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
4025 Evas_Coord x, y, w, h, xx, yy, ww, hh;
4027 Evas_Textblock_Cursor_Type cur_type;
4029 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4030 (!rp->typedata.text)) return;
4031 en = rp->typedata.text->entry_data;
4033 switch (rp->part->cursor_mode)
4035 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
4036 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
4038 case EDJE_ENTRY_CURSOR_MODE_UNDER:
4039 /* no break for a resaon */
4041 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
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);
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);
4052 if (cx) *cx = x + xx;
4053 if (cy) *cy = y + yy;
4059 _edje_entry_user_insert(Edje_Real_Part *rp, const char *text)
4062 Edje_Entry_Change_Info *info;
4064 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4065 (!rp->typedata.text)) return;
4066 en = rp->typedata.text->entry_data;
4068 info = calloc(1, sizeof(*info));
4070 info->insert = EINA_TRUE;
4071 info->change.insert.plain_length = 1;
4072 info->change.insert.content = eina_stringshare_add(text);
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);
4081 if (en->have_selection)
4083 _range_del_emit(rp->edje, en->cursor, rp->object, en);
4084 info->merge = EINA_TRUE;
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)
4092 evas_object_hide(en->cursor_handler);
4093 en->cursor_handler_show = EINA_FALSE;
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);
4101 _edje_entry_imf_cursor_info_set(en);
4102 _edje_entry_real_part_configure(rp);
4106 _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
4110 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4111 (!rp->typedata.text)) return;
4112 en = rp->typedata.text->entry_data;
4114 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
4116 en->select_allow = allow;
4120 _edje_entry_select_allow_get(const Edje_Real_Part *rp)
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;
4132 _edje_entry_select_abort(Edje_Real_Part *rp)
4136 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4137 (!rp->typedata.text)) return;
4138 en = rp->typedata.text->entry_data;
4142 en->selecting = EINA_FALSE;
4144 _edje_entry_imf_context_reset(rp);
4145 _edje_entry_imf_cursor_info_set(en);
4146 _edje_entry_real_part_configure(rp);
4150 // TIZEN ONLY - START
4152 _edje_entry_selection_geometry_get(Edje_Real_Part *rp, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
4154 Entry *en = rp->typedata.text->entry_data;
4155 if (!en || !en->have_selection || !en->sel)
4160 Evas_Textblock_Rectangle rect;
4161 Evas_Coord tx, ty, tw, th;
4164 if (!l) return EINA_FALSE;
4165 sel = eina_list_data_get(l);
4166 if (!sel) return EINA_FALSE;
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;
4178 th = rect.y - ty + rect.h;
4180 EINA_LIST_FOREACH(en->sel, l, sel)
4184 if (tw < sel->rect.w) tw = sel->rect.w;
4185 if (sel->rect.x < tx) tx = sel->rect.x;
4190 evas_object_geometry_get(rp->object, &vx, &vy, NULL, NULL);
4204 _edje_entry_imf_context_get(Edje_Real_Part *rp)
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;
4213 #ifdef HAVE_ECORE_IMF
4214 return en->imf_context;
4221 _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type)
4225 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4226 (!rp->typedata.text)) return;
4227 en = rp->typedata.text->entry_data;
4230 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
4231 autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4233 #ifdef HAVE_ECORE_IMF
4234 if (en->imf_context)
4235 ecore_imf_context_autocapital_type_set(en->imf_context, autocapital_type);
4239 Edje_Text_Autocapital_Type
4240 _edje_entry_autocapital_type_get(Edje_Real_Part *rp)
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;
4249 #ifdef HAVE_ECORE_IMF
4250 if (en->imf_context)
4251 return ecore_imf_context_autocapital_type_get(en->imf_context);
4254 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4258 _edje_entry_prediction_allow_set(Edje_Real_Part *rp, Eina_Bool prediction)
4262 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4263 (!rp->typedata.text)) return;
4264 en = rp->typedata.text->entry_data;
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);
4274 _edje_entry_prediction_allow_get(Edje_Real_Part *rp)
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;
4286 _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled)
4290 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4291 (!rp->typedata.text)) return;
4292 en = rp->typedata.text->entry_data;
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);
4302 _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp)
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;
4314 _edje_entry_input_panel_show(Edje_Real_Part *rp)
4318 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4319 (!rp->typedata.text)) return;
4320 en = rp->typedata.text->entry_data;
4322 #ifdef HAVE_ECORE_IMF
4323 if (en->imf_context)
4324 ecore_imf_context_input_panel_show(en->imf_context);
4329 _edje_entry_input_panel_hide(Edje_Real_Part *rp)
4333 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4334 (!rp->typedata.text)) return;
4335 en = rp->typedata.text->entry_data;
4337 #ifdef HAVE_ECORE_IMF
4338 if (en->imf_context)
4339 ecore_imf_context_input_panel_hide(en->imf_context);
4344 _edje_entry_input_panel_language_set(Edje_Real_Part *rp, Edje_Input_Panel_Lang lang)
4348 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4349 (!rp->typedata.text)) return;
4350 en = rp->typedata.text->entry_data;
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);
4359 Edje_Input_Panel_Lang
4360 _edje_entry_input_panel_language_get(Edje_Real_Part *rp)
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;
4371 #ifdef HAVE_ECORE_IMF
4373 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data, int len)
4376 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data __UNUSED__, int len __UNUSED__)
4381 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4382 (!rp->typedata.text)) return;
4383 en = rp->typedata.text->entry_data;
4385 #ifdef HAVE_ECORE_IMF
4386 if (en->imf_context)
4387 ecore_imf_context_input_panel_imdata_set(en->imf_context, data, len);
4391 #ifdef HAVE_ECORE_IMF
4393 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data, int *len)
4396 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data __UNUSED__, int *len __UNUSED__)
4401 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4402 (!rp->typedata.text)) return;
4403 en = rp->typedata.text->entry_data;
4405 #ifdef HAVE_ECORE_IMF
4406 if (en->imf_context)
4407 ecore_imf_context_input_panel_imdata_get(en->imf_context, data, len);
4411 #ifdef HAVE_ECORE_IMF
4413 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type)
4416 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type __UNUSED__)
4421 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4422 (!rp->typedata.text)) return;
4423 en = rp->typedata.text->entry_data;
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);
4431 Edje_Input_Panel_Return_Key_Type
4432 _edje_entry_input_panel_return_key_type_get(Edje_Real_Part *rp)
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);
4444 return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4447 #ifdef HAVE_ECORE_IMF
4449 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
4452 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled __UNUSED__)
4457 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4458 (!rp->typedata.text)) return;
4459 en = rp->typedata.text->entry_data;
4461 #ifdef HAVE_ECORE_IMF
4462 if (en->imf_context)
4463 ecore_imf_context_input_panel_return_key_disabled_set(en->imf_context, disabled);
4468 _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp)
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);
4483 static Evas_Textblock_Cursor *
4484 _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
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;
4494 case EDJE_CURSOR_MAIN:
4496 case EDJE_CURSOR_SELECTION_BEGIN:
4497 return en->sel_start;
4498 case EDJE_CURSOR_SELECTION_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;
4523 _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
4526 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
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;
4533 if (!c) return EINA_FALSE;
4535 _edje_entry_imf_context_reset(rp);
4537 if (!evas_textblock_cursor_char_next(c))
4541 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4542 _edje_entry_imf_cursor_info_set(en);
4544 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4545 _edje_entry_real_part_configure(rp);
4550 _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
4553 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
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;
4561 _edje_entry_imf_context_reset(rp);
4563 if (!evas_textblock_cursor_char_prev(c))
4565 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
4566 else return EINA_FALSE;
4569 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4571 _edje_entry_imf_cursor_info_set(en);
4573 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4574 _edje_entry_real_part_configure(rp);
4579 _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
4582 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4583 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
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;
4592 _edje_entry_imf_context_reset(rp);
4594 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
4596 if (ln < 0) return EINA_FALSE;
4597 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
4598 &lx, &ly, &lw, &lh))
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)))
4603 if (cx < (lx + (lw / 2)))
4604 evas_textblock_cursor_line_char_last(c);
4606 evas_textblock_cursor_line_char_last(c);
4608 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4610 _edje_entry_imf_cursor_info_set(en);
4612 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4613 _edje_entry_real_part_configure(rp);
4618 _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
4621 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4622 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
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;
4631 _edje_entry_imf_context_reset(rp);
4633 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
4635 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
4636 &lx, &ly, &lw, &lh))
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)))
4641 if (cx < (lx + (lw / 2)))
4642 evas_textblock_cursor_line_char_last(c);
4644 evas_textblock_cursor_line_char_last(c);
4646 _sel_update(c, rp->object, rp->typedata.text->entry_data);
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);
4655 _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
4658 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4660 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4661 (!rp->typedata.text)) return;
4662 en = rp->typedata.text->entry_data;
4666 _edje_entry_imf_context_reset(rp);
4668 evas_textblock_cursor_paragraph_first(c);
4669 _sel_update(c, rp->object, rp->typedata.text->entry_data);
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);
4677 _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
4680 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4682 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4683 (!rp->typedata.text)) return;
4684 en = rp->typedata.text->entry_data;
4688 _edje_entry_imf_context_reset(rp);
4690 _curs_end(c, rp->object, rp->typedata.text->entry_data);
4691 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4693 _edje_entry_imf_cursor_info_set(en);
4695 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4696 _edje_entry_real_part_configure(rp);
4700 _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
4703 Evas_Textblock_Cursor *c;
4704 Evas_Textblock_Cursor *d;
4706 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4707 (!rp->typedata.text)) return;
4708 en = rp->typedata.text->entry_data;
4710 c = _cursor_get(rp, cur);
4712 d = _cursor_get(rp, dst);
4714 evas_textblock_cursor_copy(c, d);
4715 _sel_update(c, rp->object, rp->typedata.text->entry_data);
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);
4724 _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
4727 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4729 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4730 (!rp->typedata.text)) return;
4731 en = rp->typedata.text->entry_data;
4734 _edje_entry_imf_context_reset(rp);
4736 evas_textblock_cursor_line_char_first(c);
4737 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4739 _edje_entry_imf_cursor_info_set(en);
4741 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4742 _edje_entry_real_part_configure(rp);
4746 _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
4749 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4751 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4752 (!rp->typedata.text)) return;
4753 en = rp->typedata.text->entry_data;
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);
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);
4766 _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
4767 Evas_Coord x, Evas_Coord y)
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);
4775 _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
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;
4784 _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
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);
4792 _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
4794 static char *s = NULL;
4795 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4797 if (!c) return NULL;
4804 s = evas_textblock_cursor_content_get(c);
4809 _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
4812 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4814 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4815 (!rp->typedata.text)) return;
4816 en = rp->typedata.text->entry_data;
4819 /* Abort if cursor position didn't really change */
4820 if (evas_textblock_cursor_pos_get(c) == pos)
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);
4827 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4828 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
4831 _edje_entry_imf_cursor_info_set(en);
4832 _edje_entry_real_part_configure(rp);
4838 _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur)
4840 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4842 return evas_textblock_cursor_pos_get(c);
4846 _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout)
4850 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4851 (!rp->typedata.text)) return;
4852 en = rp->typedata.text->entry_data;
4854 #ifdef HAVE_ECORE_IMF
4855 if (en->imf_context)
4856 ecore_imf_context_input_panel_layout_set(en->imf_context, layout);
4862 Edje_Input_Panel_Layout
4863 _edje_entry_input_panel_layout_get(Edje_Real_Part *rp)
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);
4876 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4880 _edje_entry_input_panel_layout_variation_set(Edje_Real_Part *rp, int variation)
4884 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4885 (!rp->typedata.text)) return;
4886 en = rp->typedata.text->entry_data;
4888 #ifdef HAVE_ECORE_IMF
4889 if (en->imf_context)
4890 ecore_imf_context_input_panel_layout_variation_set(en->imf_context, variation);
4897 _edje_entry_input_panel_layout_variation_get(Edje_Real_Part *rp)
4901 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4902 (!rp->typedata.text)) return 0;
4903 en = rp->typedata.text->entry_data;
4905 #ifdef HAVE_ECORE_IMF
4906 if (en->imf_context)
4907 return ecore_imf_context_input_panel_layout_variation_get(en->imf_context);
4914 _edje_entry_imf_context_reset(Edje_Real_Part *rp)
4918 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4919 (!rp->typedata.text)) return;
4920 en = rp->typedata.text->entry_data;
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;
4931 _edje_entry_imf_cursor_location_set(Entry *en)
4933 #ifdef HAVE_ECORE_IMF
4934 Evas_Coord cx, cy, cw, ch;
4935 if (!en || !en->rp || !en->imf_context) return;
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);
4945 _edje_entry_imf_cursor_info_set(Entry *en)
4949 #ifdef HAVE_ECORE_IMF
4950 if (!en || !en->rp || !en->imf_context) return;
4952 if (en->have_selection)
4954 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
4955 cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
4957 cursor_pos = evas_textblock_cursor_pos_get(en->sel_end);
4960 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
4962 ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos);
4964 _edje_entry_imf_cursor_location_set(en);
4970 #ifdef HAVE_ECORE_IMF
4972 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos)
4975 Edje_Real_Part *rp = ed->focused_part;
4979 Eina_Strbuf *buf = NULL;
4981 if (!rp) return EINA_FALSE;
4982 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4983 (!rp->typedata.text)) return EINA_FALSE;
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))
4992 str = _edje_entry_text_get(rp);
4995 plain_text = evas_textblock_text_markup_to_utf8(NULL, str);
4999 if (en->have_selection)
5001 buf = eina_strbuf_new();
5004 eina_strbuf_append_n(buf, plain_text, evas_textblock_cursor_pos_get(en->sel_start));
5006 eina_strbuf_append(buf, plain_text);
5008 *text = strdup(eina_strbuf_string_get(buf));
5009 eina_strbuf_free(buf);
5012 *text = strdup(plain_text);
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);
5038 _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
5041 Edje_Real_Part *rp = ed->focused_part;
5043 char *commit_str = event_info;
5047 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5048 (!rp->typedata.text)) return;
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))
5055 if (en->have_selection)
5057 if (strcmp(commit_str, ""))
5059 /* delete selected characters */
5060 _range_del_emit(ed, en->cursor, rp->object, en);
5061 _sel_clear(en->cursor, rp->object, en);
5065 start_pos = evas_textblock_cursor_pos_get(en->cursor);
5067 /* delete preedit characters */
5071 // Skipping commit process when it is useless
5072 if (en->commit_cancel)
5074 en->commit_cancel = EINA_FALSE;
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))
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");
5090 ecore_timer_del(en->pw_timer);
5091 en->pw_timer = NULL;
5093 en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
5094 _password_timer_cb, en);
5097 _text_filter_text_prepend(en, en->cursor, commit_str);
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)
5105 evas_object_hide(en->cursor_handler);
5106 en->cursor_handler_show = EINA_FALSE;
5109 _edje_emit(rp->edje, "entry,changed", rp->part->name);
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);
5123 _edje_entry_imf_cursor_info_set(en);
5124 _edje_entry_real_part_configure(rp);
5128 _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info __UNUSED__)
5131 Edje_Real_Part *rp = ed->focused_part;
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"};
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;
5147 Eina_Strbuf *preedit_attr_str;
5151 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5152 (!rp->typedata.text)) return;
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))
5159 if (!en->imf_context) return;
5160 // TIZEN ONLY - START
5161 if (en->cursor_handler_show)
5163 evas_object_hide(en->cursor_handler);
5164 en->cursor_handler_show = EINA_FALSE;
5168 ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
5170 &attrs, &cursor_pos);
5171 if (!preedit_string) return;
5173 if (!strcmp(preedit_string, ""))
5174 preedit_end_state = EINA_TRUE;
5176 if (en->have_selection && !preedit_end_state)
5178 /* delete selected characters */
5179 _range_del_emit(ed, en->cursor, rp->object, en);
5182 if (en->preedit_start && en->preedit_end)
5184 /* extract the tag string */
5185 char *str = evas_textblock_cursor_range_text_get(en->preedit_start, en->preedit_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
5189 preedit_tag_index = strstr(str, "<preedit");
5191 if ((preedit_tag_index - str) > 0)
5193 pretag = calloc(1, sizeof(char)*(preedit_tag_index-str+1));
5194 if (preedit_tag_index)
5196 strncpy(pretag, str, preedit_tag_index-str);
5203 /* delete preedit characters */
5206 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
5208 /* restore previous tag */
5211 _text_filter_markup_prepend(en, en->cursor, pretag);
5215 /* insert preedit character(s) */
5216 if (strlen(preedit_string) > 0)
5218 buf = eina_strbuf_new();
5221 EINA_LIST_FOREACH(attrs, l, attr)
5223 if (attr->preedit_type <= preedit_type_size &&
5224 tagname[attr->preedit_type])
5226 preedit_attr_str = eina_strbuf_new();
5227 if (preedit_attr_str)
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));
5234 eina_strbuf_append_printf(buf, "<%s>%s</%s>", tagname[attr->preedit_type], markup_txt, tagname[attr->preedit_type]);
5237 eina_strbuf_free(preedit_attr_str);
5241 eina_strbuf_append(buf, preedit_string);
5246 eina_strbuf_append(buf, preedit_string);
5249 // For skipping useless commit
5250 if (!preedit_end_state)
5251 en->have_preedit = EINA_TRUE;
5253 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5254 _edje_password_show_last)
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");
5262 ecore_timer_del(en->pw_timer);
5263 en->pw_timer = NULL;
5265 en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
5266 _password_timer_cb, en);
5270 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
5272 eina_strbuf_free(buf);
5275 if (!preedit_end_state)
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);
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);
5287 preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor);
5289 for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++)
5291 evas_textblock_cursor_char_prev(en->preedit_start);
5294 en->have_preedit = EINA_TRUE;
5296 /* set cursor position */
5297 evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos);
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);
5305 /* delete attribute list */
5308 EINA_LIST_FREE(attrs, attr) free(attr);
5311 free(preedit_string);
5315 _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
5318 Edje_Real_Part *rp = ed->focused_part;
5320 Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
5321 Evas_Textblock_Cursor *del_start, *del_end;
5324 if ((!rp) || (!ev)) return;
5325 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5326 (!rp->typedata.text)) return;
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))
5333 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
5335 del_start = evas_object_textblock_cursor_new(en->rp->object);
5336 evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
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);
5341 evas_textblock_cursor_range_delete(del_start, del_end);
5343 evas_textblock_cursor_free(del_start);
5344 evas_textblock_cursor_free(del_end);
5349 ////////////////////////////////////// TIZEN ONLY(130129) : START //////////////////////////////////
5350 void _edje_entry_freeze(Edje_Real_Part *rp)
5354 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5355 (!rp->typedata.text)) return;
5357 en = rp->typedata.text->entry_data;
5360 en->freeze = EINA_TRUE;
5363 void _edje_entry_thaw(Edje_Real_Part *rp)
5367 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5368 (!rp->typedata.text)) return;
5370 en = rp->typedata.text->entry_data;
5373 en->freeze = EINA_FALSE;
5375 _edje_entry_imf_cursor_info_set(en);
5376 _edje_entry_real_part_configure(rp);
5378 /////////////////////////////////////////// TIZEN ONLY : END ////////////////////////////////////////
5380 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/