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 Eina_Bool vp_updated : 1; // TIZEN ONLY
83 Eina_Bool sh_start_normal_pos : 1; // TIZEN ONLY
84 Eina_Bool sh_end_normal_pos : 1; // TIZEN ONLY
85 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
88 int select_dragging_state;
91 Eina_Bool have_preedit : 1;
92 Eina_Bool commit_cancel : 1; // For skipping useless commit
93 Ecore_IMF_Context *imf_context;
96 Ecore_Timer *long_press_timer; // TIZEN ONLY
97 Ecore_Timer *cursor_handler_click_timer; // TIZEN ONLY
98 Entry_Long_Press_State long_press_state; // TIZEN ONLY
103 Evas_Textblock_Rectangle rect;
104 Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
111 Evas_Textblock_Cursor *start, *end;
116 #ifdef HAVE_ECORE_IMF
118 _preedit_clear(Entry *en)
120 if (en->preedit_start)
122 evas_textblock_cursor_free(en->preedit_start);
123 en->preedit_start = NULL;
128 evas_textblock_cursor_free(en->preedit_end);
129 en->preedit_end = NULL;
132 en->have_preedit = EINA_FALSE;
136 _preedit_del(Entry *en)
138 if (!en || !en->have_preedit) return;
139 if (!en->preedit_start || !en->preedit_end) return;
140 if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return;
142 /* delete the preedit characters */
143 evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end);
147 _edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
153 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
154 (!rp->typedata.text)) return;
155 if (!rp || !rp->typedata.text->entry_data || !rp->edje || !rp->edje->obj) return;
157 en = rp->typedata.text->entry_data;
158 if (!en || !en->imf_context) return;
160 if (evas_object_focus_get(rp->edje->obj))
162 // TIZEN ONLY - START
163 if ((!en->sel_handler_start) && (!en->sel_handler_end) &&
164 (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
166 if (rp->part->source8)
168 en->sel_handler_end = edje_object_add(en->rp->edje->base.evas);
169 edje_object_file_set(en->sel_handler_end, en->rp->edje->path, en->rp->part->source8);
171 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_end);
172 evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_end_handler_mouse_down_cb, en->rp);
173 evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_UP, _edje_entry_end_handler_mouse_up_cb, en->rp);
174 evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_end_handler_mouse_move_cb, en->rp);
177 if (rp->part->source7)
179 en->sel_handler_start = edje_object_add(en->rp->edje->base.evas);
180 edje_object_file_set(en->sel_handler_start, en->rp->edje->path, en->rp->part->source7);
181 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_start);
182 evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_start_handler_mouse_down_cb, en->rp);
183 evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_UP, _edje_entry_start_handler_mouse_up_cb, en->rp);
184 evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_start_handler_mouse_move_cb, en->rp);
188 if (rp->part->source10)
190 en->sel_handler_edge_start = edje_object_add(en->rp->edje->base.evas);
191 edje_object_file_set(en->sel_handler_edge_start, en->rp->edje->path, en->rp->part->source10);
192 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_start);
193 evas_object_clip_set(en->sel_handler_edge_start, evas_object_clip_get(rp->object));
194 if (en->sel_handler_start)
195 evas_object_stack_below(en->sel_handler_edge_start, en->sel_handler_start);
196 if (en->sel_handler_end)
197 evas_object_stack_below(en->sel_handler_edge_start, en->sel_handler_end);
201 if (rp->part->source11)
203 en->sel_handler_edge_end = edje_object_add(en->rp->edje->base.evas);
204 edje_object_file_set(en->sel_handler_edge_end, en->rp->edje->path, en->rp->part->source11);
205 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_end);
206 evas_object_clip_set(en->sel_handler_edge_end, evas_object_clip_get(rp->object));
207 if (en->sel_handler_start)
208 evas_object_stack_below(en->sel_handler_edge_end, en->sel_handler_start);
209 if (en->sel_handler_end)
210 evas_object_stack_below(en->sel_handler_edge_end, en->sel_handler_end);
213 if (en->sel_handler_start)
214 edje_object_signal_emit(en->sel_handler_start, "edje,focus,in", "edje");
215 if (en->sel_handler_end)
216 edje_object_signal_emit(en->sel_handler_end, "edje,focus,in", "edje");
217 if (en->cursor_handler)
218 edje_object_signal_emit(en->cursor_handler, "edje,focus,in", "edje");
219 if (en->sel_handler_edge_start)
220 edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,in", "edje");
221 if (en->sel_handler_edge_end)
222 edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,in", "edje");
225 ecore_imf_context_reset(en->imf_context);
226 ecore_imf_context_focus_in(en->imf_context);
227 _edje_entry_imf_cursor_info_set(en);
228 en->focused = EINA_TRUE;
233 _edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
239 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
240 (!rp->typedata.text)) return;
241 if (!rp || !rp->typedata.text->entry_data) return;
243 en = rp->typedata.text->entry_data;
244 if (!en || !en->imf_context) return;
246 // TIZEN ONLY - START
247 if (en->sel_handler_start)
248 edje_object_signal_emit(en->sel_handler_start, "edje,focus,out", "edje");
249 if (en->sel_handler_end)
250 edje_object_signal_emit(en->sel_handler_end, "edje,focus,out", "edje");
251 if (en->cursor_handler)
252 edje_object_signal_emit(en->cursor_handler, "edje,focus,out", "edje");
253 if (en->sel_handler_edge_start)
254 edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,out", "edje");
255 if (en->sel_handler_edge_end)
256 edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,out", "edje");
259 ecore_imf_context_reset(en->imf_context);
260 ecore_imf_context_focus_out(en->imf_context);
265 _edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
268 #ifdef HAVE_ECORE_IMF
273 _edje_emit(ed, "focus,in", "");
275 rp = ed->focused_part;
278 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
279 (!rp->typedata.text)) return;
280 en = rp->typedata.text->entry_data;
281 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
282 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) // TIZEN ONLY
285 // TIZEN ONLY - START
286 if ((!en->sel_handler_start) && (!en->sel_handler_end) &&
287 (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
289 if (rp->part->source8)
291 en->sel_handler_end = edje_object_add(en->rp->edje->base.evas);
292 edje_object_file_set(en->sel_handler_end, en->rp->edje->path, en->rp->part->source8);
294 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_end);
295 evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_end_handler_mouse_down_cb, en->rp);
296 evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_UP, _edje_entry_end_handler_mouse_up_cb, en->rp);
297 evas_object_event_callback_add(en->sel_handler_end, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_end_handler_mouse_move_cb, en->rp);
300 if (rp->part->source7)
302 en->sel_handler_start = edje_object_add(en->rp->edje->base.evas);
303 edje_object_file_set(en->sel_handler_start, en->rp->edje->path, en->rp->part->source7);
304 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_start);
305 evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_start_handler_mouse_down_cb, en->rp);
306 evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_UP, _edje_entry_start_handler_mouse_up_cb, en->rp);
307 evas_object_event_callback_add(en->sel_handler_start, EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_start_handler_mouse_move_cb, en->rp);
311 if (rp->part->source10)
313 en->sel_handler_edge_start = edje_object_add(en->rp->edje->base.evas);
314 edje_object_file_set(en->sel_handler_edge_start, en->rp->edje->path, en->rp->part->source10);
315 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_start);
316 evas_object_clip_set(en->sel_handler_edge_start, evas_object_clip_get(rp->object));
317 if (en->sel_handler_start)
318 evas_object_stack_below(en->sel_handler_edge_start, en->sel_handler_start);
319 if (en->sel_handler_end)
320 evas_object_stack_below(en->sel_handler_edge_start, en->sel_handler_end);
324 if (rp->part->source11)
326 en->sel_handler_edge_end = edje_object_add(en->rp->edje->base.evas);
327 edje_object_file_set(en->sel_handler_edge_end, en->rp->edje->path, en->rp->part->source11);
328 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->sel_handler_edge_end);
329 evas_object_clip_set(en->sel_handler_edge_end, evas_object_clip_get(rp->object));
330 if (en->sel_handler_start)
331 evas_object_stack_below(en->sel_handler_edge_end, en->sel_handler_start);
332 if (en->sel_handler_end)
333 evas_object_stack_below(en->sel_handler_edge_end, en->sel_handler_end);
336 if (en->sel_handler_start)
337 edje_object_signal_emit(en->sel_handler_start, "edje,focus,in", "edje");
338 if (en->sel_handler_end)
339 edje_object_signal_emit(en->sel_handler_end, "edje,focus,in", "edje");
340 if (en->cursor_handler)
341 edje_object_signal_emit(en->cursor_handler, "edje,focus,in", "edje");
342 if (en->sel_handler_edge_start)
343 edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,in", "edje");
344 if (en->sel_handler_edge_end)
345 edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,in", "edje");
347 en->focused = EINA_TRUE;
348 if (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE) return;
351 #ifdef HAVE_ECORE_IMF
352 if (!en->imf_context) return;
354 ecore_imf_context_reset(en->imf_context);
355 ecore_imf_context_focus_in(en->imf_context);
356 _edje_entry_imf_cursor_info_set(en);
361 _edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
364 #ifdef HAVE_ECORE_IMF
365 Edje_Real_Part *rp = ed->focused_part;
369 _edje_emit(ed, "focus,out", "");
371 #ifdef HAVE_ECORE_IMF
373 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
374 (!rp->typedata.text)) return;
375 en = rp->typedata.text->entry_data;
376 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
377 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) // TIZEN ONLY
380 // TIZEN ONLY - START
381 if (en->sel_handler_start)
382 edje_object_signal_emit(en->sel_handler_start, "edje,focus,out", "edje");
383 if (en->sel_handler_end)
384 edje_object_signal_emit(en->sel_handler_end, "edje,focus,out", "edje");
385 if (en->cursor_handler)
386 edje_object_signal_emit(en->cursor_handler, "edje,focus,out", "edje");
387 if (en->sel_handler_edge_start)
388 edje_object_signal_emit(en->sel_handler_edge_start, "edje,focus,out", "edje");
389 if (en->sel_handler_edge_end)
390 edje_object_signal_emit(en->sel_handler_edge_end, "edje,focus,out", "edje");
391 en->focused = EINA_FALSE;
392 if (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE) return;
395 if (!en->imf_context) return;
397 ecore_imf_context_reset(en->imf_context);
398 ecore_imf_context_focus_out(en->imf_context);
403 _text_filter_markup_prepend_internal(Entry *en, Evas_Textblock_Cursor *c, char *text)
405 Edje_Markup_Filter_Callback *cb;
408 EINA_LIST_FOREACH(en->rp->edje->markup_filter_callbacks, l, cb)
410 if (!strcmp(cb->part, en->rp->part->name))
412 cb->func(cb->data, en->rp->edje->obj, cb->part, &text);
416 #ifdef HAVE_ECORE_IMF
417 // For skipping useless commit
418 if (en->have_preedit && (!text || !strcmp(text, "")))
419 en->commit_cancel = EINA_TRUE;
421 en->commit_cancel = EINA_FALSE;
425 evas_object_textblock_text_markup_prepend(c, text);
431 _text_filter_text_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
434 Edje_Text_Insert_Filter_Callback *cb;
437 text2 = strdup(text);
438 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
440 if (!strcmp(cb->part, en->rp->part->name))
442 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2);
449 markup_text = evas_textblock_text_utf8_to_markup(NULL, text2);
452 _text_filter_markup_prepend_internal(en, c, markup_text);
457 _text_filter_format_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
460 Edje_Text_Insert_Filter_Callback *cb;
463 text2 = strdup(text);
464 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
466 if (!strcmp(cb->part, en->rp->part->name))
468 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2);
474 char *s, *markup_text;
480 while (*s == ' ') s++;
486 markup_text = (char*) malloc(strlen(s) + 3);
489 *(markup_text) = '<';
490 strncpy((markup_text + 1), s, strlen(s));
491 *(markup_text + strlen(s) + 1) = '>';
492 *(markup_text + strlen(s) + 2) = '\0';
495 else if (s[0] == '-')
498 while (*s == ' ') s++;
504 markup_text = (char*) malloc(strlen(s) + 4);
507 *(markup_text) = '<';
508 *(markup_text + 1) = '/';
509 strncpy((markup_text + 2), s, strlen(s));
510 *(markup_text + strlen(s) + 2) = '>';
511 *(markup_text + strlen(s) + 3) = '\0';
516 markup_text = (char*) malloc(strlen(s) + 4);
519 *(markup_text) = '<';
520 strncpy((markup_text + 1), s, strlen(s));
521 *(markup_text + strlen(s) + 1) = '/';
522 *(markup_text + strlen(s) + 2) = '>';
523 *(markup_text + strlen(s) + 3) = '\0';
528 _text_filter_markup_prepend_internal(en, c, markup_text);
533 _text_filter_markup_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
536 Edje_Text_Insert_Filter_Callback *cb;
539 text2 = strdup(text);
540 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
542 if (!strcmp(cb->part, en->rp->part->name))
544 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2);
549 _text_filter_markup_prepend_internal(en, c, text2);
553 _curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en, Evas_Coord *cx, Evas_Coord *cy)
556 Evas_Textblock_Cursor_Type cur_type;
557 if (c != en->cursor) return;
558 switch (en->rp->part->cursor_mode)
560 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
561 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
563 case EDJE_ENTRY_CURSOR_MODE_UNDER:
564 /* no break for a resaon */
566 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
568 evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type);
574 _curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
576 Evas_Textblock_Cursor *cc;
579 cc = evas_object_textblock_cursor_new(o);
580 evas_textblock_cursor_paragraph_last(cc);
581 ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL);
582 evas_textblock_cursor_free(cc);
587 _curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
588 Entry *en __UNUSED__)
590 evas_textblock_cursor_line_char_first(c);
594 _curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
595 Entry *en __UNUSED__)
597 evas_textblock_cursor_line_char_last(c);
601 _curs_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
602 Entry *en __UNUSED__)
604 evas_textblock_cursor_paragraph_first(c);
608 _curs_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__)
610 evas_textblock_cursor_paragraph_last(c);
614 _curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
617 Evas_Coord lx, ly, lw, lh;
618 int last = _curs_line_last_get(c, o, en);
620 if (ln < 0) return EINA_FALSE;
621 if (ln > last) return EINA_FALSE;
623 _curs_update_from_curs(c, o, en, &cx, &cy);
625 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
627 if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
629 evas_textblock_cursor_line_set(c, ln);
630 if (cx < (lx + (lw / 2)))
632 if (ln == last) _curs_end(c, o, en);
633 _curs_lin_start(c, o, en);
640 _curs_lin_end(c, o, en);
646 _curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
650 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
651 return _curs_jump_line(c, o, en, ln);
655 _curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
657 return _curs_jump_line_by(c, o, en, -1);
661 _curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
663 return _curs_jump_line_by(c, o, en, 1);
667 _sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
669 if (en->sel_start) return;
670 en->sel_start = evas_object_textblock_cursor_new(o);
671 evas_textblock_cursor_copy(c, en->sel_start);
672 en->sel_end = evas_object_textblock_cursor_new(o);
673 evas_textblock_cursor_copy(c, en->sel_end);
675 en->have_selection = EINA_FALSE;
679 en->selection = NULL;
684 _sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
686 if (en->have_selection) return;
687 en->have_selection = EINA_TRUE;
691 en->selection = NULL;
694 _edje_entry_imf_context_reset(en->rp);
695 _edje_emit(en->rp->edje, "selection,start", en->rp->part->name);
699 _sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
701 if (!en->sel_end) return;
702 _sel_enable(c, o, en);
703 if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
705 evas_textblock_cursor_copy(c, en->sel_end);
707 _edje_entry_imf_cursor_info_set(en);
712 en->selection = NULL;
714 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
715 // TIZEN ONLY - start
716 if (en->cursor_handler_show)
718 evas_object_hide(en->cursor_handler);
719 en->cursor_handler_show = EINA_FALSE;
725 _sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
727 if (!en->sel_end) return;
728 _sel_enable(c, o, en);
729 if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
731 evas_textblock_cursor_copy(c, en->sel_start);
733 _edje_entry_imf_cursor_info_set(en);
738 en->selection = NULL;
740 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
741 // TIZEN ONLY - start
742 if (en->cursor_handler_show)
744 evas_object_hide(en->cursor_handler);
745 en->cursor_handler_show = EINA_FALSE;
751 _sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
753 en->had_sel = EINA_FALSE;
756 evas_textblock_cursor_free(en->sel_start);
757 evas_textblock_cursor_free(en->sel_end);
758 en->sel_start = NULL;
764 en->selection = NULL;
771 if (sel->obj_bg) evas_object_del(sel->obj_bg);
772 if (sel->obj_fg) evas_object_del(sel->obj_fg);
774 // TIZEN ONLY - START
775 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
777 evas_object_hide(en->sel_handler_start);
778 evas_object_hide(en->sel_handler_end);
780 evas_object_hide(en->sel_handler_edge_start);
781 evas_object_hide(en->sel_handler_edge_end);
785 en->sel = eina_list_remove_list(en->sel, en->sel);
787 if (en->have_selection)
789 en->have_selection = EINA_FALSE;
790 evas_object_show(en->cursor_fg);
791 _edje_emit(en->rp->edje, "selection,cleared", en->rp->part->name);
796 _sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
798 Eina_List *range = NULL, *l;
800 Evas_Coord x, y, w, h;
801 Evas_Object *smart, *clip;
803 smart = evas_object_smart_parent_get(o);
804 clip = evas_object_clip_get(o);
807 range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end);
812 if (eina_list_count(range) != eina_list_count(en->sel))
817 if (sel->obj_bg) evas_object_del(sel->obj_bg);
818 if (sel->obj_fg) evas_object_del(sel->obj_fg);
820 en->sel = eina_list_remove_list(en->sel, en->sel);
822 if (en->have_selection)
824 for (l = range; l; l = eina_list_next(l))
828 sel = calloc(1, sizeof(Sel));
829 en->sel = eina_list_append(en->sel, sel);
830 ob = edje_object_add(en->rp->edje->base.evas);
831 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source);
832 evas_object_smart_member_add(ob, smart);
833 evas_object_stack_below(ob, o);
834 evas_object_clip_set(ob, clip);
835 evas_object_pass_events_set(ob, EINA_TRUE);
836 evas_object_show(ob);
838 _edje_subobj_register(en->rp->edje, sel->obj_bg);
840 ob = edje_object_add(en->rp->edje->base.evas);
841 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source2);
842 evas_object_smart_member_add(ob, smart);
843 evas_object_stack_above(ob, o);
844 evas_object_clip_set(ob, clip);
845 evas_object_pass_events_set(ob, EINA_TRUE);
846 evas_object_show(ob);
848 _edje_subobj_register(en->rp->edje, sel->obj_fg);
853 evas_object_geometry_get(o, &x, &y, &w, &h);
854 if (en->have_selection)
856 // TIZEN ONLY - START
857 int list_cnt, list_idx;
859 list_cnt = eina_list_count(en->sel);
861 evas_object_hide(en->cursor_fg);
862 evas_object_hide(en->cursor_bg);
865 EINA_LIST_FOREACH(en->sel, l, sel)
867 Evas_Textblock_Rectangle *r;
868 list_idx++; // TIZEN ONLY
873 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
874 evas_object_resize(sel->obj_bg, r->w, r->h);
878 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
879 evas_object_resize(sel->obj_fg, r->w, r->h);
881 // TIZEN ONLY - START
882 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
885 const char *gc = edje_object_data_get(en->sel_handler_start, "gap");
887 if (gc) bh_gap = atoi(gc);
889 if (en->handler_bypassing)
900 if (list_idx == fh_idx)
902 Evas_Coord nx, ny, handler_height = 0;
904 Evas_Coord moving = 0;
905 edje_object_part_geometry_get(en->sel_handler_start, "handle", NULL, NULL, NULL, &handler_height);
907 //keep same touch pos when by passing
908 if (en->handler_bypassing)
910 nx = x + r->x + r->w;
911 ny = y + r->y + r->h;
916 ny = y + r->y + r->h;
918 evas_object_hide(en->sel_handler_start);
920 edje_object_size_min_calc(en->sel_handler_edge_start, &edge_w, NULL);
921 evas_object_move(en->sel_handler_edge_start, nx, ny - r->h);
922 evas_object_resize(en->sel_handler_edge_start, edge_w, r->h);
924 if (!en->vp_updated && en->sh_start_normal_pos)
926 /* to avoid blinking when moving */
930 evas_object_hide(en->sel_handler_edge_start);
932 // if viewport region is not set, show handlers
933 if (en->viewport_region.x == -1 && en->viewport_region.y == -1 &&
934 en->viewport_region.w == -1 && en->viewport_region.h == -1)
936 evas_object_hide(en->sel_handler_start);
937 evas_object_move(en->sel_handler_start, nx, ny);
938 edje_object_signal_emit(en->sel_handler_start, "elm,state,bottom", "elm");
939 evas_object_show(en->sel_handler_start);
941 evas_object_show(en->sel_handler_edge_start);
945 if ((en->viewport_region.w > 0 && en->viewport_region.h > 0) &&
946 (nx >= en->viewport_region.x) && (nx <= (en->viewport_region.x + en->viewport_region.w)) &&
947 (ny >= en->viewport_region.y) && (ny - r->h <= (en->viewport_region.y + en->viewport_region.h)))
949 if ((en->layout_region.w != -1) && (en->layout_region.h != -1) &&
950 (((ny + handler_height) > (en->layout_region.y + en->layout_region.h))
951 || (ny > en->viewport_region.y + en->viewport_region.h + moving)))
953 evas_object_move(en->sel_handler_start, nx, ny - r->h);
954 if (nx <= en->layout_region.x + bh_gap)
955 edje_object_signal_emit(en->sel_handler_start, "elm,state,top,reversed", "elm");
957 edje_object_signal_emit(en->sel_handler_start, "elm,state,top", "elm");
958 en->sh_start_normal_pos = EINA_FALSE;
962 evas_object_move(en->sel_handler_start, nx, ny);
963 if (nx <= en->layout_region.x + bh_gap)
964 edje_object_signal_emit(en->sel_handler_start, "elm,state,bottom,reversed", "elm");
966 edje_object_signal_emit(en->sel_handler_start, "elm,state,bottom", "elm");
967 en->sh_start_normal_pos = EINA_TRUE;
970 evas_object_show(en->sel_handler_start);
971 evas_object_show(en->sel_handler_edge_start);
975 if (list_idx == eh_idx)
977 Evas_Coord nx, ny, handler_height = 0;
979 Evas_Coord moving = 0;
981 edje_object_part_geometry_get(en->sel_handler_end, "handle", NULL, NULL, NULL, &handler_height);
983 //keep pos when bypassing
984 if (en->handler_bypassing)
987 ny = y + r->y + r->h;
991 nx = x + r->x + r->w;
992 ny = y + r->y + r->h;
995 evas_object_hide(en->sel_handler_end);
997 edje_object_size_min_calc(en->sel_handler_edge_end, &edge_w, NULL);
998 evas_object_move(en->sel_handler_edge_end, nx, ny - r->h);
999 evas_object_resize(en->sel_handler_edge_end, edge_w, r->h);
1001 if (!en->vp_updated && en->sh_end_normal_pos)
1003 /* to avoid blinking when moving */
1007 evas_object_hide(en->sel_handler_edge_end);
1009 // if viewport region is not set, show handlers
1010 if (en->viewport_region.x == -1 && en->viewport_region.y == -1 &&
1011 en->viewport_region.w == -1 && en->viewport_region.h == -1)
1013 evas_object_move(en->sel_handler_end, nx, ny);
1014 evas_object_move(en->sel_handler_end, nx, ny);
1015 edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom", "elm");
1016 evas_object_show(en->sel_handler_end);
1018 evas_object_show(en->sel_handler_edge_end);
1022 if ((en->viewport_region.w > 0 && en->viewport_region.h > 0) &&
1023 (nx >= en->viewport_region.x) && (nx <= (en->viewport_region.x + en->viewport_region.w)) &&
1024 (ny >= en->viewport_region.y) && (ny - r->h <= (en->viewport_region.y + en->viewport_region.h)))
1026 evas_object_move(en->sel_handler_end, nx, ny - r->h);
1027 if (en->layout_region.w != -1 && en->layout_region.h != -1 &&
1028 (((ny + handler_height) > (en->layout_region.y + en->layout_region.h))
1029 || (ny > en->viewport_region.y + en->viewport_region.h + moving)))
1031 if (nx >= en->layout_region.w - bh_gap)
1032 edje_object_signal_emit(en->sel_handler_end, "elm,state,top,reversed", "elm");
1034 edje_object_signal_emit(en->sel_handler_end, "elm,state,top", "elm");
1035 en->sh_end_normal_pos = EINA_FALSE;
1039 evas_object_move(en->sel_handler_end, nx, ny);
1041 if (nx >= en->layout_region.w - bh_gap)
1042 edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom,reversed", "elm");
1044 edje_object_signal_emit(en->sel_handler_end, "elm,state,bottom", "elm");
1045 en->sh_end_normal_pos = EINA_TRUE;
1048 evas_object_show(en->sel_handler_end);
1050 evas_object_show(en->sel_handler_edge_end);
1057 *(&(sel->rect)) = *r;
1058 range = eina_list_remove_list(range, range);
1067 range = eina_list_remove_list(range, range);
1070 en->vp_updated = EINA_FALSE;
1074 _edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1077 Evas_Event_Mouse_Down *ev = event_info;
1078 Edje_Real_Part *rp = an->en->rp;
1084 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1085 (!rp->typedata.text)) return;
1086 en = rp->typedata.text->entry_data;
1087 if (((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
1088 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)) &&
1091 ignored = rp->part->ignore_flags & ev->event_flags;
1092 if ((!ev->event_flags) || (!ignored))
1096 len = 200 + strlen(n);
1098 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
1099 snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, n);
1100 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1101 snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, n);
1103 snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
1104 _edje_emit(rp->edje, buf, rp->part->name);
1109 _edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1112 Evas_Event_Mouse_Up *ev = event_info;
1113 Edje_Real_Part *rp = an->en->rp;
1119 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1120 (!rp->typedata.text)) return;
1121 en = rp->typedata.text->entry_data;
1122 ignored = rp->part->ignore_flags & ev->event_flags;
1123 if (((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
1124 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)) &&
1129 len = 200 + strlen(n);
1131 if ((!ev->event_flags) || (!ignored))
1133 snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n);
1134 _edje_emit(rp->edje, buf, rp->part->name);
1136 if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
1138 snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
1139 _edje_emit(rp->edje, buf, rp->part->name);
1144 _edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1147 Evas_Event_Mouse_Move *ev = event_info;
1148 Edje_Real_Part *rp = an->en->rp;
1154 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1155 (!rp->typedata.text)) return;
1156 en = rp->typedata.text->entry_data;
1157 if (((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
1158 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)) &&
1161 ignored = rp->part->ignore_flags & ev->event_flags;
1162 if ((!ev->event_flags) || (!ignored))
1166 len = 200 + strlen(n);
1168 snprintf(buf, len, "anchor,mouse,move,%s", n);
1169 _edje_emit(rp->edje, buf, rp->part->name);
1174 _edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1177 Evas_Event_Mouse_In *ev = event_info;
1178 Edje_Real_Part *rp = an->en->rp;
1183 ignored = rp->part->ignore_flags & ev->event_flags;
1184 if ((!ev->event_flags) || (!ignored))
1188 len = 200 + strlen(n);
1190 snprintf(buf, len, "anchor,mouse,in,%s", n);
1191 _edje_emit(rp->edje, buf, rp->part->name);
1196 _edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1199 Evas_Event_Mouse_Out *ev = event_info;
1200 Edje_Real_Part *rp = an->en->rp;
1205 ignored = rp->part->ignore_flags & ev->event_flags;
1206 if ((!ev->event_flags) || (!ignored))
1210 len = 200 + strlen(n);
1212 snprintf(buf, len, "anchor,mouse,out,%s", n);
1213 _edje_emit(rp->edje, buf, rp->part->name);
1218 _anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
1220 Eina_List *l, *ll, *range = NULL;
1221 Evas_Coord x, y, w, h;
1222 Evas_Object *smart, *clip;
1226 smart = evas_object_smart_parent_get(o);
1227 clip = evas_object_clip_get(o);
1229 evas_object_geometry_get(o, &x, &y, &w, &h);
1230 EINA_LIST_FOREACH(en->anchors, l, an)
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);
1249 sel = calloc(1, sizeof(Sel));
1250 an->sel = eina_list_append(an->sel, sel);
1252 if (en->rp->edje->item_provider.func)
1254 ob = en->rp->edje->item_provider.func
1255 (en->rp->edje->item_provider.data, smart,
1256 en->rp->part->name, an->name);
1257 evas_object_smart_member_add(ob, smart);
1258 evas_object_stack_above(ob, o);
1259 evas_object_clip_set(ob, clip);
1260 evas_object_pass_events_set(ob, EINA_TRUE);
1261 evas_object_show(ob);
1270 evas_textblock_cursor_range_geometry_get(an->start, an->end);
1271 if (eina_list_count(range) != eina_list_count(an->sel))
1275 sel = an->sel->data;
1276 if (sel->obj_bg) evas_object_del(sel->obj_bg);
1277 if (sel->obj_fg) evas_object_del(sel->obj_fg);
1278 if (sel->obj) evas_object_del(sel->obj);
1280 an->sel = eina_list_remove_list(an->sel, an->sel);
1282 for (ll = range; ll; ll = eina_list_next(ll))
1286 sel = calloc(1, sizeof(Sel));
1287 an->sel = eina_list_append(an->sel, sel);
1288 ob = edje_object_add(en->rp->edje->base.evas);
1289 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source5);
1290 evas_object_smart_member_add(ob, smart);
1291 evas_object_stack_below(ob, o);
1292 evas_object_clip_set(ob, clip);
1293 evas_object_pass_events_set(ob, EINA_TRUE);
1294 evas_object_show(ob);
1296 _edje_subobj_register(en->rp->edje, sel->obj_bg);
1298 ob = edje_object_add(en->rp->edje->base.evas);
1299 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source6);
1300 evas_object_smart_member_add(ob, smart);
1301 evas_object_stack_above(ob, o);
1302 evas_object_clip_set(ob, clip);
1303 evas_object_pass_events_set(ob, EINA_TRUE);
1304 evas_object_show(ob);
1306 _edje_subobj_register(en->rp->edje, sel->obj_fg);
1308 ob = evas_object_rectangle_add(en->rp->edje->base.evas);
1309 evas_object_color_set(ob, 0, 0, 0, 0);
1310 evas_object_smart_member_add(ob, smart);
1311 evas_object_stack_above(ob, o);
1312 evas_object_clip_set(ob, clip);
1313 evas_object_repeat_events_set(ob, EINA_TRUE);
1314 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an);
1315 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an);
1316 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an);
1317 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an);
1318 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an);
1319 evas_object_show(ob);
1324 EINA_LIST_FOREACH(an->sel, ll, sel)
1328 Evas_Coord cx, cy, cw, ch;
1330 if (!evas_textblock_cursor_format_item_geometry_get
1331 (an->start, &cx, &cy, &cw, &ch))
1333 evas_object_move(sel->obj, x + cx, y + cy);
1334 evas_object_resize(sel->obj, cw, ch);
1338 Evas_Textblock_Rectangle *r;
1341 *(&(sel->rect)) = *r;
1344 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
1345 evas_object_resize(sel->obj_bg, r->w, r->h);
1349 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
1350 evas_object_resize(sel->obj_fg, r->w, r->h);
1354 evas_object_move(sel->obj, x + r->x, y + r->y);
1355 evas_object_resize(sel->obj, r->w, r->h);
1357 range = eina_list_remove_list(range, range);
1365 _anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1367 while (en->anchorlist)
1369 free(en->anchorlist->data);
1370 en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
1372 while (en->itemlist)
1374 free(en->itemlist->data);
1375 en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
1379 Anchor *an = en->anchors->data;
1381 evas_textblock_cursor_free(an->start);
1382 evas_textblock_cursor_free(an->end);
1385 Sel *sel = an->sel->data;
1386 if (sel->obj_bg) evas_object_del(sel->obj_bg);
1387 if (sel->obj_fg) evas_object_del(sel->obj_fg);
1388 if (sel->obj) evas_object_del(sel->obj);
1390 an->sel = eina_list_remove_list(an->sel, an->sel);
1394 en->anchors = eina_list_remove_list(en->anchors, en->anchors);
1399 _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1401 const Eina_List *anchors_a, *anchors_item;
1403 _anchors_clear(c, o, en);
1405 anchors_a = evas_textblock_node_format_list_get(o, "a");
1406 anchors_item = evas_textblock_node_format_list_get(o, "item");
1410 const Evas_Object_Textblock_Node_Format *node;
1411 const Eina_List *itr;
1412 EINA_LIST_FOREACH(anchors_a, itr, node)
1414 const char *s = evas_textblock_node_format_text_get(node);
1416 an = calloc(1, sizeof(Anchor));
1421 p = strstr(s, "href=");
1424 an->name = strdup(p + 5);
1426 en->anchors = eina_list_append(en->anchors, an);
1427 an->start = evas_object_textblock_cursor_new(o);
1428 an->end = evas_object_textblock_cursor_new(o);
1429 evas_textblock_cursor_at_format_set(an->start, node);
1430 evas_textblock_cursor_copy(an->start, an->end);
1432 /* Close the anchor, if the anchor was without text,
1433 * free it as well */
1434 node = evas_textblock_node_format_next_get(node);
1435 for (; node; node = evas_textblock_node_format_next_get(node))
1437 s = evas_textblock_node_format_text_get(node);
1438 if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
1444 evas_textblock_cursor_at_format_set(an->end, node);
1446 else if (!evas_textblock_cursor_compare(an->start, an->end))
1448 if (an->name) free(an->name);
1449 evas_textblock_cursor_free(an->start);
1450 evas_textblock_cursor_free(an->end);
1451 en->anchors = eina_list_remove(en->anchors, an);
1460 const Evas_Object_Textblock_Node_Format *node;
1461 const Eina_List *itr;
1462 EINA_LIST_FOREACH(anchors_item, itr, node)
1464 const char *s = evas_textblock_node_format_text_get(node);
1466 an = calloc(1, sizeof(Anchor));
1472 p = strstr(s, "href=");
1475 an->name = strdup(p + 5);
1477 en->anchors = eina_list_append(en->anchors, an);
1478 an->start = evas_object_textblock_cursor_new(o);
1479 an->end = evas_object_textblock_cursor_new(o);
1480 evas_textblock_cursor_at_format_set(an->start, node);
1481 evas_textblock_cursor_copy(an->start, an->end);
1482 /* Although needed in textblock, don't bother with finding the end
1483 * here cause it doesn't really matter. */
1489 _free_entry_change_info(void *_info)
1491 Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
1494 eina_stringshare_del(info->change.insert.content);
1498 eina_stringshare_del(info->change.del.content);
1504 _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1508 Edje_Entry_Change_Info *info;
1510 start = evas_textblock_cursor_pos_get(en->sel_start);
1511 end = evas_textblock_cursor_pos_get(en->sel_end);
1515 info = calloc(1, sizeof(*info));
1516 info->insert = EINA_FALSE;
1517 info->change.del.start = start;
1518 info->change.del.end = end;
1520 tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
1521 info->change.del.content = eina_stringshare_add(tmp);
1523 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1524 _edje_emit(ed, "entry,changed", en->rp->part->name);
1525 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
1526 _free_entry_change_info);
1528 _sel_clear(en->cursor, en->rp->object, en);
1532 _range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1534 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1535 _sel_clear(en->cursor, en->rp->object, en);
1539 _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1540 Eina_Bool backspace)
1542 if (!evas_textblock_cursor_char_next(c))
1546 evas_textblock_cursor_char_prev(c);
1548 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1549 char *tmp = evas_textblock_cursor_content_get(c);
1551 info->insert = EINA_FALSE;
1554 info->change.del.start = pos - 1;
1555 info->change.del.end = pos;
1559 info->change.del.start = pos + 1;
1560 info->change.del.end = pos;
1563 info->change.del.content = eina_stringshare_add(tmp);
1566 evas_textblock_cursor_char_delete(c);
1567 _edje_emit(ed, "entry,changed", en->rp->part->name);
1568 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1569 info, _free_entry_change_info);
1573 _edje_entry_hide_visible_password(Edje_Real_Part *rp)
1575 const Evas_Object_Textblock_Node_Format *node;
1576 node = evas_textblock_node_format_first_get(rp->object);
1577 for (; node; node = evas_textblock_node_format_next_get(node))
1579 const char *text = evas_textblock_node_format_text_get(node);
1582 if (!strcmp(text, "+ password=off"))
1584 evas_textblock_node_format_remove_pair(rp->object,
1585 (Evas_Object_Textblock_Node_Format *) node);
1590 _edje_entry_real_part_configure(rp);
1591 _edje_emit(rp->edje, "entry,changed", rp->part->name);
1595 _password_timer_cb(void *data)
1597 Entry *en = (Entry *)data;
1598 _edje_entry_hide_visible_password(en->rp);
1599 en->pw_timer = NULL;
1600 return ECORE_CALLBACK_CANCEL;
1604 _is_modifier(const char *key)
1606 if ((!strncmp(key, "Shift", 5)) ||
1607 (!strncmp(key, "Control", 7)) ||
1608 (!strncmp(key, "Alt", 3)) ||
1609 (!strncmp(key, "Meta", 4)) ||
1610 (!strncmp(key, "Super", 5)) ||
1611 (!strncmp(key, "Hyper", 5)) ||
1612 (!strcmp(key, "Scroll_Lock")) ||
1613 (!strcmp(key, "Num_Lock")) ||
1614 (!strcmp(key, "Caps_Lock")))
1620 _compose_seq_reset(Entry *en)
1624 EINA_LIST_FREE(en->seq, str) eina_stringshare_del(str);
1625 en->composing = EINA_FALSE;
1629 _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1632 Evas_Event_Key_Down *ev = event_info;
1633 Edje_Real_Part *rp = ed->focused_part;
1635 Eina_Bool control, alt, shift;
1636 Eina_Bool multiline;
1637 Eina_Bool cursor_changed;
1640 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
1641 (!rp->typedata.text)) return;
1642 en = rp->typedata.text->entry_data;
1643 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1644 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1646 if (!ev->keyname) return;
1648 // TIZEN ONLY - START
1649 if (en->cursor_handler_show)
1651 evas_object_hide(en->cursor_handler);
1652 en->cursor_handler_show = EINA_FALSE;
1656 #ifdef HAVE_ECORE_IMF
1657 if (en->imf_context)
1659 Ecore_IMF_Event_Key_Down ecore_ev;
1660 Eina_Bool filter_ret;
1661 ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
1664 filter_ret = ecore_imf_context_filter_event(en->imf_context,
1665 ECORE_IMF_EVENT_KEY_DOWN,
1666 (Ecore_IMF_Event *)&ecore_ev);
1668 if (en->have_preedit)
1670 if (!strcmp(ev->keyname, "Down") ||
1671 (!strcmp(ev->keyname, "KP_Down") && !ev->string) ||
1672 !strcmp(ev->keyname, "Up") ||
1673 (!strcmp(ev->keyname, "KP_Up") && !ev->string) ||
1674 !strcmp(ev->keyname, "Next") ||
1675 (!strcmp(ev->keyname, "KP_Next") && !ev->string) ||
1676 !strcmp(ev->keyname, "Prior") ||
1677 (!strcmp(ev->keyname, "KP_Prior") && !ev->string) ||
1678 !strcmp(ev->keyname, "Home") ||
1679 (!strcmp(ev->keyname, "KP_Home") && !ev->string) ||
1680 !strcmp(ev->keyname, "End") ||
1681 (!strcmp(ev->keyname, "KP_End") && !ev->string))
1682 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1691 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1693 control = evas_key_modifier_is_set(ev->modifiers, "Control");
1694 alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
1695 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1696 multiline = rp->part->multiline;
1697 cursor_changed = EINA_FALSE;
1698 if (!strcmp(ev->keyname, "Escape"))
1700 _compose_seq_reset(en);
1701 // dead keys here. Escape for now (should emit these)
1702 _edje_emit(ed, "entry,key,escape", rp->part->name);
1703 // TIZEN ONLY (20130327) : This code is doing nothing for entry now.
1704 // And for Tizen "ESC" is used for another purpose.
1705 //ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1707 else if (!strcmp(ev->keyname, "Up") ||
1708 (!strcmp(ev->keyname, "KP_Up") && !ev->string))
1710 _compose_seq_reset(en);
1713 if (en->have_selection &&
1714 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1715 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1716 if (en->select_allow)
1720 _sel_start(en->cursor, rp->object, en);
1721 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1723 else _sel_clear(en->cursor, rp->object, en);
1725 if (_curs_up(en->cursor, rp->object, en))
1726 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1727 if (en->select_allow)
1729 if (shift) _sel_extend(en->cursor, rp->object, en);
1730 else _sel_clear(en->cursor, rp->object, en);
1733 _edje_emit(ed, "entry,key,up", rp->part->name);
1734 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1736 else if (!strcmp(ev->keyname, "Down") ||
1737 (!strcmp(ev->keyname, "KP_Down") && !ev->string))
1739 _compose_seq_reset(en);
1742 if (en->have_selection &&
1743 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1744 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1745 if (en->select_allow)
1749 _sel_start(en->cursor, rp->object, en);
1750 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1752 else _sel_clear(en->cursor, rp->object, en);
1754 if (_curs_down(en->cursor, rp->object, en))
1755 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1756 if (en->select_allow)
1758 if (shift) _sel_extend(en->cursor, rp->object, en);
1759 else _sel_clear(en->cursor, rp->object, en);
1762 _edje_emit(ed, "entry,key,down", rp->part->name);
1763 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1765 else if (!strcmp(ev->keyname, "Left") ||
1766 (!strcmp(ev->keyname, "KP_Left") && !ev->string))
1768 _compose_seq_reset(en);
1769 if (en->have_selection &&
1770 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1771 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1772 if (en->select_allow)
1776 _sel_start(en->cursor, rp->object, en);
1777 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1779 else _sel_clear(en->cursor, rp->object, en);
1781 if (evas_textblock_cursor_char_prev(en->cursor))
1782 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1783 /* If control is pressed, go to the start of the word */
1784 if (control) evas_textblock_cursor_word_start(en->cursor);
1785 if (en->select_allow)
1787 if (shift) _sel_extend(en->cursor, rp->object, en);
1788 else _sel_clear(en->cursor, rp->object, en);
1790 _edje_emit(ed, "entry,key,left", rp->part->name);
1791 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1793 else if (!strcmp(ev->keyname, "Right") ||
1794 (!strcmp(ev->keyname, "KP_Right") && !ev->string))
1796 _compose_seq_reset(en);
1797 if (en->have_selection &&
1798 (evas_textblock_cursor_pos_get(en->sel_start) != evas_textblock_cursor_pos_get(en->sel_end)))
1799 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1800 if (en->select_allow)
1804 _sel_start(en->cursor, rp->object, en);
1805 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1807 else _sel_clear(en->cursor, rp->object, en);
1809 /* If control is pressed, go to the end of the word */
1810 if (control) evas_textblock_cursor_word_end(en->cursor);
1811 if (evas_textblock_cursor_char_next(en->cursor))
1812 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1813 if (en->select_allow)
1815 if (shift) _sel_extend(en->cursor, rp->object, en);
1816 else _sel_clear(en->cursor, rp->object, en);
1818 _edje_emit(ed, "entry,key,right", rp->part->name);
1819 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1821 else if (!strcmp(ev->keyname, "BackSpace"))
1823 _compose_seq_reset(en);
1824 if (control && !en->have_selection)
1826 // del to start of previous word
1827 _sel_start(en->cursor, rp->object, en);
1829 evas_textblock_cursor_char_prev(en->cursor);
1830 evas_textblock_cursor_word_start(en->cursor);
1832 _sel_preextend(en->cursor, rp->object, en);
1834 _range_del_emit(ed, en->cursor, rp->object, en);
1836 else if ((alt) && (shift))
1842 if (en->have_selection)
1844 _range_del_emit(ed, en->cursor, rp->object, en);
1848 if (evas_textblock_cursor_char_prev(en->cursor))
1850 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
1854 _sel_clear(en->cursor, rp->object, en);
1855 _anchors_get(en->cursor, rp->object, en);
1856 _edje_emit(ed, "entry,key,backspace", rp->part->name);
1857 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1859 else if (!strcmp(ev->keyname, "Delete") ||
1860 (!strcmp(ev->keyname, "KP_Delete") && !ev->string))
1862 _compose_seq_reset(en);
1865 // del to end of next word
1866 _sel_start(en->cursor, rp->object, en);
1868 evas_textblock_cursor_word_end(en->cursor);
1869 evas_textblock_cursor_char_next(en->cursor);
1871 _sel_extend(en->cursor, rp->object, en);
1873 _range_del_emit(ed, en->cursor, rp->object, en);
1881 if (en->have_selection)
1883 _range_del_emit(ed, en->cursor, rp->object, en);
1887 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
1890 _sel_clear(en->cursor, rp->object, en);
1891 _anchors_get(en->cursor, rp->object, en);
1892 _edje_emit(ed, "entry,key,delete", rp->part->name);
1893 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1895 else if (!strcmp(ev->keyname, "Home") ||
1896 ((!strcmp(ev->keyname, "KP_Home")) && !ev->string))
1898 _compose_seq_reset(en);
1899 if (en->select_allow)
1901 if (shift) _sel_start(en->cursor, rp->object, en);
1902 else _sel_clear(en->cursor, rp->object, en);
1904 if ((control) && (multiline))
1905 _curs_start(en->cursor, rp->object, en);
1907 _curs_lin_start(en->cursor, rp->object, en);
1908 if (en->select_allow)
1910 if (shift) _sel_extend(en->cursor, rp->object, en);
1912 _edje_emit(ed, "entry,key,home", rp->part->name);
1913 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1915 else if (!strcmp(ev->keyname, "End") ||
1916 ((!strcmp(ev->keyname, "KP_End")) && !ev->string))
1918 _compose_seq_reset(en);
1919 if (en->select_allow)
1921 if (shift) _sel_start(en->cursor, rp->object, en);
1922 else _sel_clear(en->cursor, rp->object, en);
1924 if ((control) && (multiline))
1925 _curs_end(en->cursor, rp->object, en);
1927 _curs_lin_end(en->cursor, rp->object, en);
1928 if (en->select_allow)
1930 if (shift) _sel_extend(en->cursor, rp->object, en);
1932 _edje_emit(ed, "entry,key,end", rp->part->name);
1933 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1935 else if ((control) && (!shift) && (!strcmp(ev->keyname, "v")))
1937 _compose_seq_reset(en);
1938 _edje_emit(ed, "entry,paste,request", rp->part->name);
1939 _edje_emit(ed, "entry,paste,request,3", rp->part->name);
1940 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1942 else if ((control) && (!strcmp(ev->keyname, "a")))
1944 _compose_seq_reset(en);
1947 _edje_emit(ed, "entry,selection,none,request", rp->part->name);
1948 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1952 if (en->select_allow) // TIZEN ONLY
1953 _edje_emit(ed, "entry,selection,all,request", rp->part->name);
1954 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1957 else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->keyname, "Insert")))
1959 _compose_seq_reset(en);
1960 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1961 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1963 else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
1965 _compose_seq_reset(en);
1966 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1967 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1969 else if ((control) && (!strcmp(ev->keyname, "z")))
1971 _compose_seq_reset(en);
1975 _edje_emit(ed, "entry,redo,request", rp->part->name);
1980 _edje_emit(ed, "entry,undo,request", rp->part->name);
1982 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1984 else if ((control) && (!shift) && (!strcmp(ev->keyname, "y")))
1986 _compose_seq_reset(en);
1988 _edje_emit(ed, "entry,redo,request", rp->part->name);
1989 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1991 else if ((control) && (!shift) && (!strcmp(ev->keyname, "w")))
1993 _compose_seq_reset(en);
1994 _sel_clear(en->cursor, rp->object, en);
1995 // select current word?
1996 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1998 else if (!strcmp(ev->keyname, "Tab"))
2000 _compose_seq_reset(en);
2009 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2010 info->insert = EINA_TRUE;
2011 info->change.insert.plain_length = 1;
2013 if (en->have_selection)
2015 _range_del_emit(ed, en->cursor, rp->object, en);
2016 info->merge = EINA_TRUE;
2018 info->change.insert.pos =
2019 evas_textblock_cursor_pos_get(en->cursor);
2020 info->change.insert.content = eina_stringshare_add("<tab/>");
2022 // evas_textblock_cursor_format_prepend(en->cursor, "tab");
2023 _text_filter_format_prepend(en, en->cursor, "tab");
2024 _anchors_get(en->cursor, rp->object, en);
2025 _edje_emit(ed, "entry,changed", rp->part->name);
2026 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
2027 info, _free_entry_change_info);
2029 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2031 _edje_emit(ed, "entry,key,tab", rp->part->name);
2033 else if ((!strcmp(ev->keyname, "ISO_Left_Tab")) && (multiline))
2035 _compose_seq_reset(en);
2037 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2039 else if (!strcmp(ev->keyname, "Prior") ||
2040 (!strcmp(ev->keyname, "KP_Prior") && !ev->string))
2042 _compose_seq_reset(en);
2043 if (en->select_allow)
2045 if (shift) _sel_start(en->cursor, rp->object, en);
2046 else _sel_clear(en->cursor, rp->object, en);
2048 _curs_jump_line_by(en->cursor, rp->object, en, -10);
2049 if (en->select_allow)
2051 if (shift) _sel_extend(en->cursor, rp->object, en);
2052 else _sel_clear(en->cursor, rp->object, en);
2054 _edje_emit(ed, "entry,key,pgup", rp->part->name);
2055 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2057 else if (!strcmp(ev->keyname, "Next") ||
2058 (!strcmp(ev->keyname, "KP_Next") && !ev->string))
2060 _compose_seq_reset(en);
2061 if (en->select_allow)
2063 if (shift) _sel_start(en->cursor, rp->object, en);
2064 else _sel_clear(en->cursor, rp->object, en);
2066 _curs_jump_line_by(en->cursor, rp->object, en, 10);
2067 if (en->select_allow)
2069 if (shift) _sel_extend(en->cursor, rp->object, en);
2070 else _sel_clear(en->cursor, rp->object, en);
2072 _edje_emit(ed, "entry,key,pgdn", rp->part->name);
2073 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2075 else if ((!strcmp(ev->keyname, "Return")) || (!strcmp(ev->keyname, "KP_Enter")))
2077 _compose_seq_reset(en);
2080 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2081 info->insert = EINA_TRUE;
2082 info->change.insert.plain_length = 1;
2083 if (en->have_selection)
2085 _range_del_emit(ed, en->cursor, rp->object, en);
2086 info->merge = EINA_TRUE;
2089 info->change.insert.pos =
2090 evas_textblock_cursor_pos_get(en->cursor);
2092 evas_object_textblock_legacy_newline_get(rp->object))
2095 // evas_textblock_cursor_format_prepend(en->cursor, "br");
2096 _text_filter_format_prepend(en, en->cursor, "br");
2097 info->change.insert.content = eina_stringshare_add("<br/>");
2102 // evas_textblock_cursor_format_prepend(en->cursor, "ps");
2103 _text_filter_format_prepend(en, en->cursor, "ps");
2104 info->change.insert.content = eina_stringshare_add("<ps/>");
2106 _anchors_get(en->cursor, rp->object, en);
2107 _edje_emit(ed, "entry,changed", rp->part->name);
2108 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
2109 info, _free_entry_change_info);
2110 _edje_emit(ed, "cursor,changed", rp->part->name);
2111 cursor_changed = EINA_TRUE;
2112 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2114 _edje_emit(ed, "entry,key,enter", rp->part->name);
2118 char *compres = NULL, *string = (char *)ev->string;
2119 Eina_Bool free_string = EINA_FALSE;
2120 Ecore_Compose_State state;
2124 _compose_seq_reset(en);
2125 en->seq = eina_list_append(en->seq, eina_stringshare_add(ev->key));
2126 state = ecore_compose_get(en->seq, &compres);
2127 if (state == ECORE_COMPOSE_MIDDLE) en->composing = EINA_TRUE;
2128 else en->composing = EINA_FALSE;
2129 if (!en->composing) _compose_seq_reset(en);
2134 if (_is_modifier(ev->key)) goto end;
2135 en->seq = eina_list_append(en->seq, eina_stringshare_add(ev->key));
2136 state = ecore_compose_get(en->seq, &compres);
2137 if (state == ECORE_COMPOSE_NONE) _compose_seq_reset(en);
2138 else if (state == ECORE_COMPOSE_DONE)
2140 _compose_seq_reset(en);
2144 free_string = EINA_TRUE;
2151 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2152 info->insert = EINA_TRUE;
2153 info->change.insert.plain_length = 1;
2154 info->change.insert.content = eina_stringshare_add(string);
2156 if (en->have_selection)
2158 _range_del_emit(ed, en->cursor, rp->object, en);
2159 info->merge = EINA_TRUE;
2162 info->change.insert.pos =
2163 evas_textblock_cursor_pos_get(en->cursor);
2164 // if PASSWORD_SHOW_LAST mode, appending text with password=off tag
2165 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2166 _edje_password_show_last)
2168 _edje_entry_hide_visible_password(en->rp);
2169 _text_filter_format_prepend(en, en->cursor, "+ password=off");
2170 _text_filter_text_prepend(en, en->cursor, string);
2171 _text_filter_format_prepend(en, en->cursor, "- password");
2174 ecore_timer_del(en->pw_timer);
2175 en->pw_timer = NULL;
2177 en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
2178 _password_timer_cb, en);
2181 _text_filter_text_prepend(en, en->cursor, string);
2182 _anchors_get(en->cursor, rp->object, en);
2183 _edje_emit(ed, "entry,changed", rp->part->name);
2184 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
2185 info, _free_entry_change_info);
2186 _edje_emit(ed, "cursor,changed", rp->part->name);
2187 cursor_changed = EINA_TRUE;
2188 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2190 if (free_string) free(string);
2193 if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
2194 _edje_emit(ed, "cursor,changed", rp->part->name);
2196 _edje_entry_imf_cursor_info_set(en);
2197 _edje_entry_real_part_configure(rp);
2201 _edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2204 Edje_Real_Part *rp = ed->focused_part;
2208 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2209 (!rp->typedata.text)) return;
2210 en = rp->typedata.text->entry_data;
2211 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2212 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
2215 #ifdef HAVE_ECORE_IMF
2216 if (en->imf_context)
2218 Evas_Event_Key_Up *ev = event_info;
2219 Ecore_IMF_Event_Key_Up ecore_ev;
2221 ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev);
2222 if (ecore_imf_context_filter_event(en->imf_context,
2223 ECORE_IMF_EVENT_KEY_UP,
2224 (Ecore_IMF_Event *)&ecore_ev))
2232 // TIZEN ONLY - START
2234 _edje_entry_select_word(Edje_Real_Part *rp)
2237 if (!rp) return EINA_FALSE;
2238 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2239 (!rp->typedata.text)) return EINA_FALSE;
2241 en = rp->typedata.text->entry_data;
2242 if (!en) return EINA_FALSE;
2244 if (en->cursor_fg) evas_object_hide(en->cursor_fg);
2245 if (en->cursor_bg) evas_object_hide(en->cursor_bg);
2247 evas_textblock_cursor_word_start(en->cursor);
2249 if (evas_textblock_cursor_eol_get(en->cursor))
2251 evas_textblock_cursor_char_prev(en->cursor);
2252 evas_textblock_cursor_word_start(en->cursor);
2255 _sel_clear(en->cursor, rp->object, en);
2256 _sel_enable(en->cursor, rp->object, en);
2257 _sel_start(en->cursor, rp->object, en);
2259 evas_textblock_cursor_word_end(en->cursor);
2260 evas_textblock_cursor_char_next(en->cursor);
2262 _sel_extend(en->cursor, rp->object, en);
2263 _edje_entry_real_part_configure(rp);
2265 en->had_sel = EINA_TRUE;
2266 en->selecting = EINA_FALSE;
2272 _long_press_cb(void *data)
2274 Edje_Real_Part *rp = data;
2276 if (!rp) return ECORE_CALLBACK_CANCEL;
2277 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2278 (!rp->typedata.text)) return ECORE_CALLBACK_CANCEL;
2280 en = rp->typedata.text->entry_data;
2281 if (!en) return ECORE_CALLBACK_CANCEL;
2283 if (en->long_press_timer)
2285 ecore_timer_del(en->long_press_timer);
2286 en->long_press_timer = NULL;
2289 en->long_press_state = _ENTRY_LONG_PRESSED;
2290 en->long_press_timer = NULL;
2292 _edje_emit(en->rp->edje, "long,pressed", en->rp->part->name);
2294 if ((en->cursor_handler) && (!en->cursor_handler_disabled) && (en->focused))
2296 edje_object_signal_emit(en->cursor_handler, "edje,cursor,handle,show", "edje");
2297 evas_object_show(en->cursor_handler);
2298 en->cursor_handler_show = EINA_TRUE;
2300 return ECORE_CALLBACK_CANCEL;
2305 _edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2307 Edje_Real_Part *rp = data;
2310 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2311 (!rp->typedata.text)) return;
2312 en = rp->typedata.text->entry_data;
2314 _edje_entry_imf_cursor_location_set(en);
2318 _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2321 Edje_Real_Part *rp = data;
2322 Evas_Event_Mouse_Down *ev = event_info;
2324 Evas_Coord x, y, w, h;
2325 // Eina_Bool multiline;
2326 Evas_Textblock_Cursor *tc = NULL;
2327 Eina_Bool dosel = EINA_FALSE;
2330 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
2331 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2332 (!rp->typedata.text)) return;
2333 en = rp->typedata.text->entry_data;
2334 en->long_press_state = _ENTRY_LONG_PRESSING; // TIZEN ONLY
2335 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2336 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2338 if ((ev->button != 1) && (ev->button != 2)) return;
2340 // TIZEN ONLY - START
2341 en->dx = ev->canvas.x;
2342 en->dy = ev->canvas.y;
2345 #ifdef HAVE_ECORE_IMF
2346 if (en->imf_context)
2348 Ecore_IMF_Event_Mouse_Down ecore_ev;
2349 ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev);
2350 if (ecore_imf_context_filter_event(en->imf_context,
2351 ECORE_IMF_EVENT_MOUSE_DOWN,
2352 (Ecore_IMF_Event *)&ecore_ev))
2357 _edje_entry_imf_context_reset(rp);
2359 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
2360 en->select_mod_start = EINA_FALSE;
2361 en->select_mod_end = EINA_FALSE;
2362 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
2364 else if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
2365 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2367 if (en->select_allow) dosel = EINA_TRUE;
2369 if (ev->button == 2) dosel = EINA_FALSE;
2372 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2373 cx = ev->canvas.x - x;
2374 cy = ev->canvas.y - y;
2375 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
2379 tc = evas_object_textblock_cursor_new(rp->object);
2380 evas_textblock_cursor_copy(en->cursor, tc);
2381 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
2382 evas_textblock_cursor_line_char_first(en->cursor);
2384 evas_textblock_cursor_line_char_last(en->cursor);
2385 _sel_extend(en->cursor, rp->object, en);
2389 en->have_selection = EINA_FALSE;
2390 en->selecting = EINA_FALSE;
2391 _sel_clear(en->cursor, rp->object, en);
2392 tc = evas_object_textblock_cursor_new(rp->object);
2393 evas_textblock_cursor_copy(en->cursor, tc);
2394 evas_textblock_cursor_line_char_first(en->cursor);
2395 _sel_start(en->cursor, rp->object, en);
2396 evas_textblock_cursor_line_char_last(en->cursor);
2397 _sel_extend(en->cursor, rp->object, en);
2401 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
2405 tc = evas_object_textblock_cursor_new(rp->object);
2406 evas_textblock_cursor_copy(en->cursor, tc);
2407 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
2408 evas_textblock_cursor_word_start(en->cursor);
2411 evas_textblock_cursor_word_end(en->cursor);
2412 evas_textblock_cursor_char_next(en->cursor);
2414 _sel_extend(en->cursor, rp->object, en);
2418 en->have_selection = EINA_FALSE;
2419 en->selecting = EINA_FALSE;
2420 _sel_clear(en->cursor, rp->object, en);
2421 tc = evas_object_textblock_cursor_new(rp->object);
2422 evas_textblock_cursor_copy(en->cursor, tc);
2423 evas_textblock_cursor_word_start(en->cursor);
2424 _sel_start(en->cursor, rp->object, en);
2425 evas_textblock_cursor_word_end(en->cursor);
2426 evas_textblock_cursor_char_next(en->cursor);
2427 _sel_extend(en->cursor, rp->object, en);
2432 tc = evas_object_textblock_cursor_new(rp->object);
2433 evas_textblock_cursor_copy(en->cursor, tc);
2434 // multiline = rp->part->multiline;
2435 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2436 cx = ev->canvas.x - x;
2437 cy = ev->canvas.y - y;
2438 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2440 evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
2444 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2446 Evas_Coord lx, ly, lw, lh;
2449 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2452 if (rp->part->multiline)
2453 _curs_end(en->cursor, rp->object, en);
2456 evas_textblock_cursor_paragraph_first(en->cursor);
2457 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2458 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2459 _curs_end(en->cursor, rp->object, en);
2466 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2469 _curs_lin_start(en->cursor, rp->object, en);
2474 _curs_lin_start(en->cursor, rp->object, en);
2476 _curs_lin_end(en->cursor, rp->object, en);
2483 if ((en->have_selection) &&
2484 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2487 _sel_extend(en->cursor, rp->object, en);
2490 Eina_List *first, *last;
2494 last = eina_list_last(en->sel);
2497 Evas_Textblock_Rectangle *r1, *r2;
2498 Evas_Coord d, d1, d2;
2504 d = (r1->y + (r1->h / 2)) - cy;
2506 d = r2->x + r2->w - 1 - cx;
2508 d = (r2->y + (r2->h / 2)) - cy;
2510 sc = rp->edje->scale;
2511 if (sc == ZERO) sc = _edje_scale;
2512 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
2518 en->select_mod_start = EINA_TRUE;
2519 en->selecting = EINA_TRUE;
2526 en->select_mod_end = EINA_TRUE;
2527 en->selecting = EINA_TRUE;
2533 else if ((en->have_selection) &&
2534 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2535 { // TIZEN ONLY - START
2537 _sel_extend(en->cursor, rp->object, en);
2538 } // TIZEN ONLY - END
2541 if ((en->have_selection) && (shift))
2542 _sel_extend(en->cursor, rp->object, en);
2545 en->selecting = EINA_TRUE;
2546 _sel_clear(en->cursor, rp->object, en);
2547 if (en->select_allow)
2549 _sel_start(en->cursor, rp->object, en);
2555 if (evas_textblock_cursor_compare(tc, en->cursor))
2557 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2558 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2560 evas_textblock_cursor_free(tc);
2562 // TIZEN ONLY - START
2563 if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2565 if (en->long_press_timer) ecore_timer_del(en->long_press_timer);
2566 en->long_press_timer = ecore_timer_add(0.5, _long_press_cb, data); //FIXME: timer value
2569 _edje_entry_real_part_configure(rp);
2570 if (ev->button == 2)
2572 _edje_emit(rp->edje, "entry,paste,request", rp->part->name);
2573 _edje_emit(rp->edje, "entry,paste,request,1", rp->part->name);
2578 _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2581 Edje_Real_Part *rp = data;
2582 Evas_Event_Mouse_Up *ev = event_info;
2584 Evas_Coord x, y, w, h;
2585 Evas_Textblock_Cursor *tc;
2586 if (ev->button != 1) return;
2588 //if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; //TIZEN ONLY
2589 //if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return; // TIZEN ONLY
2590 //if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return; // TIZEN ONLY
2591 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2592 (!rp->typedata.text)) return;
2593 en = rp->typedata.text->entry_data;
2594 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2595 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2598 // TIZEN ONLY - START
2599 if (en->long_press_timer)
2601 ecore_timer_del(en->long_press_timer);
2602 en->long_press_timer = NULL;
2605 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2607 _edje_entry_imf_cursor_info_set(en);
2611 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return;
2612 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return;
2614 if (en->long_press_state == _ENTRY_LONG_PRESSED)
2616 en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2617 _edje_entry_imf_cursor_info_set(en);
2619 if ((strcmp(_edje_entry_text_get(rp), "") == 0) && (en->cursor_handler_show))
2621 evas_object_hide(en->cursor_handler);
2622 en->cursor_handler_show = EINA_FALSE;
2626 en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2628 if ((en->cursor_handler) && (!en->cursor_handler_disabled) && (!en->have_selection))
2630 evas_object_show(en->cursor_handler);
2631 en->cursor_handler_show = EINA_TRUE;
2635 #ifdef HAVE_ECORE_IMF
2636 if (en->imf_context)
2638 Ecore_IMF_Event_Mouse_Up ecore_ev;
2639 ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev);
2640 if (ecore_imf_context_filter_event(en->imf_context,
2641 ECORE_IMF_EVENT_MOUSE_UP,
2642 (Ecore_IMF_Event *)&ecore_ev))
2647 tc = evas_object_textblock_cursor_new(rp->object);
2648 evas_textblock_cursor_copy(en->cursor, tc);
2649 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2650 cx = ev->canvas.x - x;
2651 cy = ev->canvas.y - y;
2652 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2654 Evas_Coord lx, ly, lw, lh;
2657 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
2660 if (rp->part->multiline)
2661 _curs_end(en->cursor, rp->object, en);
2664 evas_textblock_cursor_paragraph_first(en->cursor);
2665 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2666 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2667 _curs_end(en->cursor, rp->object, en);
2674 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2677 _curs_lin_start(en->cursor, rp->object, en);
2682 _curs_lin_start(en->cursor, rp->object, en);
2684 _curs_lin_end(en->cursor, rp->object, en);
2688 if (rp->part->select_mode != EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2690 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
2692 if (en->select_allow)
2696 if (en->select_mod_end)
2697 _sel_extend(en->cursor, rp->object, en);
2698 else if (en->select_mod_start)
2699 _sel_preextend(en->cursor, rp->object, en);
2702 _sel_extend(en->cursor, rp->object, en);
2703 //evas_textblock_cursor_copy(en->cursor, en->sel_end);
2707 evas_textblock_cursor_copy(en->cursor, en->sel_end);
2711 if (en->have_selection)
2712 en->had_sel = EINA_TRUE;
2713 en->selecting = EINA_FALSE;
2716 else // TIZEN ONLY - START
2720 dx = en->dx - ev->canvas.x;
2721 dy = en->dy - ev->canvas.y;
2722 if (((dx * dx) + (dy * dy)) < (40 * 40)) //FIXME: maxing number!
2724 _sel_clear(en->cursor, en->rp->object, en);
2726 } // TIZEN ONLY - END
2728 if (evas_textblock_cursor_compare(tc, en->cursor))
2730 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2731 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2734 _edje_entry_imf_cursor_info_set(en);
2736 evas_textblock_cursor_free(tc);
2738 _edje_entry_real_part_configure(rp);
2742 _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2745 Edje_Real_Part *rp = data;
2746 Evas_Event_Mouse_Move *ev = event_info;
2748 Evas_Coord x, y, w, h;
2749 Evas_Textblock_Cursor *tc;
2751 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2752 (!rp->typedata.text)) return;
2753 en = rp->typedata.text->entry_data;
2754 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2755 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2758 #ifdef HAVE_ECORE_IMF
2759 if (en->imf_context)
2761 Ecore_IMF_Event_Mouse_Move ecore_ev;
2762 ecore_imf_evas_event_mouse_move_wrap(ev, &ecore_ev);
2763 if (ecore_imf_context_filter_event(en->imf_context,
2764 ECORE_IMF_EVENT_MOUSE_MOVE,
2765 (Ecore_IMF_Event *)&ecore_ev))
2770 // TIZEN ONLY - START
2771 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
2773 _edje_entry_real_part_configure(rp);
2775 if (en->long_press_state == _ENTRY_LONG_PRESSING)
2779 dx = en->dx - ev->cur.canvas.x;
2780 dy = en->dy - ev->cur.canvas.y;
2782 /* FIXME: Magic number 40 is used to ignore finger move while detecting long press. */
2783 /* This should be replaced with the constant or variable relevant to the elm_finger_size. */
2784 if (((dx*dx) + (dy*dy)) > (40*40))
2786 en->long_press_state = _ENTRY_LONG_PRESS_RELEASED;
2787 if (en->long_press_timer)
2789 ecore_timer_del(en->long_press_timer);
2790 en->long_press_timer = NULL;
2794 else if (en->long_press_state == _ENTRY_LONG_PRESSED)
2796 Evas_Coord flx, fly, flh;
2797 Evas_Coord cnx, cny;
2800 tc = evas_object_textblock_cursor_new(rp->object);
2801 evas_textblock_cursor_copy(en->cursor, tc);
2802 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2804 cx = ev->cur.canvas.x - x;
2805 cy = ev->cur.canvas.y - y;
2807 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
2808 evas_textblock_cursor_char_coord_set(en->cursor, cx, cy);
2810 /* handle the special cases in which pressed position is above the first line or below the last line */
2811 evas_object_textblock_line_number_geometry_get(rp->object, 0, &flx, &fly, NULL, &flh);
2812 evas_textblock_cursor_line_geometry_get(en->cursor, &cnx, &cny, NULL, NULL);
2813 if ((cnx == flx) && (cny == fly))
2815 /* cursor is in the first line */
2816 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, fly + flh / 2))
2817 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
2821 Evas_Textblock_Cursor *lc;
2822 Evas_Coord llx, lly, llh;
2824 lc = evas_object_textblock_cursor_new(rp->object);
2825 evas_textblock_cursor_copy(en->cursor, lc);
2826 evas_textblock_cursor_paragraph_last(lc);
2827 evas_textblock_cursor_line_geometry_get(lc, &llx, &lly, NULL, &llh);
2828 if ((cnx == llx) && (cny == lly))
2830 /* cursor is in the last line */
2831 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, lly + llh / 2))
2832 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
2834 evas_textblock_cursor_free(lc);
2836 if (evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, NULL) == -1)
2837 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
2839 if (evas_textblock_cursor_compare(tc, en->cursor))
2841 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2843 evas_textblock_cursor_free(tc);
2845 //_edje_emit(en->rp->edje, "magnifier,changed", en->rp->part->name);
2847 } // TIZEN ONLY - END
2852 tc = evas_object_textblock_cursor_new(rp->object);
2853 evas_textblock_cursor_copy(en->cursor, tc);
2854 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2855 cx = ev->cur.canvas.x - x;
2856 cy = ev->cur.canvas.y - y;
2857 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
2859 Evas_Coord lx, ly, lw, lh;
2861 if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0)
2863 if (rp->part->multiline)
2864 _curs_end(en->cursor, rp->object, en);
2867 evas_textblock_cursor_paragraph_first(en->cursor);
2868 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2869 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
2870 _curs_end(en->cursor, rp->object, en);
2875 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2877 _curs_lin_start(en->cursor, rp->object, en);
2879 _curs_lin_end(en->cursor, rp->object, en);
2883 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) ||
2884 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE))
2886 if (en->select_allow)
2890 if (en->select_mod_end)
2891 _sel_extend(en->cursor, rp->object, en);
2892 else if (en->select_mod_start)
2893 _sel_preextend(en->cursor, rp->object, en);
2896 _sel_extend(en->cursor, rp->object, en);
2901 _sel_extend(en->cursor, rp->object, en);
2903 if (en->select_allow)
2905 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0)
2906 _sel_enable(en->cursor, rp->object, en);
2907 if (en->have_selection)
2908 _sel_update(en->cursor, rp->object, en);
2910 if (evas_textblock_cursor_compare(tc, en->cursor))
2912 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2913 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
2915 evas_textblock_cursor_free(tc);
2917 _edje_entry_real_part_configure(rp);
2922 // TIZEN ONLY - START
2924 _cursor_handler_click_cb(void *data)
2926 Edje_Real_Part *rp = data;
2928 if (!rp) return ECORE_CALLBACK_CANCEL;
2929 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2930 (!rp->typedata.text)) return ECORE_CALLBACK_CANCEL;
2931 en = rp->typedata.text->entry_data;
2932 if (!en) return ECORE_CALLBACK_CANCEL;
2934 if (en->cursor_handler_click_timer)
2936 ecore_timer_del(en->cursor_handler_click_timer);
2937 en->cursor_handler_click_timer = NULL;
2939 en->cursor_handler_click_timer = NULL;
2941 return ECORE_CALLBACK_CANCEL;
2945 _edje_entry_cursor_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
2948 Edje_Real_Part *rp = data;
2949 Evas_Event_Mouse_Down *ev = event_info;
2950 Evas_Coord ox, oy, ow, oh;
2951 Evas_Coord lx, ly, lw, lh;
2954 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2955 (!rp->typedata.text)) return;
2956 en = rp->typedata.text->entry_data;
2958 if (ev->button != 1) return;
2960 en->rx = en->sx = ev->canvas.x;
2961 en->ry = en->sy = ev->canvas.y;
2963 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
2964 edje_object_size_min_calc(obj, &ow, &oh);
2965 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
2967 en->ox = ox + ow/2 - en->rx;
2968 en->oy = oy - en->ry - lh/2;
2970 _edje_emit(rp->edje, "cursor,handler,move,start", en->rp->part->name);
2972 if (en->cursor_handler_click_timer) ecore_timer_del(en->cursor_handler_click_timer);
2973 en->cursor_handler_click_timer = ecore_timer_add(0.1, _cursor_handler_click_cb, data); //FIXME: timer value
2977 _edje_entry_cursor_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2980 Edje_Real_Part *rp = data;
2981 Evas_Event_Mouse_Up *ev = event_info;
2984 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
2985 (!rp->typedata.text)) return;
2986 en = rp->typedata.text->entry_data;
2988 if (ev->button != 1) return;
2990 if (en->cursor_handler_click_timer)
2992 ecore_timer_del(en->cursor_handler_click_timer);
2993 en->cursor_handler_click_timer = NULL;
2995 _edje_emit(rp->edje, "cursor,handler,clicked", rp->part->name);
2999 _edje_entry_imf_cursor_info_set(en);
3000 _edje_emit(rp->edje, "cursor,handler,move,end", en->rp->part->name);
3005 _edje_entry_cursor_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3008 Edje_Real_Part *rp = data;
3009 Evas_Event_Mouse_Move *ev = event_info;
3010 Evas_Coord x, y, tx, ty, tw, th;
3016 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3017 (!rp->typedata.text)) return;
3018 en = rp->typedata.text->entry_data;
3020 if (ev->buttons != 1) return;
3022 x = ev->cur.canvas.x;
3023 y = ev->cur.canvas.y;
3025 en->rx += (x - en->sx);
3026 en->ry += (y - en->sy);
3027 en->sx = ev->cur.canvas.x;
3028 en->sy = ev->cur.canvas.y;
3030 evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3031 evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3033 cx = en->rx + en->ox - tx;
3034 cy = en->ry + en->oy - ty;
3036 evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, &lh);
3037 if (cx <= 0) cx = 1;
3038 if (cy <= 0) cy = lh / 2;
3039 if (cy > th) cy = th - 1;
3041 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
3042 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
3044 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
3046 else if (evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, NULL) == -1)
3048 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
3051 //_edje_entry_imf_cursor_info_set(en);
3052 _edje_emit(rp->edje, "cursor,changed", rp->part->name); //to scroll scroller
3053 _edje_entry_real_part_configure(rp);
3055 _edje_emit(rp->edje, "cursor,handler,moving", rp->part->name);
3059 _edje_entry_start_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
3061 Evas_Event_Mouse_Down *ev = event_info;
3062 Evas_Coord ox, oy, ow, oh;
3063 Evas_Coord lx, ly, lw, lh;
3064 Edje_Real_Part *rp = data;
3065 Entry *en = rp->typedata.text->entry_data;
3067 if (ev->button != 1) return;
3069 _edje_entry_cursor_copy(rp, EDJE_CURSOR_SELECTION_BEGIN, EDJE_CURSOR_MAIN);
3070 en->rx = en->sx = ev->canvas.x;
3071 en->ry = en->sy = ev->canvas.y;
3073 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
3074 edje_object_size_min_calc(obj, &ow, &oh);
3075 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
3077 en->ox = ox + ow/2 - en->rx;
3078 //en->oy = oy + oh - en->ry + lh/2;
3079 en->oy = oy + oh - en->ry - lh/2;
3081 en->select_mod_start = EINA_TRUE;
3082 en->selecting = EINA_TRUE;
3084 _edje_emit(en->rp->edje, "handler,move,start", en->rp->part->name);
3088 _edje_entry_start_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3090 Edje_Real_Part *rp = data;
3091 Entry *en = rp->typedata.text->entry_data;
3093 //switch sel_start,end
3094 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) >= 0)
3096 Evas_Textblock_Cursor *tc;
3097 tc = evas_object_textblock_cursor_new(rp->object);
3098 evas_textblock_cursor_copy(en->sel_start, tc);
3099 evas_textblock_cursor_copy(en->sel_end, en->sel_start);
3100 evas_textblock_cursor_copy(tc, en->sel_end);
3101 evas_textblock_cursor_free(tc);
3104 en->handler_bypassing = EINA_FALSE;
3105 _edje_entry_real_part_configure(rp);
3107 _edje_emit(en->rp->edje, "handler,move,end", en->rp->part->name);
3111 _edje_entry_start_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3113 Evas_Event_Mouse_Move *ev = event_info;
3114 Edje_Real_Part *rp = data;
3115 Entry *en = rp->typedata.text->entry_data;
3116 Evas_Coord x, y, tx, ty, tw, th;
3119 Evas_Textblock_Cursor_Type cur_type;
3123 if (ev->buttons != 1) return;
3125 x = ev->cur.canvas.x;
3126 y = ev->cur.canvas.y;
3128 en->rx += (x - en->sx);
3129 en->ry += (y - en->sy);
3130 en->sx = ev->cur.canvas.x;
3131 en->sy = ev->cur.canvas.y;
3133 evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3134 evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3136 cx = en->rx + en->ox - tx;
3137 cy = en->ry + en->oy - ty;
3139 evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, &lh);
3140 if (cx <= 0) cx = 1;
3141 if (cy < lh / 2) cy = lh / 2;
3142 if (cy > th) cy = th - 1;
3144 switch (rp->part->cursor_mode)
3146 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3147 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3149 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3151 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3154 evas_textblock_cursor_geometry_get(en->sel_end, &sx, &sy, NULL, NULL, NULL, cur_type);
3155 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
3156 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
3158 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
3160 else if (evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, NULL) == -1)
3162 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
3166 if (evas_textblock_cursor_compare(en->cursor, en->sel_end) >= 0)
3167 en->handler_bypassing = EINA_TRUE;
3169 en->handler_bypassing = EINA_FALSE;
3172 if (en->select_allow)
3176 if (en->select_mod_start)
3177 _sel_preextend(en->cursor, rp->object, en);
3180 _edje_entry_real_part_configure(rp);
3181 _edje_emit(en->rp->edje, "handler,moving", en->rp->part->name);
3185 _edje_entry_end_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3187 Evas_Event_Mouse_Down *ev = event_info;
3188 Evas_Coord ox, oy, ow, oh;
3189 Evas_Coord lx, ly, lw, lh;
3190 Edje_Real_Part *rp = data;
3191 Entry *en = rp->typedata.text->entry_data;
3193 if (ev->button != 1) return;
3195 _edje_entry_cursor_copy(rp, EDJE_CURSOR_SELECTION_END, EDJE_CURSOR_MAIN);
3196 en->rx = en->sx = ev->canvas.x;
3197 en->ry = en->sy = ev->canvas.y;
3199 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
3200 edje_object_size_min_calc(obj, &ow, &oh);
3201 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
3203 en->ox = ox + ow/2 - en->rx;
3204 en->oy = oy - en->ry - lh/2;
3206 en->select_mod_end = EINA_TRUE;
3207 en->selecting = EINA_TRUE;
3209 _edje_emit(en->rp->edje, "handler,move,start", en->rp->part->name);
3213 _edje_entry_end_handler_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3215 Edje_Real_Part *rp = data;
3216 Entry *en = rp->typedata.text->entry_data;
3218 //switch sel_start,end
3219 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) >= 0)
3221 Evas_Textblock_Cursor *tc;
3222 tc = evas_object_textblock_cursor_new(rp->object);
3223 evas_textblock_cursor_copy(en->sel_start, tc);
3224 evas_textblock_cursor_copy(en->sel_end, en->sel_start);
3225 evas_textblock_cursor_copy(tc, en->sel_end);
3227 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) == 0)
3229 evas_textblock_cursor_char_next(en->sel_end);
3231 evas_textblock_cursor_free(tc);
3234 en->handler_bypassing = EINA_FALSE;
3235 _edje_entry_real_part_configure(rp);
3237 _edje_emit(en->rp->edje, "handler,move,end", en->rp->part->name);
3241 _edje_entry_end_handler_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
3243 Evas_Event_Mouse_Move *ev = event_info;
3244 Edje_Real_Part *rp = data;
3245 Entry *en = rp->typedata.text->entry_data;
3246 Evas_Coord x, y, tx, ty, tw, th;
3249 Evas_Textblock_Cursor_Type cur_type;
3253 if (ev->buttons != 1) return;
3255 x = ev->cur.canvas.x;
3256 y = ev->cur.canvas.y;
3258 en->rx += (x - en->sx);
3259 en->ry += (y - en->sy);
3260 en->sx = ev->cur.canvas.x;
3261 en->sy = ev->cur.canvas.y;
3263 evas_object_geometry_get(rp->object, &tx, &ty, NULL, NULL);
3264 evas_object_textblock_size_formatted_get(rp->object, &tw, &th);
3266 cx = en->rx + en->ox - tx;
3267 cy = en->ry + en->oy - ty;
3269 evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, &lh);
3271 if (cy < lh / 2) cy = lh / 2;
3272 if (cy > th) cy = th - 1;
3274 switch (rp->part->cursor_mode)
3276 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3277 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3279 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3281 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3284 evas_textblock_cursor_geometry_get(en->sel_start, &sx, &sy, NULL, NULL, NULL, cur_type);
3285 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
3286 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
3288 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
3290 else if (evas_textblock_cursor_line_geometry_get(en->cursor, NULL, NULL, NULL, NULL) == -1)
3292 evas_textblock_cursor_pos_set(en->cursor, old_cur_pos);
3296 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) <= 0)
3297 en->handler_bypassing = EINA_TRUE;
3299 en->handler_bypassing = EINA_FALSE;
3302 if (en->select_allow)
3306 if (en->select_mod_end)
3307 _sel_extend(en->cursor, rp->object, en);
3310 _edje_entry_real_part_configure(rp);
3311 _edje_emit(en->rp->edje, "handler,moving", en->rp->part->name);
3316 _evas_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info)
3318 Edje *ed = (Edje *)data;
3320 if (evas_focus_get(e) == ed->obj)
3322 _edje_focus_in_cb(data, NULL, NULL, NULL);
3327 _evas_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info)
3329 Edje *ed = (Edje *)data;
3331 if (evas_focus_get(e) == ed->obj)
3333 _edje_focus_out_cb(data, NULL, NULL, NULL);
3337 /***************************************************************/
3339 _edje_entry_init(Edje *ed)
3341 if (!ed->has_entries)
3343 if (ed->entries_inited)
3345 ed->entries_inited = EINA_TRUE;
3347 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed);
3348 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed);
3349 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed);
3350 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed);
3351 evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed);
3352 evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed);
3356 _edje_entry_shutdown(Edje *ed)
3358 if (!ed->has_entries)
3360 if (!ed->entries_inited)
3362 ed->entries_inited = EINA_FALSE;
3364 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb);
3365 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb);
3366 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb);
3367 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb);
3368 if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed)
3369 ERR("could not unregister EVAS_CALLBACK_FOCUS_IN");
3370 if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed)
3371 ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT");
3375 _edje_entry_real_part_init(Edje_Real_Part *rp)
3378 #ifdef HAVE_ECORE_IMF
3380 const Ecore_IMF_Context_Info *ctx_info;
3383 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3384 (!rp->typedata.text)) return;
3385 en = calloc(1, sizeof(Entry));
3387 rp->typedata.text->entry_data = en;
3389 en->vp_updated = EINA_FALSE;
3391 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp);
3393 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp);
3394 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp);
3395 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp);
3397 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
3398 en->select_allow = EINA_TRUE;
3400 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
3402 Edje_Part_Description_Text *txt;
3404 txt = (Edje_Part_Description_Text *)rp->chosen_description;
3406 en->select_allow = EINA_FALSE;
3407 if (txt && edje_string_get(&txt->text.repch))
3408 evas_object_textblock_replace_char_set(rp->object, edje_string_get(&txt->text.repch));
3410 evas_object_textblock_replace_char_set(rp->object, "*");
3413 en->cursor_bg = edje_object_add(rp->edje->base.evas);
3414 edje_object_file_set(en->cursor_bg, rp->edje->path, rp->part->source3);
3415 evas_object_smart_member_add(en->cursor_bg, rp->edje->obj);
3416 evas_object_stack_below(en->cursor_bg, rp->object);
3417 evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object));
3418 evas_object_pass_events_set(en->cursor_bg, EINA_TRUE);
3419 _edje_subobj_register(en->rp->edje, en->cursor_bg);
3421 en->cursor_fg = edje_object_add(rp->edje->base.evas);
3422 edje_object_file_set(en->cursor_fg, rp->edje->path, rp->part->source4);
3423 evas_object_smart_member_add(en->cursor_fg, rp->edje->obj);
3424 evas_object_stack_above(en->cursor_fg, rp->object);
3425 evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object));
3426 evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
3427 _edje_subobj_register(en->rp->edje, en->cursor_fg);
3429 /* A proxy to the main cursor. */
3430 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
3432 en->cursor_fg2 = evas_object_image_add(rp->edje->base.evas);
3433 evas_object_image_source_set(en->cursor_fg2, en->cursor_fg);
3434 evas_object_image_fill_set(en->cursor_fg2, 0, 0, 1, 1);
3435 evas_object_smart_member_add(en->cursor_fg2, rp->edje->obj);
3436 evas_object_stack_above(en->cursor_fg2, rp->object);
3437 evas_object_clip_set(en->cursor_fg2, evas_object_clip_get(rp->object));
3438 evas_object_pass_events_set(en->cursor_fg2, EINA_TRUE);
3439 _edje_subobj_register(en->rp->edje, en->cursor_fg2);
3442 // TIZEN ONLY - START
3444 en->cursor_handler_disabled = EINA_FALSE;
3445 en->cursor_handler = NULL;
3446 if (rp->part->source9)
3448 en->cursor_handler = edje_object_add(en->rp->edje->base.evas);
3449 edje_object_file_set(en->cursor_handler , en->rp->edje->path, rp->part->source9);
3451 en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, en->cursor_handler );
3453 evas_object_event_callback_add(en->cursor_handler , EVAS_CALLBACK_MOUSE_DOWN, _edje_entry_cursor_handler_mouse_down_cb, en->rp);
3454 evas_object_event_callback_add(en->cursor_handler , EVAS_CALLBACK_MOUSE_UP, _edje_entry_cursor_handler_mouse_up_cb, en->rp);
3455 evas_object_event_callback_add(en->cursor_handler , EVAS_CALLBACK_MOUSE_MOVE, _edje_entry_cursor_handler_mouse_move_cb, en->rp);
3457 en->cursor_handler_show = EINA_FALSE;
3459 en->focused = EINA_FALSE;
3461 evas_object_textblock_legacy_newline_set(rp->object, EINA_TRUE);
3463 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
3465 evas_object_show(en->cursor_bg);
3466 evas_object_show(en->cursor_fg);
3467 evas_object_show(en->cursor_fg2);
3468 en->input_panel_enable = EINA_TRUE;
3470 #ifdef HAVE_ECORE_IMF
3473 en->commit_cancel = EINA_FALSE;
3475 edje_object_signal_callback_add(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
3476 edje_object_signal_callback_add(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
3478 ctx_id = ecore_imf_context_default_id_get();
3481 ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
3482 if (!ctx_info->canvas_type ||
3483 strcmp(ctx_info->canvas_type, "evas") == 0)
3485 en->imf_context = ecore_imf_context_add(ctx_id);
3489 ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
3492 en->imf_context = ecore_imf_context_add(ctx_id);
3497 en->imf_context = NULL;
3499 if (!en->imf_context) goto done;
3501 ecore_imf_context_client_window_set
3503 (void *)ecore_evas_window_get
3504 (ecore_evas_ecore_evas_get(rp->edje->base.evas)));
3505 ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->base.evas);
3507 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
3508 _edje_entry_imf_retrieve_surrounding_cb, rp->edje);
3509 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
3510 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje);
3511 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje);
3512 ecore_imf_context_input_mode_set(en->imf_context,
3513 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
3514 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
3516 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
3517 ecore_imf_context_input_panel_language_set(en->imf_context, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
3520 #ifdef HAVE_ECORE_IMF
3523 en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
3527 _edje_entry_real_part_shutdown(Edje_Real_Part *rp)
3531 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3532 (!rp->typedata.text)) return;
3533 en = rp->typedata.text->entry_data;
3535 rp->typedata.text->entry_data = NULL;
3536 _sel_clear(en->cursor, rp->object, en);
3537 _anchors_clear(en->cursor, rp->object, en);
3538 #ifdef HAVE_ECORE_IMF
3541 // TIZEN ONLY - START
3542 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_bg);
3543 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_fg);
3544 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_start);
3545 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_end);
3546 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_edge_start);
3547 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->sel_handler_edge_end);
3548 rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_handler);
3550 evas_object_del(en->cursor_bg);
3551 evas_object_del(en->cursor_fg);
3552 evas_object_del(en->cursor_fg2);
3554 // TIZEN ONLY - START
3555 if (en->sel_handler_start)
3557 evas_object_del(en->sel_handler_start);
3558 en->sel_handler_start = NULL;
3560 if (en->sel_handler_end)
3562 evas_object_del(en->sel_handler_end);
3563 en->sel_handler_end = NULL;
3565 if (en->cursor_handler)
3567 evas_object_del(en->cursor_handler);
3568 en->cursor_handler = NULL;
3570 if (en->sel_handler_edge_start)
3572 evas_object_del(en->sel_handler_edge_start);
3573 en->sel_handler_edge_start = NULL;
3575 if (en->sel_handler_edge_end)
3577 evas_object_del(en->sel_handler_edge_end);
3578 en->sel_handler_edge_end = NULL;
3581 if (en->long_press_timer)
3583 ecore_timer_del(en->long_press_timer);
3584 en->long_press_timer = NULL;
3586 if (en->cursor_handler_click_timer)
3588 ecore_timer_del(en->cursor_handler_click_timer);
3589 en->cursor_handler_click_timer = NULL;
3595 ecore_timer_del(en->pw_timer);
3596 en->pw_timer = NULL;
3599 #ifdef HAVE_ECORE_IMF
3600 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
3602 if (en->imf_context)
3604 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb);
3605 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb);
3606 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
3608 ecore_imf_context_del(en->imf_context);
3609 en->imf_context = NULL;
3612 edje_object_signal_callback_del(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
3613 edje_object_signal_callback_del(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb);
3614 ecore_imf_shutdown();
3617 _compose_seq_reset(en);
3623 _edje_entry_real_part_configure(Edje_Real_Part *rp)
3625 Evas_Coord x, y, w, h, xx, yy, ww, hh, xx2, yy2;
3627 Evas_Textblock_Cursor_Type cur_type;
3628 Eina_Bool bidi_cursor = EINA_FALSE;
3630 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3631 (!rp->typedata.text)) return;
3632 en = rp->typedata.text->entry_data;
3634 switch (rp->part->cursor_mode)
3636 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
3637 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
3639 case EDJE_ENTRY_CURSOR_MODE_UNDER:
3640 /* no break for a resaon */
3642 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
3645 _sel_update(en->cursor, rp->object, en);
3646 _anchors_update(en->cursor, rp->object, en);
3648 xx = yy = ww = hh = -1;
3649 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
3650 /* For split cursor need to assign return value to bidi_cursor.
3651 * bidi_cursor = evas_textblock_geometry_bidi_get() */
3652 evas_textblock_cursor_geometry_bidi_get(en->cursor, &xx, &yy, &ww, &hh, &xx2, &yy2, NULL, NULL, cur_type);
3657 evas_object_move(en->cursor_bg, x + xx, y + yy);
3658 evas_object_resize(en->cursor_bg, ww, hh);
3662 evas_object_move(en->cursor_fg, x + xx, y + yy);
3663 evas_object_resize(en->cursor_fg, ww, hh);
3670 evas_object_image_fill_set(en->cursor_fg2, 0, 0, ww, hh / 2);
3671 evas_object_move(en->cursor_fg2, x + xx2, y + yy2 + (hh / 2));
3672 evas_object_resize(en->cursor_fg, ww, hh / 2);
3673 evas_object_resize(en->cursor_fg2, ww, hh / 2);
3675 evas_object_show(en->cursor_fg2);
3679 evas_object_hide(en->cursor_fg2);
3683 if (en->cursor_handler && (!en->cursor_handler_disabled || en->long_press_state == _ENTRY_LONG_PRESSED || en->long_press_state == _ENTRY_LONG_PRESSING))
3686 Evas_Coord chx, chy;
3690 evas_object_move(en->cursor_handler, chx, chy);
3691 edje_object_size_min_calc(en->cursor_handler, NULL, &chh);
3692 if (en->cursor_handler_show)
3694 if (((chx < en->viewport_region.x) || (chy < en->viewport_region.y) ||
3695 (chx > en->viewport_region.x + en->viewport_region.w) || (chy > en->viewport_region.y + en->viewport_region.h)))
3697 evas_object_hide(en->cursor_handler);
3698 en->cursor_handler_show = EINA_FALSE;
3700 else if (en->focused)
3702 if (chy + chh > en->layout_region.y + en->layout_region.h)
3704 evas_object_move(en->cursor_handler, x + xx, y + yy);
3705 edje_object_signal_emit(en->cursor_handler, "edje,cursor,handle,top", "edje");
3709 edje_object_signal_emit(en->cursor_handler, "edje,cursor,handle,show", "edje");
3717 _edje_entry_selection_get(Edje_Real_Part *rp)
3721 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3722 (!rp->typedata.text)) return NULL;
3723 en = rp->typedata.text->entry_data;
3724 if (!en) return NULL;
3725 // get selection - convert to markup
3726 if ((!en->selection) && (en->have_selection))
3727 en->selection = evas_textblock_cursor_range_text_get
3728 (en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
3729 return en->selection;
3733 _edje_entry_text_get(Edje_Real_Part *rp)
3737 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3738 (!rp->typedata.text)) return NULL;
3739 en = rp->typedata.text->entry_data;
3740 if (!en) return NULL;
3741 // get text - convert to markup
3742 return evas_object_textblock_text_markup_get(rp->object);
3746 _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
3750 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3751 (!rp->typedata.text)) return;
3752 en = rp->typedata.text->entry_data;
3754 _edje_entry_imf_context_reset(rp);
3755 // set text as markup
3756 _sel_clear(en->cursor, rp->object, en);
3757 evas_object_textblock_text_markup_set(rp->object, text);
3758 _edje_entry_set_cursor_start(rp);
3760 _anchors_get(en->cursor, rp->object, en);
3761 _edje_emit(rp->edje, "entry,changed", rp->part->name);
3763 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
3766 _edje_entry_imf_cursor_info_set(en);
3767 _edje_entry_real_part_configure(rp);
3772 /* Don't emit cursor changed cause it didn't. It's just init to 0. */
3773 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
3778 _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
3782 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3783 (!rp->typedata.text)) return;
3784 en = rp->typedata.text->entry_data;
3785 Evas_Textblock_Cursor *end_cur;
3787 end_cur = evas_object_textblock_cursor_new(rp->object);
3788 evas_textblock_cursor_paragraph_last(end_cur);
3790 _text_filter_markup_prepend(en, end_cur, text);
3791 evas_textblock_cursor_free(end_cur);
3793 /* We are updating according to the real cursor on purpose */
3794 _anchors_get(en->cursor, rp->object, en);
3795 _edje_emit(rp->edje, "entry,changed", rp->part->name);
3797 _edje_entry_real_part_configure(rp);
3801 _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
3805 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3806 (!rp->typedata.text)) return;
3807 en = rp->typedata.text->entry_data;
3809 _edje_entry_imf_context_reset(rp);
3811 // prepend markup @ cursor pos
3812 if (en->have_selection)
3813 _range_del(en->cursor, rp->object, en);
3815 // evas_object_textblock_text_markup_prepend(en->cursor, text);
3816 _text_filter_markup_prepend(en, en->cursor, text);
3817 _anchors_get(en->cursor, rp->object, en);
3818 // TIZEN ONLY - START
3819 if (en->cursor_handler_show)
3821 evas_object_hide(en->cursor_handler);
3822 en->cursor_handler_show = EINA_FALSE;
3825 _edje_emit(rp->edje, "entry,changed", rp->part->name);
3826 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
3828 _edje_entry_imf_cursor_info_set(en);
3829 _edje_entry_real_part_configure(rp);
3833 _edje_entry_set_cursor_start(Edje_Real_Part *rp)
3837 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3838 (!rp->typedata.text)) return;
3839 en = rp->typedata.text->entry_data;
3841 _curs_start(en->cursor, rp->object, en);
3843 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
3845 _edje_entry_imf_cursor_info_set(en);
3849 _edje_entry_set_cursor_end(Edje_Real_Part *rp)
3853 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3854 (!rp->typedata.text)) return;
3855 en = rp->typedata.text->entry_data;
3857 _curs_end(en->cursor, rp->object, en);
3859 _edje_entry_imf_cursor_info_set(en);
3863 _edje_entry_select_none(Edje_Real_Part *rp)
3867 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3868 (!rp->typedata.text)) return;
3869 en = rp->typedata.text->entry_data;
3871 _sel_clear(en->cursor, rp->object, en);
3875 _edje_entry_select_all(Edje_Real_Part *rp)
3879 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3880 (!rp->typedata.text)) return;
3881 en = rp->typedata.text->entry_data;
3884 _edje_entry_imf_context_reset(rp);
3886 _sel_clear(en->cursor, rp->object, en);
3887 _curs_start(en->cursor, rp->object, en);
3888 _sel_enable(en->cursor, rp->object, en);
3889 _sel_start(en->cursor, rp->object, en);
3890 _curs_end(en->cursor, rp->object, en);
3891 _sel_extend(en->cursor, rp->object, en);
3893 _edje_entry_real_part_configure(rp);
3895 // TIZEN ONLY - START
3896 en->select_allow = EINA_TRUE;
3897 en->had_sel = EINA_TRUE;
3899 _edje_emit(en->rp->edje, "selection,end", en->rp->part->name);
3904 _edje_entry_select_begin(Edje_Real_Part *rp)
3908 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3909 (!rp->typedata.text)) return;
3910 en = rp->typedata.text->entry_data;
3913 _sel_clear(en->cursor, rp->object, en);
3914 _sel_enable(en->cursor, rp->object, en);
3915 _sel_start(en->cursor, rp->object, en);
3916 _sel_extend(en->cursor, rp->object, en);
3918 _edje_entry_real_part_configure(rp);
3922 _edje_entry_select_extend(Edje_Real_Part *rp)
3926 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3927 (!rp->typedata.text)) return;
3928 en = rp->typedata.text->entry_data;
3930 _sel_extend(en->cursor, rp->object, en);
3932 _edje_entry_real_part_configure(rp);
3936 _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
3942 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3943 (!rp->typedata.text)) return NULL;
3944 en = rp->typedata.text->entry_data;
3945 if (!en) return NULL;
3946 EINA_LIST_FOREACH(en->anchors, l, an)
3948 if (an->item) continue;
3949 if (!strcmp(anchor, an->name))
3956 _edje_entry_anchors_list(Edje_Real_Part *rp)
3959 Eina_List *l, *anchors = NULL;
3962 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3963 (!rp->typedata.text)) return NULL;
3964 en = rp->typedata.text->entry_data;
3965 if (!en) return NULL;
3966 if (!en->anchorlist)
3968 EINA_LIST_FOREACH(en->anchors, l, an)
3970 const char *n = an->name;
3971 if (an->item) continue;
3973 anchors = eina_list_append(anchors, strdup(n));
3975 en->anchorlist = anchors;
3977 return en->anchorlist;
3981 _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
3987 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
3988 (!rp->typedata.text)) return EINA_FALSE;
3989 en = rp->typedata.text->entry_data;
3990 if (!en) return EINA_FALSE;
3991 EINA_LIST_FOREACH(en->anchors, l, an)
3993 if (an->item) continue;
3994 if (!strcmp(item, an->name))
3996 evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
4004 _edje_entry_items_list(Edje_Real_Part *rp)
4007 Eina_List *l, *items = NULL;
4010 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4011 (!rp->typedata.text)) return NULL;
4012 en = rp->typedata.text->entry_data;
4013 if (!en) return NULL;
4016 EINA_LIST_FOREACH(en->anchors, l, an)
4018 const char *n = an->name;
4019 if (an->item) continue;
4021 items = eina_list_append(items, strdup(n));
4023 en->itemlist = items;
4025 return en->itemlist;
4028 // TIZEN ONLY - START
4030 _edje_entry_layout_region_set(Edje_Real_Part *rp, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
4034 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4035 (!rp->typedata.text)) return;
4036 en = rp->typedata.text->entry_data;
4039 en->layout_region.x = x;
4040 en->layout_region.y = y;
4041 en->layout_region.w = w;
4042 en->layout_region.h = h;
4043 _sel_update(en->cursor, rp->object, en);
4047 _edje_entry_viewport_region_set(Edje_Real_Part *rp, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
4050 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4051 (!rp->typedata.text)) return;
4052 en = rp->typedata.text->entry_data;
4055 en->viewport_region.x = x;
4056 en->viewport_region.y = y;
4057 en->viewport_region.w = w;
4058 en->viewport_region.h = h;
4059 en->vp_updated = EINA_TRUE;
4060 _sel_update(en->cursor, rp->object, en);
4064 _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)
4067 Evas_Coord ex, ey, hx, hy, edx, edy, edw, edh;
4068 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4069 (!rp->typedata.text)) return;
4070 en = rp->typedata.text->entry_data;
4073 evas_object_geometry_get(rp->object, &ex, &ey, NULL, NULL);
4076 case EDJE_SELECTION_HANDLER_START:
4077 if (en->sel_handler_start)
4079 evas_object_geometry_get(en->sel_handler_start, &hx, &hy, NULL, NULL);
4080 edje_object_part_geometry_get(en->sel_handler_start, "handle", &edx, &edy, &edw, &edh);
4085 case EDJE_SELECTION_HANDLER_END:
4086 if (en->sel_handler_end)
4088 evas_object_geometry_get(en->sel_handler_end, &hx, &hy, NULL, NULL);
4089 edje_object_part_geometry_get(en->sel_handler_end, "handle", &edx, &edy, &edw, &edh);
4105 _edje_entry_cursor_handler_disabled_get(Edje_Real_Part *rp)
4108 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4109 (!rp->typedata.text)) return EINA_FALSE;
4110 en = rp->typedata.text->entry_data;
4111 if (!en) return EINA_FALSE;
4112 return en->cursor_handler_disabled;
4116 _edje_entry_cursor_handler_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
4119 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4120 (!rp->typedata.text)) return;
4121 en = rp->typedata.text->entry_data;
4124 en->cursor_handler_disabled = disabled;
4129 _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
4131 Evas_Coord x, y, w, h, xx, yy, ww, hh;
4133 Evas_Textblock_Cursor_Type cur_type;
4135 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4136 (!rp->typedata.text)) return;
4137 en = rp->typedata.text->entry_data;
4139 switch (rp->part->cursor_mode)
4141 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
4142 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
4144 case EDJE_ENTRY_CURSOR_MODE_UNDER:
4145 /* no break for a resaon */
4147 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
4151 xx = yy = ww = hh = -1;
4152 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
4153 evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
4155 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
4156 edje_object_size_min_restricted_calc(en->cursor_fg, &ww, NULL, ww, 0);
4158 if (cx) *cx = x + xx;
4159 if (cy) *cy = y + yy;
4165 _edje_entry_user_insert(Edje_Real_Part *rp, const char *text)
4168 Edje_Entry_Change_Info *info;
4170 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4171 (!rp->typedata.text)) return;
4172 en = rp->typedata.text->entry_data;
4174 info = calloc(1, sizeof(*info));
4176 info->insert = EINA_TRUE;
4177 info->change.insert.plain_length = 1;
4178 info->change.insert.content = eina_stringshare_add(text);
4181 tmp = evas_textblock_text_markup_to_utf8(rp->object,
4182 info->change.insert.content);
4183 info->change.insert.plain_length = eina_unicode_utf8_get_len(tmp);
4187 if (en->have_selection)
4189 _range_del_emit(rp->edje, en->cursor, rp->object, en);
4190 info->merge = EINA_TRUE;
4192 info->change.insert.pos = evas_textblock_cursor_pos_get(en->cursor);
4193 _text_filter_markup_prepend(en, en->cursor, text);
4194 _anchors_get(en->cursor, rp->object, en);
4195 // TIZEN ONLY - START
4196 if (en->cursor_handler_show)
4198 evas_object_hide(en->cursor_handler);
4199 en->cursor_handler_show = EINA_FALSE;
4202 _edje_emit(rp->edje, "entry,changed", rp->part->name);
4203 _edje_emit_full(rp->edje, "entry,changed,user", rp->part->name,
4204 info, _free_entry_change_info);
4205 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4207 _edje_entry_imf_cursor_info_set(en);
4208 _edje_entry_real_part_configure(rp);
4212 _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
4216 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4217 (!rp->typedata.text)) return;
4218 en = rp->typedata.text->entry_data;
4220 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
4222 en->select_allow = allow;
4226 _edje_entry_select_allow_get(const Edje_Real_Part *rp)
4230 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4231 (!rp->typedata.text)) return EINA_FALSE;
4232 en = rp->typedata.text->entry_data;
4233 if (!en) return EINA_FALSE;
4234 return en->select_allow;
4238 _edje_entry_select_abort(Edje_Real_Part *rp)
4242 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4243 (!rp->typedata.text)) return;
4244 en = rp->typedata.text->entry_data;
4248 en->selecting = EINA_FALSE;
4250 _edje_entry_imf_context_reset(rp);
4251 _edje_entry_imf_cursor_info_set(en);
4252 _edje_entry_real_part_configure(rp);
4256 // TIZEN ONLY - START
4258 _edje_entry_selection_geometry_get(Edje_Real_Part *rp, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
4260 Entry *en = rp->typedata.text->entry_data;
4261 if (!en || !en->have_selection || !en->sel)
4266 Evas_Textblock_Rectangle rect;
4267 Evas_Coord tx, ty, tw, th;
4270 if (!l) return EINA_FALSE;
4271 sel = eina_list_data_get(l);
4272 if (!sel) return EINA_FALSE;
4277 l = eina_list_last(en->sel);
4278 if (!l) return EINA_FALSE;
4279 sel = eina_list_data_get(l);
4280 if (!sel) return EINA_FALSE;
4284 th = rect.y - ty + rect.h;
4286 EINA_LIST_FOREACH(en->sel, l, sel)
4290 if (tw < sel->rect.w) tw = sel->rect.w;
4291 if (sel->rect.x < tx) tx = sel->rect.x;
4296 evas_object_geometry_get(rp->object, &vx, &vy, NULL, NULL);
4310 _edje_entry_imf_context_get(Edje_Real_Part *rp)
4314 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4315 (!rp->typedata.text)) return NULL;
4316 en = rp->typedata.text->entry_data;
4317 if (!en) return NULL;
4319 #ifdef HAVE_ECORE_IMF
4320 return en->imf_context;
4327 _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type)
4331 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4332 (!rp->typedata.text)) return;
4333 en = rp->typedata.text->entry_data;
4336 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
4337 autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4339 #ifdef HAVE_ECORE_IMF
4340 if (en->imf_context)
4341 ecore_imf_context_autocapital_type_set(en->imf_context, autocapital_type);
4345 Edje_Text_Autocapital_Type
4346 _edje_entry_autocapital_type_get(Edje_Real_Part *rp)
4350 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4351 (!rp->typedata.text)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4352 en = rp->typedata.text->entry_data;
4353 if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4355 #ifdef HAVE_ECORE_IMF
4356 if (en->imf_context)
4357 return ecore_imf_context_autocapital_type_get(en->imf_context);
4360 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
4364 _edje_entry_prediction_allow_set(Edje_Real_Part *rp, Eina_Bool prediction)
4368 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4369 (!rp->typedata.text)) return;
4370 en = rp->typedata.text->entry_data;
4372 en->prediction_allow = prediction;
4373 #ifdef HAVE_ECORE_IMF
4374 if (en->imf_context)
4375 ecore_imf_context_prediction_allow_set(en->imf_context, prediction);
4380 _edje_entry_prediction_allow_get(Edje_Real_Part *rp)
4384 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4385 (!rp->typedata.text)) return EINA_FALSE;
4386 en = rp->typedata.text->entry_data;
4387 if (!en) return EINA_FALSE;
4388 return en->prediction_allow;
4392 _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled)
4396 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4397 (!rp->typedata.text)) return;
4398 en = rp->typedata.text->entry_data;
4400 en->input_panel_enable = enabled;
4401 #ifdef HAVE_ECORE_IMF
4402 if (en->imf_context)
4403 ecore_imf_context_input_panel_enabled_set(en->imf_context, enabled);
4408 _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp)
4412 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4413 (!rp->typedata.text)) return EINA_FALSE;
4414 en = rp->typedata.text->entry_data;
4415 if (!en) return EINA_FALSE;
4416 return en->input_panel_enable;
4420 _edje_entry_input_panel_show(Edje_Real_Part *rp)
4424 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4425 (!rp->typedata.text)) return;
4426 en = rp->typedata.text->entry_data;
4428 #ifdef HAVE_ECORE_IMF
4429 if (en->imf_context)
4430 ecore_imf_context_input_panel_show(en->imf_context);
4435 _edje_entry_input_panel_hide(Edje_Real_Part *rp)
4439 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4440 (!rp->typedata.text)) return;
4441 en = rp->typedata.text->entry_data;
4443 #ifdef HAVE_ECORE_IMF
4444 if (en->imf_context)
4445 ecore_imf_context_input_panel_hide(en->imf_context);
4450 _edje_entry_input_panel_language_set(Edje_Real_Part *rp, Edje_Input_Panel_Lang lang)
4454 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4455 (!rp->typedata.text)) return;
4456 en = rp->typedata.text->entry_data;
4458 en->input_panel_lang = lang;
4459 #ifdef HAVE_ECORE_IMF
4460 if (en->imf_context)
4461 ecore_imf_context_input_panel_language_set(en->imf_context, lang);
4465 Edje_Input_Panel_Lang
4466 _edje_entry_input_panel_language_get(Edje_Real_Part *rp)
4470 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4471 (!rp->typedata.text)) return EDJE_INPUT_PANEL_LANG_AUTOMATIC;
4472 en = rp->typedata.text->entry_data;
4473 if (!en) return EDJE_INPUT_PANEL_LANG_AUTOMATIC;
4474 return en->input_panel_lang;
4477 #ifdef HAVE_ECORE_IMF
4479 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data, int len)
4482 _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data __UNUSED__, int len __UNUSED__)
4487 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4488 (!rp->typedata.text)) return;
4489 en = rp->typedata.text->entry_data;
4491 #ifdef HAVE_ECORE_IMF
4492 if (en->imf_context)
4493 ecore_imf_context_input_panel_imdata_set(en->imf_context, data, len);
4497 #ifdef HAVE_ECORE_IMF
4499 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data, int *len)
4502 _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data __UNUSED__, int *len __UNUSED__)
4507 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4508 (!rp->typedata.text)) return;
4509 en = rp->typedata.text->entry_data;
4511 #ifdef HAVE_ECORE_IMF
4512 if (en->imf_context)
4513 ecore_imf_context_input_panel_imdata_get(en->imf_context, data, len);
4517 #ifdef HAVE_ECORE_IMF
4519 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type)
4522 _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type __UNUSED__)
4527 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4528 (!rp->typedata.text)) return;
4529 en = rp->typedata.text->entry_data;
4531 #ifdef HAVE_ECORE_IMF
4532 if (en->imf_context)
4533 ecore_imf_context_input_panel_return_key_type_set(en->imf_context, return_key_type);
4537 Edje_Input_Panel_Return_Key_Type
4538 _edje_entry_input_panel_return_key_type_get(Edje_Real_Part *rp)
4542 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4543 (!rp->typedata.text)) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4544 en = rp->typedata.text->entry_data;
4545 if (!en) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4546 #ifdef HAVE_ECORE_IMF
4547 if (en->imf_context)
4548 return ecore_imf_context_input_panel_return_key_type_get(en->imf_context);
4550 return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
4553 #ifdef HAVE_ECORE_IMF
4555 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled)
4558 _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled __UNUSED__)
4563 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4564 (!rp->typedata.text)) return;
4565 en = rp->typedata.text->entry_data;
4567 #ifdef HAVE_ECORE_IMF
4568 if (en->imf_context)
4569 ecore_imf_context_input_panel_return_key_disabled_set(en->imf_context, disabled);
4574 _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp)
4578 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4579 (!rp->typedata.text)) return EINA_FALSE;
4580 en = rp->typedata.text->entry_data;
4581 if (!en) return EINA_FALSE;
4582 #ifdef HAVE_ECORE_IMF
4583 if (en->imf_context)
4584 return ecore_imf_context_input_panel_return_key_disabled_get(en->imf_context);
4589 static Evas_Textblock_Cursor *
4590 _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
4594 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4595 (!rp->typedata.text)) return NULL;
4596 en = rp->typedata.text->entry_data;
4597 if (!en) return NULL;
4600 case EDJE_CURSOR_MAIN:
4602 case EDJE_CURSOR_SELECTION_BEGIN:
4603 return en->sel_start;
4604 case EDJE_CURSOR_SELECTION_END:
4606 case EDJE_CURSOR_PREEDIT_START:
4607 if (!en->preedit_start)
4608 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
4609 return en->preedit_start;
4610 case EDJE_CURSOR_PREEDIT_END:
4611 if (!en->preedit_end)
4612 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
4613 return en->preedit_end;
4614 case EDJE_CURSOR_USER:
4615 if (!en->cursor_user)
4616 en->cursor_user = evas_object_textblock_cursor_new(rp->object);
4617 return en->cursor_user;
4618 case EDJE_CURSOR_USER_EXTRA:
4619 if (!en->cursor_user_extra)
4620 en->cursor_user_extra = evas_object_textblock_cursor_new(rp->object);
4621 return en->cursor_user_extra;
4629 _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
4632 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4634 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4635 (!rp->typedata.text)) return EINA_FALSE;
4636 en = rp->typedata.text->entry_data;
4637 if (!en) return EINA_FALSE;
4639 if (!c) return EINA_FALSE;
4641 _edje_entry_imf_context_reset(rp);
4643 if (!evas_textblock_cursor_char_next(c))
4647 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4648 _edje_entry_imf_cursor_info_set(en);
4650 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4651 _edje_entry_real_part_configure(rp);
4656 _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
4659 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4661 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4662 (!rp->typedata.text)) return EINA_FALSE;
4663 en = rp->typedata.text->entry_data;
4664 if (!en) return EINA_FALSE;
4665 if (!c) return EINA_FALSE;
4667 _edje_entry_imf_context_reset(rp);
4669 if (!evas_textblock_cursor_char_prev(c))
4671 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
4672 else return EINA_FALSE;
4675 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4677 _edje_entry_imf_cursor_info_set(en);
4679 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4680 _edje_entry_real_part_configure(rp);
4685 _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
4688 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4689 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
4692 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4693 (!rp->typedata.text)) return EINA_FALSE;
4694 en = rp->typedata.text->entry_data;
4695 if (!en) return EINA_FALSE;
4696 if (!c) return EINA_FALSE;
4698 _edje_entry_imf_context_reset(rp);
4700 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
4702 if (ln < 0) return EINA_FALSE;
4703 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
4704 &lx, &ly, &lw, &lh))
4706 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
4707 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
4709 if (cx < (lx + (lw / 2)))
4710 evas_textblock_cursor_line_char_last(c);
4712 evas_textblock_cursor_line_char_last(c);
4714 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4716 _edje_entry_imf_cursor_info_set(en);
4718 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4719 _edje_entry_real_part_configure(rp);
4724 _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
4727 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4728 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
4731 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4732 (!rp->typedata.text)) return EINA_FALSE;
4733 en = rp->typedata.text->entry_data;
4734 if (!en) return EINA_FALSE;
4735 if (!c) return EINA_FALSE;
4737 _edje_entry_imf_context_reset(rp);
4739 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
4741 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
4742 &lx, &ly, &lw, &lh))
4744 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
4745 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
4747 if (cx < (lx + (lw / 2)))
4748 evas_textblock_cursor_line_char_last(c);
4750 evas_textblock_cursor_line_char_last(c);
4752 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4754 _edje_entry_imf_cursor_info_set(en);
4755 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4756 _edje_entry_real_part_configure(rp);
4761 _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
4764 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4766 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4767 (!rp->typedata.text)) return;
4768 en = rp->typedata.text->entry_data;
4772 _edje_entry_imf_context_reset(rp);
4774 evas_textblock_cursor_paragraph_first(c);
4775 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4777 _edje_entry_imf_cursor_info_set(en);
4778 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4779 _edje_entry_real_part_configure(rp);
4783 _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
4786 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4788 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4789 (!rp->typedata.text)) return;
4790 en = rp->typedata.text->entry_data;
4794 _edje_entry_imf_context_reset(rp);
4796 _curs_end(c, rp->object, rp->typedata.text->entry_data);
4797 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4799 _edje_entry_imf_cursor_info_set(en);
4801 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4802 _edje_entry_real_part_configure(rp);
4806 _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
4809 Evas_Textblock_Cursor *c;
4810 Evas_Textblock_Cursor *d;
4812 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4813 (!rp->typedata.text)) return;
4814 en = rp->typedata.text->entry_data;
4816 c = _cursor_get(rp, cur);
4818 d = _cursor_get(rp, dst);
4820 evas_textblock_cursor_copy(c, d);
4821 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4823 _edje_entry_imf_context_reset(rp);
4824 _edje_entry_imf_cursor_info_set(en);
4825 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4826 _edje_entry_real_part_configure(rp);
4830 _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
4833 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4835 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4836 (!rp->typedata.text)) return;
4837 en = rp->typedata.text->entry_data;
4840 _edje_entry_imf_context_reset(rp);
4842 evas_textblock_cursor_line_char_first(c);
4843 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4845 _edje_entry_imf_cursor_info_set(en);
4847 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4848 _edje_entry_real_part_configure(rp);
4852 _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
4855 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4857 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4858 (!rp->typedata.text)) return;
4859 en = rp->typedata.text->entry_data;
4862 _edje_entry_imf_context_reset(rp);
4863 evas_textblock_cursor_line_char_last(c);
4864 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4866 _edje_entry_imf_cursor_info_set(en);
4867 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4868 _edje_entry_real_part_configure(rp);
4872 _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
4873 Evas_Coord x, Evas_Coord y)
4875 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4876 if (!c) return EINA_FALSE;
4877 return evas_textblock_cursor_char_coord_set(c, x, y);
4881 _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
4883 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4884 if (!c) return EINA_FALSE;
4885 if (evas_textblock_cursor_is_format(c)) return EINA_TRUE;
4890 _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
4892 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4893 if (!c) return EINA_FALSE;
4894 return evas_textblock_cursor_format_is_visible_get(c);
4898 _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
4900 static char *s = NULL;
4901 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4903 if (!c) return NULL;
4910 s = evas_textblock_cursor_content_get(c);
4915 _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
4918 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4920 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4921 (!rp->typedata.text)) return;
4922 en = rp->typedata.text->entry_data;
4925 /* Abort if cursor position didn't really change */
4926 if (evas_textblock_cursor_pos_get(c) == pos)
4929 _edje_entry_imf_context_reset(rp);
4930 evas_textblock_cursor_pos_set(c, pos);
4931 _sel_update(c, rp->object, rp->typedata.text->entry_data);
4933 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
4934 // TIZEN ONLY(130129) : Currently, for freezing cursor movement.
4937 _edje_entry_imf_cursor_info_set(en);
4938 _edje_entry_real_part_configure(rp);
4944 _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur)
4946 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
4948 return evas_textblock_cursor_pos_get(c);
4952 _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout)
4956 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4957 (!rp->typedata.text)) return;
4958 en = rp->typedata.text->entry_data;
4960 #ifdef HAVE_ECORE_IMF
4961 if (en->imf_context)
4962 ecore_imf_context_input_panel_layout_set(en->imf_context, layout);
4968 Edje_Input_Panel_Layout
4969 _edje_entry_input_panel_layout_get(Edje_Real_Part *rp)
4973 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4974 (!rp->typedata.text)) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4975 en = rp->typedata.text->entry_data;
4976 if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4977 #ifdef HAVE_ECORE_IMF
4978 if (en->imf_context)
4979 return ecore_imf_context_input_panel_layout_get(en->imf_context);
4982 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
4986 _edje_entry_input_panel_layout_variation_set(Edje_Real_Part *rp, int variation)
4990 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4991 (!rp->typedata.text)) return;
4992 en = rp->typedata.text->entry_data;
4994 #ifdef HAVE_ECORE_IMF
4995 if (en->imf_context)
4996 ecore_imf_context_input_panel_layout_variation_set(en->imf_context, variation);
5003 _edje_entry_input_panel_layout_variation_get(Edje_Real_Part *rp)
5007 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5008 (!rp->typedata.text)) return 0;
5009 en = rp->typedata.text->entry_data;
5011 #ifdef HAVE_ECORE_IMF
5012 if (en->imf_context)
5013 return ecore_imf_context_input_panel_layout_variation_get(en->imf_context);
5020 _edje_entry_imf_context_reset(Edje_Real_Part *rp)
5024 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5025 (!rp->typedata.text)) return;
5026 en = rp->typedata.text->entry_data;
5028 #ifdef HAVE_ECORE_IMF
5029 if (en->imf_context)
5030 ecore_imf_context_reset(en->imf_context);
5031 if (en->commit_cancel)
5032 en->commit_cancel = EINA_FALSE;
5037 _edje_entry_imf_cursor_location_set(Entry *en)
5039 #ifdef HAVE_ECORE_IMF
5040 Evas_Coord cx, cy, cw, ch;
5041 if (!en || !en->rp || !en->imf_context) return;
5043 _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch);
5044 ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch);
5051 _edje_entry_imf_cursor_info_set(Entry *en)
5055 #ifdef HAVE_ECORE_IMF
5056 if (!en || !en->rp || !en->imf_context) return;
5058 if (en->have_selection)
5060 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0)
5061 cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
5063 cursor_pos = evas_textblock_cursor_pos_get(en->sel_end);
5066 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
5068 ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos);
5070 _edje_entry_imf_cursor_location_set(en);
5076 #ifdef HAVE_ECORE_IMF
5078 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos)
5081 Edje_Real_Part *rp = ed->focused_part;
5085 Eina_Strbuf *buf = NULL;
5087 if (!rp) return EINA_FALSE;
5088 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5089 (!rp->typedata.text)) return EINA_FALSE;
5091 en = rp->typedata.text->entry_data;
5092 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5093 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5098 str = _edje_entry_text_get(rp);
5101 plain_text = evas_textblock_text_markup_to_utf8(NULL, str);
5105 if (en->have_selection)
5107 buf = eina_strbuf_new();
5110 eina_strbuf_append_n(buf, plain_text, evas_textblock_cursor_pos_get(en->sel_start));
5112 eina_strbuf_append(buf, plain_text);
5114 *text = strdup(eina_strbuf_string_get(buf));
5115 eina_strbuf_free(buf);
5118 *text = strdup(plain_text);
5132 if (en->have_selection && en->sel_start)
5133 *cursor_pos = evas_textblock_cursor_pos_get(en->sel_start);
5134 else if (en->cursor)
5135 *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
5144 _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
5147 Edje_Real_Part *rp = ed->focused_part;
5149 char *commit_str = event_info;
5153 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5154 (!rp->typedata.text)) return;
5156 en = rp->typedata.text->entry_data;
5157 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5158 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5161 if (en->have_selection)
5163 if (strcmp(commit_str, ""))
5165 /* delete selected characters */
5166 _range_del_emit(ed, en->cursor, rp->object, en);
5167 _sel_clear(en->cursor, rp->object, en);
5171 start_pos = evas_textblock_cursor_pos_get(en->cursor);
5173 /* delete preedit characters */
5177 // Skipping commit process when it is useless
5178 if (en->commit_cancel)
5180 en->commit_cancel = EINA_FALSE;
5184 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5185 _edje_password_show_last)
5186 _edje_entry_hide_visible_password(en->rp);
5187 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5188 _edje_password_show_last && (!en->preedit_start))
5190 _text_filter_format_prepend(en, en->cursor, "+ password=off");
5191 _text_filter_text_prepend(en, en->cursor, commit_str);
5192 _text_filter_format_prepend(en, en->cursor, "- password");
5196 ecore_timer_del(en->pw_timer);
5197 en->pw_timer = NULL;
5199 en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
5200 _password_timer_cb, en);
5203 _text_filter_text_prepend(en, en->cursor, commit_str);
5206 _edje_entry_imf_cursor_info_set(en);
5207 _anchors_get(en->cursor, rp->object, en);
5208 // TIZEN ONLY - START
5209 if (en->cursor_handler_show)
5211 evas_object_hide(en->cursor_handler);
5212 en->cursor_handler_show = EINA_FALSE;
5215 _edje_emit(rp->edje, "entry,changed", rp->part->name);
5218 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
5219 info->insert = EINA_TRUE;
5220 info->change.insert.pos = start_pos;
5221 info->change.insert.content = eina_stringshare_add(commit_str);
5222 info->change.insert.plain_length =
5223 eina_unicode_utf8_get_len(info->change.insert.content);
5224 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
5225 info, _free_entry_change_info);
5226 _edje_emit(ed, "cursor,changed", rp->part->name);
5229 _edje_entry_imf_cursor_info_set(en);
5230 _edje_entry_real_part_configure(rp);
5234 _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info __UNUSED__)
5237 Edje_Real_Part *rp = ed->focused_part;
5240 int preedit_start_pos, preedit_end_pos;
5241 char *preedit_string;
5242 char *preedit_tag_index;
5243 char *pretag = NULL;
5244 char *markup_txt = NULL;
5245 char *tagname[] = {NULL, "preedit", "preedit_sel", "preedit_sel",
5246 "preedit_sub1", "preedit_sub2", "preedit_sub3", "preedit_sub4"};
5248 size_t preedit_type_size = sizeof(tagname) / sizeof(tagname[0]);
5249 Eina_Bool preedit_end_state = EINA_FALSE;
5250 Eina_List *attrs = NULL, *l = NULL;
5251 Ecore_IMF_Preedit_Attr *attr;
5253 Eina_Strbuf *preedit_attr_str;
5257 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5258 (!rp->typedata.text)) return;
5260 en = rp->typedata.text->entry_data;
5261 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5262 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5265 if (!en->imf_context) return;
5266 // TIZEN ONLY - START
5267 if (en->cursor_handler_show)
5269 evas_object_hide(en->cursor_handler);
5270 en->cursor_handler_show = EINA_FALSE;
5274 ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
5276 &attrs, &cursor_pos);
5277 if (!preedit_string) return;
5279 if (!strcmp(preedit_string, ""))
5280 preedit_end_state = EINA_TRUE;
5282 if (en->have_selection && !preedit_end_state)
5284 /* delete selected characters */
5285 _range_del_emit(ed, en->cursor, rp->object, en);
5288 if (en->preedit_start && en->preedit_end)
5290 /* extract the tag string */
5291 char *str = evas_textblock_cursor_range_text_get(en->preedit_start, en->preedit_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
5295 preedit_tag_index = strstr(str, "<preedit");
5297 if ((preedit_tag_index - str) > 0)
5299 pretag = calloc(1, sizeof(char)*(preedit_tag_index-str+1));
5300 if (preedit_tag_index)
5302 strncpy(pretag, str, preedit_tag_index-str);
5309 /* delete preedit characters */
5312 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
5314 /* restore previous tag */
5317 _text_filter_markup_prepend(en, en->cursor, pretag);
5321 /* insert preedit character(s) */
5322 if (strlen(preedit_string) > 0)
5324 buf = eina_strbuf_new();
5327 EINA_LIST_FOREACH(attrs, l, attr)
5329 if (attr->preedit_type <= preedit_type_size &&
5330 tagname[attr->preedit_type])
5332 preedit_attr_str = eina_strbuf_new();
5333 if (preedit_attr_str)
5335 eina_strbuf_append_n(preedit_attr_str, preedit_string + attr->start_index, attr->end_index - attr->start_index);
5336 markup_txt = evas_textblock_text_utf8_to_markup(NULL, eina_strbuf_string_get(preedit_attr_str));
5340 eina_strbuf_append_printf(buf, "<%s>%s</%s>", tagname[attr->preedit_type], markup_txt, tagname[attr->preedit_type]);
5343 eina_strbuf_free(preedit_attr_str);
5347 eina_strbuf_append(buf, preedit_string);
5352 eina_strbuf_append(buf, preedit_string);
5355 // For skipping useless commit
5356 if (!preedit_end_state)
5357 en->have_preedit = EINA_TRUE;
5359 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
5360 _edje_password_show_last)
5362 _edje_entry_hide_visible_password(en->rp);
5363 _text_filter_format_prepend(en, en->cursor, "+ password=off");
5364 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
5365 _text_filter_format_prepend(en, en->cursor, "- password");
5368 ecore_timer_del(en->pw_timer);
5369 en->pw_timer = NULL;
5371 en->pw_timer = ecore_timer_add(TO_DOUBLE(_edje_password_show_last_timeout),
5372 _password_timer_cb, en);
5376 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
5378 eina_strbuf_free(buf);
5381 if (!preedit_end_state)
5383 /* set preedit start cursor */
5384 if (!en->preedit_start)
5385 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
5386 evas_textblock_cursor_copy(en->cursor, en->preedit_start);
5388 /* set preedit end cursor */
5389 if (!en->preedit_end)
5390 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
5391 evas_textblock_cursor_copy(en->cursor, en->preedit_end);
5393 preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor);
5395 for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++)
5397 evas_textblock_cursor_char_prev(en->preedit_start);
5400 en->have_preedit = EINA_TRUE;
5402 /* set cursor position */
5403 evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos);
5406 _edje_entry_imf_cursor_info_set(en);
5407 _anchors_get(en->cursor, rp->object, en);
5408 _edje_emit(rp->edje, "preedit,changed", rp->part->name);
5409 _edje_emit(ed, "cursor,changed", rp->part->name);
5411 /* delete attribute list */
5414 EINA_LIST_FREE(attrs, attr) free(attr);
5417 free(preedit_string);
5421 _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
5424 Edje_Real_Part *rp = ed->focused_part;
5426 Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
5427 Evas_Textblock_Cursor *del_start, *del_end;
5430 if ((!rp) || (!ev)) return;
5431 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5432 (!rp->typedata.text)) return;
5434 en = rp->typedata.text->entry_data;
5435 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
5436 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
5439 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
5441 del_start = evas_object_textblock_cursor_new(en->rp->object);
5442 evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
5444 del_end = evas_object_textblock_cursor_new(en->rp->object);
5445 evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars);
5447 evas_textblock_cursor_range_delete(del_start, del_end);
5449 evas_textblock_cursor_free(del_start);
5450 evas_textblock_cursor_free(del_end);
5455 ////////////////////////////////////// TIZEN ONLY(130129) : START //////////////////////////////////
5456 void _edje_entry_freeze(Edje_Real_Part *rp)
5460 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5461 (!rp->typedata.text)) return;
5463 en = rp->typedata.text->entry_data;
5466 en->freeze = EINA_TRUE;
5469 void _edje_entry_thaw(Edje_Real_Part *rp)
5473 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
5474 (!rp->typedata.text)) return;
5476 en = rp->typedata.text->entry_data;
5479 en->freeze = EINA_FALSE;
5481 _edje_entry_imf_cursor_info_set(en);
5482 _edje_entry_real_part_configure(rp);
5484 /////////////////////////////////////////// TIZEN ONLY : END ////////////////////////////////////////
5486 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/