1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
4 #include "elm_module_priv.h"
7 * @defgroup Entry Entry
9 * An entry is a convenience widget which shows
10 * a box that the user can enter text into. Unlike a
11 * @ref Scrolled_Entry widget, entries DO NOT scroll with user
12 * input. Entry widgets are capable of expanding past the
13 * boundaries of the window, thus resizing the window to its
16 * You can also insert "items" in the entry with:
18 * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
20 * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
21 * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
22 * supports a list of emoticon names by default. These are:
25 * - emoticon/angry-shout
26 * - emoticon/crazy-laugh
27 * - emoticon/evil-laugh
29 * - emoticon/goggle-smile
31 * - emoticon/grumpy-smile
33 * - emoticon/guilty-smile
35 * - emoticon/half-smile
36 * - emoticon/happy-panting
38 * - emoticon/indifferent
40 * - emoticon/knowing-grin
42 * - emoticon/little-bit-sorry
43 * - emoticon/love-lots
45 * - emoticon/minimal-smile
46 * - emoticon/not-happy
47 * - emoticon/not-impressed
49 * - emoticon/opensmile
52 * - emoticon/squint-laugh
53 * - emoticon/surprised
54 * - emoticon/suspicious
55 * - emoticon/tongue-dangling
56 * - emoticon/tongue-poke
59 * - emoticon/very-sorry
65 * These are built-in currently, but you can add your own item provieer that
66 * can create inlined objects in the text and fill the space allocated to the
67 * item with a custom object of your own.
69 * See the entry test for some more examples of use of this.
71 * Entries have functions to load a text file, display it,
72 * allowing editing of it and saving of changes back to the file loaded.
73 * Changes are written back to the original file after a short delay.
74 * The file to load and save to is specified by elm_entry_file_set().
76 * Signals that you can add callbacks for are:
77 * - "changed" - The text within the entry was changed
78 * - "activated" - The entry has had editing finished and changes are to be committed (generally when enter key is pressed)
79 * - "press" - The entry has been clicked
80 * - "longpressed" - The entry has been clicked for a couple seconds
81 * - "clicked" - The entry has been clicked
82 * - "clicked,double" - The entry has been double clicked
83 * - "focused" - The entry has received focus
84 * - "unfocused" - The entry has lost focus
85 * - "selection,paste" - A paste action has occurred
86 * - "selection,copy" - A copy action has occurred
87 * - "selection,cut" - A cut action has occurred
88 * - "selection,start" - A selection has begun
89 * - "selection,changed" - The selection has changed
90 * - "selection,cleared" - The selection has been cleared
91 * - "cursor,changed" - The cursor has changed
92 * - "anchor,clicked" - The anchor has been clicked
95 typedef struct _Mod_Api Mod_Api;
97 typedef struct _Widget_Data Widget_Data;
98 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
99 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
100 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
106 Evas_Object *hoversel;
110 Evas_Object *mgf_proxy;
111 Evas_Object *mgf_clip;
113 Evas_Coord mgf_height;
116 Ecore_Job *deferred_recalc_job;
117 Ecore_Event_Handler *sel_notify_handler;
118 Ecore_Event_Handler *sel_clear_handler;
119 Ecore_Timer *longpress_timer;
120 Ecore_Timer *delay_write;
121 /* Only for clipboard */
125 int ellipsis_threshold;
127 Elm_Text_Format format;
129 Evas_Coord downx, downy;
130 Evas_Coord cx, cy, cw, ch;
132 Eina_List *item_providers;
133 Eina_List *text_filters;
134 Eina_List *match_list;
135 Ecore_Job *matchlist_job;
136 Ecore_Job *hovdeljob;
137 Mod_Api *api; // module api if supplied
139 Eina_Bool changed : 1;
140 Eina_Bool linewrap : 1;
141 Eina_Bool char_linewrap : 1;
142 Eina_Bool single_line : 1;
143 Eina_Bool password : 1;
144 Eina_Bool show_last_character : 1;
145 Eina_Bool editable : 1;
146 Eina_Bool selection_asked : 1;
147 Eina_Bool have_selection : 1;
148 Eina_Bool selmode : 1;
149 Eina_Bool deferred_cur : 1;
150 Eina_Bool disabled : 1;
151 Eina_Bool double_clicked : 1;
152 Eina_Bool long_pressed : 1;
153 Eina_Bool context_menu : 1;
154 Eina_Bool drag_selection_asked : 1;
155 Eina_Bool bgcolor : 1;
156 Eina_Bool ellipsis : 1;
157 Eina_Bool can_write : 1;
158 Eina_Bool autosave : 1;
159 Eina_Bool textonly : 1;
160 Eina_Bool autoreturnkey : 1;
161 Eina_Bool input_panel_enable : 1;
162 Eina_Bool autocapital : 1;
163 Elm_Input_Panel_Layout input_panel_layout;
164 Eina_Bool autoperiod : 1;
165 Eina_Bool matchlist_list_clicked : 1;
166 Eina_Bool matchlist_case_sensitive : 1;
167 int matchlist_threshold;
170 struct _Elm_Entry_Context_Menu_Item
174 const char *icon_file;
175 const char *icon_group;
176 Elm_Icon_Type icon_type;
181 struct _Elm_Entry_Item_Provider
183 Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
187 struct _Elm_Entry_Text_Filter
189 void (*func) (void *data, Evas_Object *entry, char **text);
193 static const char *widtype = NULL;
195 static Evas_Object *cnpwidgetdata = NULL;
198 static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
199 static void _del_hook(Evas_Object *obj);
200 static void _theme_hook(Evas_Object *obj);
201 static void _disable_hook(Evas_Object *obj);
202 static void _sizing_eval(Evas_Object *obj);
203 static void _on_focus_hook(void *data, Evas_Object *obj);
204 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
205 static const char *_getbase(Evas_Object *obj);
206 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
207 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
208 static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
209 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
210 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
211 static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
212 static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
213 static void _signal_handler_moving(void *data, Evas_Object *obj, const char *emission, const char *source);
214 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
215 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
216 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
217 static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
218 static int _get_value_in_key_string(const char *oldstring, char *key, char **value);
219 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag);
220 static int _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag);
221 static int _is_width_over(Evas_Object *obj);
222 static void _ellipsis_entry_to_width(Evas_Object *obj);
223 static void _reverse_ellipsis_entry(Evas_Object *obj);
224 static int _entry_length_get(Evas_Object *obj);
225 static void _magnifier_create(void *data);
226 static void _magnifier_show(void *data);
227 static void _magnifier_hide(void *data);
228 static void _magnifier_move(void *data);
229 static void _long_pressed(void *data);
231 static const char SIG_CHANGED[] = "changed";
232 static const char SIG_ACTIVATED[] = "activated";
233 static const char SIG_PRESS[] = "press";
234 static const char SIG_LONGPRESSED[] = "longpressed";
235 static const char SIG_CLICKED[] = "clicked";
236 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
237 static const char SIG_FOCUSED[] = "focused";
238 static const char SIG_UNFOCUSED[] = "unfocused";
239 static const char SIG_SELECTION_PASTE[] = "selection,paste";
240 static const char SIG_SELECTION_COPY[] = "selection,copy";
241 static const char SIG_SELECTION_CUT[] = "selection,cut";
242 static const char SIG_SELECTION_START[] = "selection,start";
243 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
244 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
245 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
246 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
247 static const char SIG_MATCHLIST_CLICKED[] = "matchlist,clicked";
248 static const Evas_Smart_Cb_Description _signals[] = {
252 {SIG_LONGPRESSED, ""},
254 {SIG_CLICKED_DOUBLE, ""},
257 {SIG_SELECTION_PASTE, ""},
258 {SIG_SELECTION_COPY, ""},
259 {SIG_SELECTION_CUT, ""},
260 {SIG_SELECTION_START, ""},
261 {SIG_SELECTION_CHANGED, ""},
262 {SIG_SELECTION_CLEARED, ""},
263 {SIG_CURSOR_CHANGED, ""},
264 {SIG_ANCHOR_CLICKED, ""},
265 {SIG_MATCHLIST_CLICKED, ""},
269 typedef enum _Elm_Entry_Magnifier_Type
271 _ENTRY_MAGNIFIER_FIXEDSIZE = 0,
272 _ENTRY_MAGNIFIER_FILLWIDTH,
273 _ENTRY_MAGNIFIER_CIRCULAR,
274 } Elm_Entry_Magnifier_Type;
277 static Eina_List *entries = NULL;
281 void (*obj_hook) (Evas_Object *obj);
282 void (*obj_unhook) (Evas_Object *obj);
283 void (*obj_longpress) (Evas_Object *obj);
284 void (*obj_hidemenu) (Evas_Object *obj);
285 void (*obj_mouseup) (Evas_Object *obj);
289 _module(Evas_Object *obj __UNUSED__)
291 static Elm_Module *m = NULL;
292 if (m) goto ok; // already found - just use
293 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
295 m->api = malloc(sizeof(Mod_Api));
296 if (!m->api) return NULL;
297 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
298 _elm_module_symbol_get(m, "obj_hook");
299 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
300 _elm_module_symbol_get(m, "obj_unhook");
301 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
302 _elm_module_symbol_get(m, "obj_longpress");
303 ((Mod_Api *)(m->api) )->obj_hidemenu = // called on hide menu
304 _elm_module_symbol_get(m, "obj_hidemenu");
305 ((Mod_Api *)(m->api) )->obj_mouseup = // called on mouseup
306 _elm_module_symbol_get(m, "obj_mouseup");
307 ok: // ok - return api
312 _buf_append(char *buf, const char *str, int *len, int *alloc)
314 int len2 = strlen(str);
315 if ((*len + len2) >= *alloc)
317 char *buf2 = realloc(buf, *alloc + len2 + 512);
318 if (!buf2) return NULL;
320 *alloc += (512 + len2);
322 strcpy(buf + *len, str);
328 _load_file(const char *file)
332 int alloc = 0, len = 0;
333 char *text = NULL, buf[PATH_MAX];
335 f = fopen(file, "rb");
337 while ((size = fread(buf, 1, sizeof(buf), f)))
341 tmp_text = _buf_append(text, buf, &len, &alloc);
342 if (!tmp_text) break;
350 _load_plain(const char *file)
354 text = _load_file(file);
359 text2 = elm_entry_utf8_to_markup(text);
367 _load(Evas_Object *obj)
369 Widget_Data *wd = elm_widget_data_get(obj);
374 elm_entry_entry_set(obj, "");
379 case ELM_TEXT_FORMAT_PLAIN_UTF8:
380 text = _load_plain(wd->file);
382 case ELM_TEXT_FORMAT_MARKUP_UTF8:
383 text = _load_file(wd->file);
391 elm_entry_entry_set(obj, text);
395 elm_entry_entry_set(obj, "");
399 _save_markup_utf8(const char *file, const char *text)
403 if ((!text) || (!text[0]))
405 ecore_file_unlink(file);
408 f = fopen(file, "wb");
411 // FIXME: report a write error
414 fputs(text, f); // FIXME: catch error
419 _save_plain_utf8(const char *file, const char *text)
423 text2 = elm_entry_markup_to_utf8(text);
426 _save_markup_utf8(file, text2);
431 _save(Evas_Object *obj)
433 Widget_Data *wd = elm_widget_data_get(obj);
435 if (!wd->file) return;
438 case ELM_TEXT_FORMAT_PLAIN_UTF8:
439 _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
441 case ELM_TEXT_FORMAT_MARKUP_UTF8:
442 _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
450 _delay_write(void *data)
452 Widget_Data *wd = elm_widget_data_get(data);
453 if (!wd) return ECORE_CALLBACK_CANCEL;
455 wd->delay_write = NULL;
456 return ECORE_CALLBACK_CANCEL;
460 _del_pre_hook(Evas_Object *obj)
462 Widget_Data *wd = elm_widget_data_get(obj);
466 ecore_timer_del(wd->delay_write);
467 wd->delay_write = NULL;
468 if (wd->autosave) _save(obj);
473 _del_hook(Evas_Object *obj)
475 Widget_Data *wd = elm_widget_data_get(obj);
476 Elm_Entry_Context_Menu_Item *it;
477 Elm_Entry_Item_Provider *ip;
478 Elm_Entry_Text_Filter *tf;
480 if (wd->file) eina_stringshare_del(wd->file);
482 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
483 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
485 entries = eina_list_remove(entries, obj);
486 #ifdef HAVE_ELEMENTARY_X
487 ecore_event_handler_del(wd->sel_notify_handler);
488 ecore_event_handler_del(wd->sel_clear_handler);
490 if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
491 if (wd->text) eina_stringshare_del(wd->text);
492 if (wd->bg) evas_object_del(wd->bg);
493 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
494 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
495 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
496 if (wd->mgf_proxy) evas_object_del(wd->mgf_proxy);
497 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
498 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
500 EINA_LIST_FREE(wd->items, it)
502 eina_stringshare_del(it->label);
503 eina_stringshare_del(it->icon_file);
504 eina_stringshare_del(it->icon_group);
507 EINA_LIST_FREE(wd->item_providers, ip)
511 EINA_LIST_FREE(wd->text_filters, tf)
519 _theme_hook(Evas_Object *obj)
521 Widget_Data *wd = elm_widget_data_get(obj);
523 Ecore_IMF_Context *ic;
525 t = eina_stringshare_add(elm_entry_entry_get(obj));
526 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
527 elm_entry_entry_set(obj, t);
528 eina_stringshare_del(t);
529 if (elm_widget_disabled_get(obj))
530 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
531 edje_object_message_signal_process(wd->ent);
532 edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
533 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
534 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
535 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
537 ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text");
540 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)wd->input_panel_layout);
547 _disable_hook(Evas_Object *obj)
549 Widget_Data *wd = elm_widget_data_get(obj);
551 if (elm_widget_disabled_get(obj))
553 edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
554 wd->disabled = EINA_TRUE;
558 edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
559 wd->disabled = EINA_FALSE;
564 _elm_win_recalc_job(void *data)
566 Widget_Data *wd = elm_widget_data_get(data);
567 Evas_Coord minw = -1, minh = -1, maxh = -1;
568 Evas_Coord resw, resh, minminw;
570 wd->deferred_recalc_job = NULL;
571 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
573 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
574 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
576 edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
577 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
578 evas_object_size_hint_min_set(data, minminw, minh);
579 if (wd->single_line) maxh = minh;
580 evas_object_size_hint_max_set(data, -1, maxh);
581 if (wd->deferred_cur)
582 elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
586 _sizing_eval(Evas_Object *obj)
588 Widget_Data *wd = elm_widget_data_get(obj);
589 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
590 Evas_Coord resw, resh;
592 if ((wd->linewrap) || (wd->char_linewrap))
594 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
595 if ((resw == wd->lastw) && (!wd->changed)) return;
596 wd->changed = EINA_FALSE;
598 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
599 wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
603 evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
604 edje_object_size_min_calc(wd->ent, &minw, &minh);
605 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
606 evas_object_size_hint_min_set(obj, minw, minh);
607 if (wd->single_line) maxh = minh;
608 evas_object_size_hint_max_set(obj, maxw, maxh);
610 if (wd->ellipsis && wd->single_line)
612 if (_is_width_over(obj))
613 _ellipsis_entry_to_width(obj);
614 else if (wd->ellipsis_threshold > 1 && _entry_length_get(obj) < wd->ellipsis_threshold)
615 _reverse_ellipsis_entry(obj);
621 _check_enable_returnkey(Evas_Object *obj)
623 Widget_Data *wd = elm_widget_data_get(obj);
626 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
629 if (!wd->autoreturnkey) return;
631 if (_entry_length_get(obj) == 0)
633 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
637 ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
642 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
644 Widget_Data *wd = elm_widget_data_get(obj);
645 Evas_Object *top = elm_widget_top_get(obj);
648 if (!wd->editable) return;
649 if (elm_widget_focus_get(obj))
651 evas_object_focus_set(wd->ent, EINA_TRUE);
652 edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
653 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
654 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
655 _check_enable_returnkey(obj);
656 wd->mgf_type = _ENTRY_MAGNIFIER_FILLWIDTH;
657 _magnifier_create(obj);
661 edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
662 evas_object_focus_set(wd->ent, EINA_FALSE);
663 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
664 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
666 if ((wd->api) && (wd->api->obj_hidemenu))
668 wd->api->obj_hidemenu(obj);
674 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
676 Widget_Data *wd = elm_widget_data_get(obj);
678 edje_object_signal_emit(wd->ent, emission, source);
682 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
684 Widget_Data *wd = elm_widget_data_get(obj);
686 edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
690 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
692 Widget_Data *wd = elm_widget_data_get(obj);
693 edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
698 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
700 Widget_Data *wd = elm_widget_data_get(obj);
701 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
705 _hoversel_position(Evas_Object *obj)
707 Widget_Data *wd = elm_widget_data_get(obj);
708 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
710 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
711 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
713 evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
724 evas_object_move(wd->hoversel, x + cx, y + cy);
725 evas_object_resize(wd->hoversel, cw, ch);
729 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
731 Widget_Data *wd = elm_widget_data_get(data);
733 if (wd->hoversel) _hoversel_position(data);
737 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
739 Widget_Data *wd = elm_widget_data_get(data);
741 if ((wd->linewrap) || (wd->char_linewrap))
745 if (wd->hoversel) _hoversel_position(data);
746 // Evas_Coord ww, hh;
747 // evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
751 _hover_del(void *data)
753 Widget_Data *wd = elm_widget_data_get(data);
758 evas_object_del(wd->hoversel);
761 wd->hovdeljob = NULL;
765 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
767 Widget_Data *wd = elm_widget_data_get(data);
769 if (wd->hoversel) evas_object_hide(wd->hoversel);
773 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
775 elm_widget_scroll_freeze_pop(data);
776 if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
777 wd->hovdeljob = ecore_job_add(_hover_del, data);
781 _selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
783 Widget_Data *wd = elm_widget_data_get(data);
785 wd->selmode = EINA_TRUE;
786 edje_object_part_text_select_none(wd->ent, "elm.text");
787 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
788 edje_object_part_text_select_all(wd->ent, "elm.text");
789 elm_object_scroll_freeze_pop(data);
793 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
795 Widget_Data *wd = elm_widget_data_get(data);
797 wd->selmode = EINA_TRUE;
798 edje_object_part_text_select_none(wd->ent, "elm.text");
800 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
801 edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
802 elm_object_scroll_freeze_pop(data);
806 _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
808 Widget_Data *wd = elm_widget_data_get(data);
810 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
811 if (wd->sel_notify_handler)
813 #ifdef HAVE_ELEMENTARY_X
814 wd->selection_asked = EINA_TRUE;
815 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
821 _store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
823 Widget_Data *wd = elm_widget_data_get(obj);
827 sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
828 elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
829 if (seltype == ELM_SEL_CLIPBOARD)
830 eina_stringshare_replace(&wd->cut_sel, sel);
834 _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
836 Widget_Data *wd = elm_widget_data_get(data);
839 wd->selmode = EINA_FALSE;
840 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
841 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
842 elm_widget_scroll_hold_pop(data);
843 _store_selection(ELM_SEL_CLIPBOARD, data);
844 edje_object_part_text_insert(wd->ent, "elm.text", "");
845 edje_object_part_text_select_none(wd->ent, "elm.text");
849 _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
851 Widget_Data *wd = elm_widget_data_get(data);
853 //wd->selmode = EINA_FALSE;
854 //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
855 //edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
856 elm_widget_scroll_hold_pop(data);
857 _store_selection(ELM_SEL_CLIPBOARD, data);
858 //edje_object_part_text_select_none(wd->ent, "elm.text");
862 _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
864 Widget_Data *wd = elm_widget_data_get(data);
866 wd->selmode = EINA_FALSE;
867 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
868 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
869 elm_widget_scroll_hold_pop(data);
870 edje_object_part_text_select_none(wd->ent, "elm.text");
874 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
876 Widget_Data *wd = elm_widget_data_get(data);
880 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
881 cnpwidgetdata = data;
882 elm_cbhm_helper_init(obj);
883 if (elm_entry_cnp_textonly_get(obj))
884 elm_cbhm_send_raw_data("show0");
886 elm_cbhm_send_raw_data("show1");
892 _cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
894 Widget_Data *wd = elm_widget_data_get(data);
896 cnpwidgetdata = data;
902 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
904 Elm_Entry_Context_Menu_Item *it = data;
905 Evas_Object *obj2 = it->obj;
906 if (it->func) it->func(it->data, obj2, NULL);
910 _long_pressed(void *data)
912 Widget_Data *wd = elm_widget_data_get(data);
915 const Elm_Entry_Context_Menu_Item *it;
917 if ((wd->api) && (wd->api->obj_longpress))
919 wd->api->obj_longpress(data);
921 else if (wd->context_menu)
923 const char *context_menu_orientation;
925 if (wd->hoversel) evas_object_del(wd->hoversel);
926 else elm_widget_scroll_freeze_push(data);
927 wd->hoversel = elm_hoversel_add(data);
928 context_menu_orientation = edje_object_data_get
929 (wd->ent, "context_menu_orientation");
930 if ((context_menu_orientation) &&
931 (!strcmp(context_menu_orientation, "horizontal")))
932 elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
933 elm_object_style_set(wd->hoversel, "entry");
934 elm_widget_sub_object_add(data, wd->hoversel);
935 elm_hoversel_label_set(wd->hoversel, "Text");
936 top = elm_widget_top_get(data);
937 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
938 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
942 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
944 if (1) // need way to detect if someone has a selection
947 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
951 if ((!wd->password) && (wd->editable))
952 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
953 _clipboard_menu, data);
960 if (wd->have_selection)
962 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
965 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
968 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
972 elm_hoversel_item_add(wd->hoversel, "More", NULL, ELM_ICON_NONE,
973 _clipboard_menu, data);
977 EINA_LIST_FOREACH(wd->items, l, it)
979 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
980 it->icon_type, _item_clicked, it);
984 _hoversel_position(data);
985 evas_object_show(wd->hoversel);
986 elm_hoversel_hover_begin(wd->hoversel);
988 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
989 edje_object_part_text_select_abort(wd->ent, "elm.text");
992 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
996 _magnifier_hide(void *data)
998 Widget_Data *wd = elm_widget_data_get(data);
1001 evas_object_hide(wd->mgf_bg);
1002 evas_object_hide(wd->mgf_clip);
1006 _magnifier_show(void *data)
1008 Widget_Data *wd = elm_widget_data_get(data);
1011 evas_object_show(wd->mgf_bg);
1012 evas_object_show(wd->mgf_clip);
1016 _magnifier_move(void *data)
1018 Widget_Data *wd = elm_widget_data_get(data);
1021 Evas_Coord x, y, w, h, fs;
1022 Evas_Coord cx, cy, cw, ch, ox, oy;
1024 evas_object_geometry_get(data, &x, &y, &w, &h);
1025 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1028 fs = elm_finger_size_get();
1030 if ((cy + y) - wd->mgf_height - fs < 0)
1031 oy = -1 * ((cy + y) - wd->mgf_height - fs);
1033 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1034 evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height - fs + oy);
1035 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1036 evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height - fs + oy);
1040 evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 - fs + oy);
1044 _magnifier_create(void *data)
1046 Widget_Data *wd = elm_widget_data_get(data);
1047 Evas_Coord x, y, w, h;
1048 const char* key_data = NULL;
1054 evas_object_image_source_unset(wd->mgf_proxy);
1055 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
1056 evas_object_hide(wd->mgf_proxy);
1057 evas_object_clip_unset(wd->mgf_proxy);
1058 evas_object_del(wd->mgf_proxy);
1060 if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
1061 if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
1063 evas_object_geometry_get(data, &x, &y, &w, &h);
1064 wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
1066 if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
1067 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
1068 else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1069 _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
1073 wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
1074 evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
1075 edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
1077 key_data = edje_object_data_get(wd->mgf_bg, "height");
1078 if (key_data) wd->mgf_height = atoi(key_data);
1079 key_data = edje_object_data_get(wd->mgf_bg, "scale");
1080 if (key_data) wd->mgf_scale = atof(key_data);
1082 if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
1083 evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
1085 wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
1086 evas_object_image_source_set(wd->mgf_proxy, data);
1087 evas_object_resize(wd->mgf_proxy, w * wd->mgf_scale, h * wd->mgf_scale);
1088 evas_object_image_fill_set(wd->mgf_proxy, 0, 0, w * wd->mgf_scale, h * wd->mgf_scale);
1089 evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
1090 evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
1091 evas_object_show(wd->mgf_proxy);
1092 evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
1094 evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
1095 evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
1099 _long_press(void *data)
1101 Widget_Data *wd = elm_widget_data_get(data);
1102 if (!wd) return ECORE_CALLBACK_CANCEL;
1104 wd->long_pressed = EINA_TRUE;
1106 if (wd->longpress_timer)
1108 ecore_timer_del(wd->longpress_timer);
1109 wd->longpress_timer = NULL;
1112 _cancel(data, NULL, NULL);
1114 _magnifier_create(data);
1115 _magnifier_move(data);
1116 _magnifier_show(data);
1117 elm_object_scroll_freeze_push(data);
1119 wd->longpress_timer = NULL;
1120 return ECORE_CALLBACK_CANCEL;
1124 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1126 Widget_Data *wd = elm_widget_data_get(data);
1127 Evas_Event_Mouse_Down *ev = event_info;
1129 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1130 if (ev->button != 1) return;
1131 // if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1132 if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
1133 wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1134 wd->downx = ev->canvas.x;
1135 wd->downy = ev->canvas.y;
1137 wd->long_pressed = EINA_FALSE;
1141 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1143 Widget_Data *wd = elm_widget_data_get(data);
1144 Evas_Event_Mouse_Up *ev = event_info;
1146 if (ev->button != 1) return;
1148 if (!wd->double_clicked)
1150 if ((wd->api) && (wd->api->obj_mouseup))
1152 wd->api->obj_mouseup(data);
1155 if (wd->longpress_timer)
1157 ecore_timer_del(wd->longpress_timer);
1158 wd->longpress_timer = NULL;
1161 _magnifier_hide(data);
1162 elm_object_scroll_freeze_pop(data);
1164 if (wd->long_pressed)
1166 _long_pressed(data);
1171 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1173 Widget_Data *wd = elm_widget_data_get(data);
1174 Evas_Event_Mouse_Move *ev = event_info;
1178 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1180 if (wd->longpress_timer)
1182 ecore_timer_del(wd->longpress_timer);
1183 wd->longpress_timer = NULL;
1186 else if (wd->longpress_timer)
1190 dx = wd->downx - ev->cur.canvas.x;
1192 dy = wd->downy - ev->cur.canvas.y;
1195 ((_elm_config->finger_size / 2) *
1196 (_elm_config->finger_size / 2)))
1198 ecore_timer_del(wd->longpress_timer);
1199 wd->longpress_timer = NULL;
1203 else if (wd->longpress_timer)
1207 dx = wd->downx - ev->cur.canvas.x;
1209 dy = wd->downy - ev->cur.canvas.y;
1212 ((_elm_config->finger_size / 2) *
1213 (_elm_config->finger_size / 2)))
1215 ecore_timer_del(wd->longpress_timer);
1216 wd->longpress_timer = NULL;
1220 if (ev->buttons != 1) return;
1222 if (wd->long_pressed)
1224 _magnifier_show(data);
1225 _magnifier_move(data);
1230 _getbase(Evas_Object *obj)
1232 Widget_Data *wd = elm_widget_data_get(obj);
1233 if (!wd) return "base";
1238 if (wd->show_last_character) return "custom-password";
1239 else return "base-password";
1243 if (wd->single_line) return "base-single";
1246 if (wd->linewrap) return "base";
1247 else if (wd->char_linewrap) return "base-charwrap";
1248 else return "base-nowrap";
1256 if (wd->show_last_character) return "custom-password";
1257 else return "base-password";
1261 if (wd->single_line) return "base-single-noedit";
1264 if (wd->linewrap) return "base-noedit";
1265 else if (wd->char_linewrap) return "base-noedit-charwrap";
1266 else return "base-nowrap-noedit";
1274 _entry_length_get(Evas_Object *obj)
1277 const char *str = elm_entry_entry_get(obj);
1280 char *plain_str = _elm_util_mkup_to_text(str);
1281 if (!plain_str) return 0;
1283 len = strlen(plain_str);
1290 _matchlist_show(void *data)
1292 Widget_Data *wd = elm_widget_data_get(data);
1293 const char *text = NULL;
1295 char *str_list = NULL, *str_result = NULL;
1296 char *str_mkup = NULL, *str_front = NULL, *str_mid = NULL;
1299 Eina_Bool textfound = EINA_FALSE;
1302 if (elm_widget_disabled_get(data)) return;
1304 wd->matchlist_job = NULL;
1306 if (wd->matchlist_list_clicked)
1308 evas_object_hide(wd->hover);
1309 wd->matchlist_list_clicked = EINA_FALSE;
1312 text = elm_entry_entry_get(data);
1315 textlen = strlen(text);
1317 if (textlen < wd->matchlist_threshold)
1319 evas_object_hide(wd->hover);
1323 evas_object_hide(wd->hover);
1327 elm_list_clear(wd->list);
1328 EINA_LIST_FOREACH(wd->match_list, l, str_list)
1330 if (wd->matchlist_case_sensitive)
1331 str_result = strstr(str_list, text);
1333 str_result = strcasestr(str_list, text);
1337 str_mkup = malloc(strlen(str_list) + 16);
1339 textlen = strlen(str_list) - strlen(str_result);
1340 str_front = malloc(textlen + 1);
1341 memset(str_front, 0, textlen + 1);
1342 strncpy(str_front, str_list, textlen);
1344 textlen = strlen(text);
1345 str_mid = malloc(textlen + 1);
1346 memset(str_mid, 0, textlen + 1);
1347 strncpy(str_mid, str_list + strlen(str_front), textlen);
1349 sprintf(str_mkup, "%s<match>%s</match>%s", str_front, str_mid, str_result + strlen(text));
1351 elm_list_item_append(wd->list, str_mkup, NULL, NULL, NULL, NULL);
1353 if (str_mkup) free(str_mkup);
1354 if (str_front) free(str_front);
1355 if (str_mid) free(str_mid);
1357 textfound=EINA_TRUE;
1366 elm_list_go(wd->list);
1367 evas_object_show(wd->hover);
1368 evas_object_raise(wd->hover);
1372 static void _matchlist_list_clicked( void *data, Evas_Object *obj, void *event_info )
1374 Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
1375 Widget_Data *wd = elm_widget_data_get(data);
1376 if ((it == NULL) || (wd == NULL))
1379 const char *text = elm_list_item_label_get(it);
1380 evas_object_smart_callback_call((Evas_Object *)data, "selected", (void *)text);
1385 elm_entry_entry_set(data, elm_entry_markup_to_utf8(text));
1386 elm_entry_cursor_end_set(data);
1387 wd->matchlist_list_clicked = EINA_TRUE;
1389 evas_object_smart_callback_call(data, SIG_MATCHLIST_CLICKED, elm_entry_markup_to_utf8(text));
1392 elm_widget_focus_set(data, EINA_TRUE);
1396 elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive)
1398 Widget_Data *wd = elm_widget_data_get(obj);
1403 Evas_Coord max_w = 9999, max_h = 9999;
1404 const char* key_data = NULL;
1406 wd->matchlist_threshold = 1;
1407 wd->hover = elm_hover_add(elm_widget_parent_get(obj));
1408 elm_hover_parent_set(wd->hover, elm_widget_parent_get(obj));
1409 elm_hover_target_set(wd->hover, obj);
1410 elm_object_style_set(wd->hover, "matchlist");
1412 wd->layout = elm_layout_add(wd->hover);
1413 elm_layout_theme_set(wd->layout, "entry", "matchlist", "default");
1414 wd->list = elm_list_add(wd->layout);
1415 evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, 0.0);
1416 evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1417 elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
1418 elm_object_style_set(wd->list, "matchlist");
1420 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_width");
1421 if (key_data) max_w = atoi(key_data);
1422 key_data = edje_object_data_get(elm_layout_edje_get(wd->layout), "max_height");
1423 if (key_data) max_h = atoi(key_data);
1425 elm_list_go(wd->list);
1426 evas_object_size_hint_max_set(wd->list, max_w, max_h);
1427 evas_object_smart_callback_add(wd->list, "selected", _matchlist_list_clicked, obj);
1428 elm_layout_content_set(wd->layout, "elm.swallow.content", wd->list);
1429 elm_hover_content_set(wd->hover, "bottom", wd->layout);
1431 wd->match_list = match_list;
1436 evas_object_del(wd->hover);
1438 wd->match_list = NULL;
1441 wd->matchlist_case_sensitive = case_sensitive;
1446 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1448 Widget_Data *wd = elm_widget_data_get(data);
1450 wd->changed = EINA_TRUE;
1452 if (wd->text) eina_stringshare_del(wd->text);
1454 _check_enable_returnkey(data);
1455 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
1456 if (wd->delay_write)
1458 ecore_timer_del(wd->delay_write);
1459 wd->delay_write = NULL;
1462 if ((wd->single_line) && (wd->match_list))
1464 if (wd->matchlist_job) ecore_job_del(wd->matchlist_job);
1465 wd->matchlist_job = ecore_job_add(_matchlist_show, data);
1467 if ((!wd->autosave) || (!wd->file)) return;
1468 wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
1472 _signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1474 Widget_Data *wd = elm_widget_data_get(data);
1475 elm_object_scroll_freeze_push(data);
1477 if ((wd->api) && (wd->api->obj_hidemenu))
1479 wd->api->obj_hidemenu(data);
1482 _magnifier_create(data);
1483 _magnifier_move(data);
1484 _magnifier_show(data);
1488 _signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1490 Widget_Data *wd = elm_widget_data_get(data);
1491 elm_object_scroll_freeze_pop(data);
1493 if (wd->have_selection)
1495 _magnifier_hide(data);
1496 _long_pressed(data);
1501 _signal_handler_moving(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1503 _magnifier_move(data);
1504 _magnifier_show(data);
1508 _signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1510 _magnifier_hide(data);
1511 _long_pressed(data);
1515 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1517 Widget_Data *wd = elm_widget_data_get(data);
1521 EINA_LIST_FOREACH(entries, l, entry)
1523 if (entry != data) elm_entry_select_none(entry);
1525 wd->have_selection = EINA_TRUE;
1526 wd->selmode = EINA_TRUE;
1527 evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
1528 #ifdef HAVE_ELEMENTARY_X
1529 if (wd->sel_notify_handler)
1531 const char *txt = elm_entry_selection_get(data);
1534 top = elm_widget_top_get(data);
1535 if ((top) && (elm_win_xwindow_get(top)))
1536 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
1542 _signal_magnifier_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1544 Evas_Coord cx, cy, cw, ch;
1545 Widget_Data *wd = elm_widget_data_get(data);
1548 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1549 if (!wd->deferred_recalc_job)
1550 elm_widget_show_region_set(data, cx, cy, cw, ch);
1553 wd->deferred_cur = EINA_TRUE;
1557 wd->ch = ch + elm_finger_size_get();
1562 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1564 Evas_Coord cx, cy, cw, ch;
1565 Widget_Data *wd = elm_widget_data_get(data);
1567 wd->have_selection = EINA_TRUE;
1568 wd->selmode = EINA_TRUE;
1569 evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
1570 elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
1571 elm_entry_selection_get(data));
1573 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
1574 if (!wd->deferred_recalc_job)
1575 elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
1578 wd->deferred_cur = EINA_TRUE;
1582 wd->ch = ch + elm_finger_size_get();
1587 _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1589 Widget_Data *wd = elm_widget_data_get(data);
1591 if (!wd->have_selection) return;
1592 wd->have_selection = EINA_FALSE;
1593 wd->selmode = EINA_FALSE;
1594 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
1595 if (wd->sel_notify_handler)
1599 #ifdef HAVE_ELEMENTARY_X
1602 top = elm_widget_top_get(data);
1603 if ((top) && (elm_win_xwindow_get(top)))
1604 elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
1607 eina_stringshare_del(wd->cut_sel);
1612 #ifdef HAVE_ELEMENTARY_X
1615 top = elm_widget_top_get(data);
1616 if ((top) && (elm_win_xwindow_get(top)))
1617 elm_selection_clear(ELM_SEL_PRIMARY, data);
1622 if ((wd->api) && (wd->api->obj_hidemenu))
1624 wd->api->obj_hidemenu(data);
1629 _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1631 Widget_Data *wd = elm_widget_data_get(data);
1633 evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
1634 if (wd->sel_notify_handler)
1636 #ifdef HAVE_ELEMENTARY_X
1639 top = elm_widget_top_get(data);
1640 if ((top) && (elm_win_xwindow_get(top)))
1642 wd->selection_asked = EINA_TRUE;
1643 elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
1651 _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1653 Widget_Data *wd = elm_widget_data_get(data);
1655 evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
1656 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1657 elm_entry_selection_get(data));
1661 _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1663 Widget_Data *wd = elm_widget_data_get(data);
1665 evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
1666 elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
1667 elm_entry_selection_get(data));
1668 edje_object_part_text_insert(wd->ent, "elm.text", "");
1669 wd->changed = EINA_TRUE;
1674 _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1676 Widget_Data *wd = elm_widget_data_get(data);
1677 Evas_Coord cx, cy, cw, ch;
1679 evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
1680 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
1681 &cx, &cy, &cw, &ch);
1682 if (!wd->deferred_recalc_job)
1683 elm_widget_show_region_set(data, cx, cy, cw, ch);
1686 wd->deferred_cur = EINA_TRUE;
1695 _signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1697 Widget_Data *wd = elm_widget_data_get(data);
1702 _signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
1704 Widget_Data *wd = elm_widget_data_get(data);
1705 Elm_Entry_Anchor_Info ei;
1706 char *buf2, *p, *p2, *n;
1708 p = strrchr(emission, ',');
1711 const Eina_List *geoms;
1715 while (p2 >= emission)
1717 if (*p2 == ',') break;
1721 buf2 = alloca(5 + p - p2);
1722 strncpy(buf2, p2, p - p2);
1725 ei.button = atoi(buf2);
1726 ei.x = ei.y = ei.w = ei.h = 0;
1728 edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
1731 Evas_Textblock_Rectangle *r;
1733 Evas_Coord px, py, x, y;
1735 evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
1736 evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
1737 EINA_LIST_FOREACH(geoms, l, r)
1739 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
1740 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
1751 evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
1756 _signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1758 Widget_Data *wd = elm_widget_data_get(data);
1763 _signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1765 Widget_Data *wd = elm_widget_data_get(data);
1770 _signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1772 Widget_Data *wd = elm_widget_data_get(data);
1777 _signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1779 Widget_Data *wd = elm_widget_data_get(data);
1781 evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
1785 _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1787 Widget_Data *wd = elm_widget_data_get(data);
1789 wd->double_clicked = EINA_FALSE;
1790 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1792 if ((wd->api) && (wd->api->obj_hidemenu))
1794 wd->api->obj_hidemenu(data);
1799 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1801 Widget_Data *wd = elm_widget_data_get(data);
1803 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1807 _signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1809 Widget_Data *wd = elm_widget_data_get(data);
1811 wd->double_clicked = EINA_TRUE;
1812 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1815 #ifdef HAVE_ELEMENTARY_X
1817 _event_selection_notify(void *data, int type __UNUSED__, void *event)
1819 Widget_Data *wd = elm_widget_data_get(data);
1820 Ecore_X_Event_Selection_Notify *ev = event;
1821 if (!wd) return ECORE_CALLBACK_PASS_ON;
1822 if ((!wd->selection_asked) && (!wd->drag_selection_asked))
1823 return ECORE_CALLBACK_PASS_ON;
1825 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1826 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1828 Ecore_X_Selection_Data_Text *text_data;
1830 text_data = ev->data;
1831 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1833 if (text_data->text)
1835 char *txt = _elm_util_text_to_mkup(text_data->text);
1839 elm_entry_entry_insert(data, txt);
1844 wd->selection_asked = EINA_FALSE;
1846 else if (ev->selection == ECORE_X_SELECTION_XDND)
1848 Ecore_X_Selection_Data_Text *text_data;
1850 text_data = ev->data;
1851 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
1853 if (text_data->text)
1855 char *txt = _elm_util_text_to_mkup(text_data->text);
1859 /* Massive FIXME: this should be at the drag point */
1860 elm_entry_entry_insert(data, txt);
1865 wd->drag_selection_asked = EINA_FALSE;
1867 ecore_x_dnd_send_finished();
1870 return ECORE_CALLBACK_PASS_ON;
1874 _event_selection_clear(void *data, int type __UNUSED__, void *event)
1877 Widget_Data *wd = elm_widget_data_get(data);
1878 Ecore_X_Event_Selection_Clear *ev = event;
1879 if (!wd) return ECORE_CALLBACK_PASS_ON;
1880 if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
1881 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
1882 (ev->selection == ECORE_X_SELECTION_PRIMARY))
1884 elm_entry_select_none(data);
1889 Evas_Object *top = elm_widget_top_get(data);
1890 Ecore_X_Event_Selection_Clear *ev = event;
1893 return ECORE_CALLBACK_PASS_ON;
1895 if (ev->selection != ECORE_X_SELECTION_SECONDARY)
1897 return ECORE_CALLBACK_PASS_ON;
1900 if (cnpwidgetdata == data)
1902 elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
1906 return ECORE_CALLBACK_PASS_ON;
1911 _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
1916 wd = elm_widget_data_get(obj);
1918 if (!wd) return EINA_FALSE;
1919 printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
1921 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1922 EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
1923 rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
1924 EDJE_CURSOR_MAIN,drop->x,drop->y);
1925 if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
1926 elm_entry_entry_insert(obj, drop->data);
1927 edje_object_part_text_cursor_copy(wd->ent, "elm.text",
1928 EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
1934 static Evas_Object *
1935 _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
1937 Widget_Data *wd = elm_widget_data_get(data);
1940 Elm_Entry_Item_Provider *ip;
1942 EINA_LIST_FOREACH(wd->item_providers, l, ip)
1944 o = ip->func(ip->data, data, item);
1947 if (!strncmp(item, "file://", 7))
1949 const char *fname = item + 7;
1951 o = evas_object_image_filled_add(evas_object_evas_get(data));
1952 evas_object_image_file_set(o, fname, NULL);
1953 if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
1955 evas_object_show(o);
1960 o = edje_object_add(evas_object_evas_get(data));
1961 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1965 o = edje_object_add(evas_object_evas_get(data));
1966 if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
1967 _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
1972 _get_value_in_key_string(const char *oldstring, char *key, char **value)
1974 char *curlocater, *starttag, *endtag;
1975 int firstindex = 0, foundflag = -1;
1977 curlocater = strstr(oldstring, key);
1980 starttag = curlocater;
1981 endtag = curlocater + strlen(key);
1982 if (endtag == NULL || *endtag != '=')
1988 firstindex = abs(oldstring - curlocater);
1989 firstindex += strlen(key)+1; // strlen("key") + strlen("=")
1990 *value = (char*)(oldstring + firstindex);
1992 while (oldstring != starttag)
1994 if (*starttag == '>')
1999 if (*starttag == '<')
2003 if (starttag == NULL) break;
2006 while (NULL != endtag)
2017 if (endtag == NULL) break;
2020 if (foundflag != 0 && *starttag == '<' && *endtag == '>')
2030 if (foundflag == 1) return 0;
2036 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int deleteflag)
2038 const char *srcstring = NULL;
2039 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
2040 char *curlocater, *replocater;
2041 char *starttag, *endtag;
2042 int tagtxtlen = 0, insertflag = 0;
2044 srcstring = eina_strbuf_string_get(srcbuf);
2045 curlocater = strstr(srcstring, key);
2047 if (!curlocater || !srcstring)
2055 starttag = strchr(srcstring, '<');
2056 endtag = strchr(srcstring, '>');
2057 tagtxtlen = endtag - starttag;
2058 if (tagtxtlen <= 0) tagtxtlen = 0;
2059 if (starttag < curlocater && curlocater < endtag) break;
2060 if (endtag != NULL && endtag+1 != NULL)
2061 srcstring = endtag+1;
2064 } while (strlen(srcstring) > 1);
2066 if (starttag && endtag && tagtxtlen > strlen(key))
2068 repbuf = eina_strbuf_new();
2069 diffbuf = eina_strbuf_new();
2070 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
2071 srcstring = eina_strbuf_string_get(repbuf);
2072 curlocater = strstr(srcstring, key);
2074 if (curlocater != NULL)
2076 replocater = curlocater + strlen(key) + 1;
2078 while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
2081 if (replocater-curlocater > strlen(key)+1)
2083 eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
2092 eina_strbuf_reset(repbuf);
2100 if (repbuf == NULL) repbuf = eina_strbuf_new();
2101 if (diffbuf == NULL) diffbuf = eina_strbuf_new();
2105 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
2106 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
2112 eina_strbuf_prepend(diffbuf, "<");
2113 eina_strbuf_append(diffbuf, ">");
2114 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
2118 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
2119 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
2123 if (repbuf) eina_strbuf_free(repbuf);
2124 if (diffbuf) eina_strbuf_free(diffbuf);
2130 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
2132 Eina_Strbuf *sharebuf = NULL;
2134 sharebuf = eina_strbuf_new();
2135 eina_strbuf_append(sharebuf, *srcstring);
2136 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
2137 eina_stringshare_del(*srcstring);
2138 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
2139 eina_strbuf_free(sharebuf);
2145 _is_width_over(Evas_Object *obj)
2147 Evas_Coord x, y, w, h;
2148 Evas_Coord vx, vy, vw, vh;
2149 Widget_Data *wd = elm_widget_data_get(obj);
2153 edje_object_part_geometry_get(wd->ent,"elm.text",&x,&y,&w,&h);
2155 evas_object_geometry_get (obj, &vx,&vy,&vw,&vh);
2157 if (x >= 0 && y >= 0)
2160 if (4 < wd->wrap_w && w > wd->wrap_w)
2167 _reverse_ellipsis_entry(Evas_Object *obj)
2169 Widget_Data *wd = elm_widget_data_get(obj);
2170 int cur_fontsize = 0;
2171 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
2172 char *kvalue = NULL;
2173 const char *minfont, *deffont, *maxfont;
2174 const char *ellipsis_string = "...";
2175 int minfontsize, maxfontsize, minshowcount;
2177 minshowcount = strlen(ellipsis_string) + 1;
2178 minfont = edje_object_data_get(wd->ent, "min_font_size");
2179 if (minfont) minfontsize = atoi(minfont);
2180 else minfontsize = 1;
2181 maxfont = edje_object_data_get(wd->ent, "max_font_size");
2182 if (maxfont) maxfontsize = atoi(maxfont);
2183 else maxfontsize = 1;
2184 deffont = edje_object_data_get(wd->ent, "default_font_size");
2185 if (deffont) cur_fontsize = atoi(deffont);
2186 else cur_fontsize = 1;
2187 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
2188 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
2190 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
2192 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
2195 txtbuf = eina_strbuf_new();
2196 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
2198 if (cur_fontsize >= atoi(deffont))
2200 if (txtbuf) eina_strbuf_free(txtbuf);
2204 if (_is_width_over(obj) != 1)
2206 int rev_fontsize = cur_fontsize;
2210 if (rev_fontsize > atoi(deffont))
2213 if (fontbuf != NULL)
2215 eina_strbuf_free(fontbuf);
2218 fontbuf = eina_strbuf_new();
2219 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
2220 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
2221 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2223 eina_strbuf_free(fontbuf);
2225 } while (_is_width_over(obj) != 1);
2227 while (_is_width_over(obj))
2230 if (rev_fontsize < atoi(deffont))
2233 if (fontbuf != NULL)
2235 eina_strbuf_free(fontbuf);
2238 fontbuf = eina_strbuf_new();
2239 eina_strbuf_append_printf(fontbuf, "%d", rev_fontsize);
2240 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
2241 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2242 eina_strbuf_free(fontbuf);
2247 if (txtbuf) eina_strbuf_free(txtbuf);
2253 _ellipsis_entry_to_width(Evas_Object *obj)
2255 Widget_Data *wd = elm_widget_data_get(obj);
2256 int cur_fontsize = 0, len, jumpcount;
2257 Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
2258 char *kvalue = NULL;
2259 const char *minfont, *deffont, *maxfont;
2260 const char *ellipsis_string = "...";
2261 int minfontsize, maxfontsize, minshowcount;
2262 int i, tagend, cur_len;
2265 minshowcount = strlen(ellipsis_string) + 1;
2266 minfont = edje_object_data_get(wd->ent, "min_font_size");
2267 if (minfont) minfontsize = atoi(minfont);
2268 else minfontsize = 1;
2269 maxfont = edje_object_data_get(wd->ent, "max_font_size");
2270 if (maxfont) maxfontsize = atoi(maxfont);
2271 else maxfontsize = 1;
2272 deffont = edje_object_data_get(wd->ent, "default_font_size");
2273 if (deffont) cur_fontsize = atoi(deffont);
2274 else cur_fontsize = 1;
2275 if (minfontsize == maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
2276 if (strlen(edje_object_part_text_get(wd->ent, "elm.text")) <= 0) return;
2278 if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
2280 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
2283 txtbuf = eina_strbuf_new();
2284 eina_strbuf_append(txtbuf, edje_object_part_text_get(wd->ent, "elm.text"));
2286 while (_is_width_over(obj))
2288 if (wd->ellipsis_threshold == 0)
2289 wd->ellipsis_threshold = _entry_length_get(obj);
2290 if (cur_fontsize > minfontsize)
2293 if (fontbuf != NULL)
2295 eina_strbuf_free(fontbuf);
2298 fontbuf = eina_strbuf_new();
2299 eina_strbuf_append_printf(fontbuf, "%d", cur_fontsize);
2300 _strbuf_key_value_replace(txtbuf, "font_size", eina_strbuf_string_get(fontbuf), 0);
2301 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2302 eina_strbuf_free(fontbuf);
2304 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2308 len = _entry_length_get(obj);
2309 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2310 cur_len = strlen(cur_str);
2312 for (i = 0; i < len; i++)
2314 if(cur_str[i] == '>' && cur_str[i+1] != '\0' &&
2315 cur_str[i+1] != '<')
2322 while (jumpcount < len-strlen(ellipsis_string))
2324 cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2328 eina_strbuf_free(txtbuf);
2331 txtbuf = eina_strbuf_new();
2332 eina_strbuf_append_n(txtbuf, cur_str, tagend+1);
2333 eina_strbuf_append(txtbuf, ellipsis_string);
2334 eina_strbuf_append(txtbuf, cur_str+tagend+jumpcount+1);
2335 edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
2336 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
2338 if (_is_width_over(obj))
2346 if (txtbuf) eina_strbuf_free(txtbuf);
2351 static Eina_Bool *_textinput_control_function(void *data,void *input_data)
2353 /* calculate character count */
2354 Evas_Object *entry = (Evas_Object *)data;
2355 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
2358 size_t insert_text_len=0;
2359 char *text = (char*)edje_object_part_text_get(wd->ent, "elm.text");
2361 size_t remain_bytes;
2364 byte_len = strlen(text); /* no of bytes */
2365 remain_bytes = wd->max_no_of_bytes - byte_len;
2366 sprintf(buf,"%d",remain_bytes);
2367 //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
2370 insert_text = (char *)input_data;
2371 insert_text_len = strlen(insert_text);
2372 if (remain_bytes < insert_text_len)
2374 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2377 if (byte_len >= wd->max_no_of_bytes)
2379 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
2389 _text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
2391 Widget_Data *wd = elm_widget_data_get(data);
2393 Elm_Entry_Text_Filter *tf;
2395 if (type == EDJE_TEXT_FILTER_FORMAT)
2398 EINA_LIST_FOREACH(wd->text_filters, l, tf)
2400 tf->func(tf->data, data, text);
2407 * This adds an entry to @p parent object.
2409 * @param parent The parent object
2410 * @return The new object or NULL if it cannot be created
2415 elm_entry_add(Evas_Object *parent)
2417 Evas_Object *obj, *top;
2421 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
2423 wd = ELM_NEW(Widget_Data);
2424 e = evas_object_evas_get(parent);
2425 if (!e) return NULL;
2426 wd->bgcolor = EINA_FALSE;
2427 wd->bg = evas_object_rectangle_add(e);
2428 evas_object_color_set(wd->bg, 0, 0, 0, 0);
2429 obj = elm_widget_add(e);
2430 ELM_SET_WIDTYPE(widtype, "entry");
2431 elm_widget_type_set(obj, "entry");
2432 elm_widget_sub_object_add(parent, obj);
2433 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2434 elm_widget_data_set(obj, wd);
2435 elm_widget_del_hook_set(obj, _del_hook);
2436 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2437 elm_widget_theme_hook_set(obj, _theme_hook);
2438 elm_widget_disable_hook_set(obj, _disable_hook);
2439 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2440 elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
2441 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
2442 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
2443 elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
2444 elm_widget_can_focus_set(obj, EINA_TRUE);
2445 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2447 wd->linewrap = EINA_TRUE;
2448 wd->ellipsis = EINA_FALSE;
2449 wd->char_linewrap= EINA_FALSE;
2450 wd->editable = EINA_TRUE;
2451 wd->disabled = EINA_FALSE;
2452 wd->context_menu = EINA_TRUE;
2453 wd->autosave = EINA_TRUE;
2454 wd->textonly = EINA_FALSE;
2455 wd->autoperiod = EINA_TRUE;
2457 wd->ellipsis_threshold = 0;
2459 wd->ent = edje_object_add(e);
2460 edje_object_item_provider_set(wd->ent, _get_item, obj);
2461 edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
2462 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
2463 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
2464 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
2466 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
2468 evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
2471 _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
2472 edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
2473 _signal_entry_changed, obj);
2474 edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
2475 _signal_handler_move_start, obj);
2476 edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
2477 _signal_handler_move_end, obj);
2478 edje_object_signal_callback_add(wd->ent, "handler,moving", "elm.text",
2479 _signal_handler_moving, obj);
2480 edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
2481 _signal_selection_start, obj);
2482 edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
2483 _signal_selection_end, obj);
2484 edje_object_signal_callback_add(wd->ent, "magnifier,changed", "elm.text",
2485 _signal_magnifier_changed, obj);
2486 edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
2487 _signal_selection_changed, obj);
2488 edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
2489 _signal_selection_cleared, obj);
2490 edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
2491 _signal_entry_paste_request, obj);
2492 edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
2493 _signal_entry_copy_notify, obj);
2494 edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
2495 _signal_entry_cut_notify, obj);
2496 edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
2497 _signal_cursor_changed, obj);
2498 edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
2499 _signal_anchor_down, obj);
2500 edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
2501 _signal_anchor_up, obj);
2502 edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
2503 _signal_anchor_move, obj);
2504 edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
2505 _signal_anchor_in, obj);
2506 edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
2507 _signal_anchor_out, obj);
2508 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
2509 _signal_key_enter, obj);
2510 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
2511 _signal_mouse_down, obj);
2512 edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
2513 _signal_mouse_clicked, obj);
2514 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
2515 _signal_mouse_double, obj);
2516 edje_object_part_text_set(wd->ent, "elm.text", "");
2517 elm_widget_resize_object_set(obj, wd->ent);
2520 wd->input_panel_enable = edje_object_part_text_input_panel_enabled_get(wd->ent, "elm.text");
2522 #ifdef HAVE_ELEMENTARY_X
2523 top = elm_widget_top_get(obj);
2524 if ((top) && (elm_win_xwindow_get(top)))
2526 wd->sel_notify_handler =
2527 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
2528 _event_selection_notify, obj);
2529 wd->sel_clear_handler =
2530 ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
2531 _event_selection_clear, obj);
2534 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
2537 entries = eina_list_prepend(entries, obj);
2539 // module - find module for entry
2540 wd->api = _module(obj);
2541 // if found - hook in
2542 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2544 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2545 // TODO: and save some bytes, making descriptions per-class and not instance!
2546 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2550 EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extension_data *ext_mod)
2552 ELM_CHECK_WIDTYPE(obj, widtype);
2553 Widget_Data *wd = elm_widget_data_get(obj);
2555 ext_mod->cancel = _cancel;
2556 ext_mod->copy = _copy;
2557 ext_mod->cut = _cut;
2558 ext_mod->paste = _paste;
2559 ext_mod->select = _select;
2560 ext_mod->selectall = _selectall;
2561 ext_mod->ent = wd->ent;
2562 ext_mod->items = wd->items;
2563 ext_mod->longpress_timer = wd->longpress_timer;
2564 ext_mod->editable = wd->editable;
2565 ext_mod->have_selection = wd->have_selection;
2566 ext_mod->password = wd->password;
2567 ext_mod->selmode = wd->selmode;
2568 ext_mod->cnpinit = _cnpinit;
2569 ext_mod->context_menu = wd->context_menu;
2570 ext_mod->textonly = wd->textonly;
2574 * This sets the entry object not to line wrap. All input will
2575 * be on a single line, and the entry box will extend with user input.
2577 * @param obj The entry object
2578 * @param single_line If true, the text in the entry
2579 * will be on a single line.
2584 elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
2586 ELM_CHECK_WIDTYPE(obj, widtype);
2587 Widget_Data *wd = elm_widget_data_get(obj);
2589 Ecore_IMF_Context *ic;
2591 if (wd->single_line == single_line) return;
2592 wd->single_line = single_line;
2593 wd->linewrap = EINA_FALSE;
2594 wd->char_linewrap = EINA_FALSE;
2595 elm_entry_cnp_textonly_set(obj, EINA_TRUE);
2596 t = eina_stringshare_add(elm_entry_entry_get(obj));
2597 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2598 elm_entry_entry_set(obj, t);
2599 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
2600 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
2601 ic = elm_entry_imf_context_get(obj);
2604 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2607 eina_stringshare_del(t);
2612 * This returns true if the entry has been set to single line mode.
2613 * See also elm_entry_single_line_set().
2615 * @param obj The entry object
2616 * @return single_line If true, the text in the entry is set to display
2622 elm_entry_single_line_get(const Evas_Object *obj)
2624 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2625 Widget_Data *wd = elm_widget_data_get(obj);
2626 if (!wd) return EINA_FALSE;
2627 return wd->single_line;
2631 * This sets the entry object to password mode. All text entered
2632 * and/or displayed within the widget will be replaced with asterisks (*).
2634 * @param obj The entry object
2635 * @param password If true, password mode is enabled.
2640 elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
2642 ELM_CHECK_WIDTYPE(obj, widtype);
2643 Widget_Data *wd = elm_widget_data_get(obj);
2644 Ecore_IMF_Context *ic;
2647 if (wd->password == password) return;
2648 wd->password = password;
2649 wd->single_line = EINA_TRUE;
2650 wd->linewrap = EINA_FALSE;
2651 wd->char_linewrap = EINA_FALSE;
2652 if (_elm_config->password_show_last_character)
2653 wd->show_last_character = EINA_TRUE;
2654 t = eina_stringshare_add(elm_entry_entry_get(obj));
2655 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2656 elm_entry_entry_set(obj, t);
2661 elm_entry_autoperiod_set(obj, EINA_FALSE);
2663 if (wd->autocapital)
2664 elm_entry_autocapitalization_set(obj, EINA_FALSE);
2667 ic = elm_entry_imf_context_get(obj);
2669 ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
2671 eina_stringshare_del(t);
2677 * This returns whether password mode is enabled.
2678 * See also elm_entry_password_set().
2680 * @param obj The entry object
2681 * @return If true, the entry is set to display all characters
2687 elm_entry_password_get(const Evas_Object *obj)
2689 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2690 Widget_Data *wd = elm_widget_data_get(obj);
2691 if (!wd) return EINA_FALSE;
2692 return wd->password;
2696 * This sets the text displayed within the entry to @p entry.
2698 * @param obj The entry object
2699 * @param entry The text to be displayed
2704 elm_entry_entry_set(Evas_Object *obj, const char *entry)
2706 ELM_CHECK_WIDTYPE(obj, widtype);
2707 Widget_Data *wd = elm_widget_data_get(obj);
2709 if (!entry) entry = "";
2710 if(wd->max_no_of_bytes)
2712 int len = strlen(entry);
2713 if(len > wd->max_no_of_bytes)
2715 ERR("[ERROR]the length of the text set is more than max no of bytes, text cannot be set");
2719 edje_object_part_text_set(wd->ent, "elm.text", entry);
2720 if (wd->text) eina_stringshare_del(wd->text);
2722 wd->changed = EINA_TRUE;
2727 * This returns the text currently shown in object @p entry.
2728 * See also elm_entry_entry_set().
2730 * @param obj The entry object
2731 * @return The currently displayed text or NULL on failure
2736 elm_entry_entry_get(const Evas_Object *obj)
2738 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2739 Widget_Data *wd = elm_widget_data_get(obj);
2741 if (!wd) return NULL;
2743 if ((wd->text)&&(wd->password))
2744 return elm_entry_markup_to_utf8(wd->text);
2746 if (wd->text) return wd->text;
2747 text = edje_object_part_text_get(wd->ent, "elm.text");
2750 ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
2753 eina_stringshare_replace(&wd->text, text);
2754 if(wd->password)return elm_entry_markup_to_utf8(wd->text);
2760 * This returns EINA_TRUE if the entry is empty/there was an error
2761 * and EINA_FALSE if it is not empty.
2763 * @param obj The entry object
2764 * @return If the entry is empty or not.
2769 elm_entry_is_empty(const Evas_Object *obj)
2771 /* FIXME: until there's support for that in textblock, we just check
2772 * to see if the there is text or not. */
2773 ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
2774 Widget_Data *wd = elm_widget_data_get(obj);
2775 const Evas_Object *tb;
2776 Evas_Textblock_Cursor *cur;
2778 if (!wd) return EINA_TRUE;
2781 /* It's a hack until we get the support suggested above.
2782 * We just create a cursor, point it to the begining, and then
2783 * try to advance it, if it can advance, the tb is not empty,
2784 * otherwise it is. */
2785 tb = edje_object_part_object_get(wd->ent, "elm.text");
2786 cur = evas_object_textblock_cursor_new((Evas_Object *) tb); /* This is
2787 actually, ok for the time being, thsese hackish stuff will be removed
2788 once evas 1.0 is out*/
2789 evas_textblock_cursor_pos_set(cur, 0);
2790 ret = evas_textblock_cursor_char_next(cur);
2791 evas_textblock_cursor_free(cur);
2796 char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
2797 if (!str) return EINA_TRUE;
2799 ret = (strlen(str) == 0);
2805 * This returns all selected text within the entry.
2807 * @param obj The entry object
2808 * @return The selected text within the entry or NULL on failure
2813 elm_entry_selection_get(const Evas_Object *obj)
2815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2816 Widget_Data *wd = elm_widget_data_get(obj);
2817 if (!wd) return NULL;
2818 return edje_object_part_text_selection_get(wd->ent, "elm.text");
2822 * This inserts text in @p entry where the current cursor position.
2824 * This inserts text at the cursor position is as if it was typed
2825 * by the user (note this also allows markup which a user
2826 * can't just "type" as it would be converted to escaped text, so this
2827 * call can be used to insert things like emoticon items or bold push/pop
2828 * tags, other font and color change tags etc.)
2830 * @param obj The entry object
2831 * @param entry The text to insert
2836 elm_entry_entry_insert(Evas_Object *obj, const char *entry)
2838 ELM_CHECK_WIDTYPE(obj, widtype);
2839 Widget_Data *wd = elm_widget_data_get(obj);
2841 edje_object_part_text_insert(wd->ent, "elm.text", entry);
2843 if (cnpwidgetdata == obj)
2844 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
2846 wd->changed = EINA_TRUE;
2851 * This enables word line wrapping in the entry object. It is the opposite
2852 * of elm_entry_single_line_set(). Additionally, setting this disables
2853 * character line wrapping.
2854 * See also elm_entry_line_char_wrap_set().
2856 * @param obj The entry object
2857 * @param wrap If true, the entry will be wrapped once it reaches the end
2858 * of the object. Wrapping will occur at the end of the word before the end of the
2864 elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2866 ELM_CHECK_WIDTYPE(obj, widtype);
2867 Widget_Data *wd = elm_widget_data_get(obj);
2870 if (wd->linewrap == wrap) return;
2871 wd->linewrap = wrap;
2873 wd->char_linewrap = EINA_FALSE;
2874 t = eina_stringshare_add(elm_entry_entry_get(obj));
2875 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2876 elm_entry_entry_set(obj, t);
2877 eina_stringshare_del(t);
2882 * Set wrap width of the entry
2884 * @param obj The entry object
2885 * @param w The wrap width in pixels at a minimum where words need to wrap
2889 elm_entry_wrap_width_set(Evas_Object *obj, Evas_Coord w)
2891 Widget_Data *wd = elm_widget_data_get(obj);
2892 if (wd->wrap_w == w) return;
2898 * get wrap width of the entry
2900 * @param obj The entry object
2901 * @return The wrap width in pixels at a minimum where words need to wrap
2905 elm_entry_wrap_width_get(const Evas_Object *obj)
2907 Widget_Data *wd = elm_widget_data_get(obj);
2912 * This enables character line wrapping in the entry object. It is the opposite
2913 * of elm_entry_single_line_set(). Additionally, setting this disables
2914 * word line wrapping.
2915 * See also elm_entry_line_wrap_set().
2917 * @param obj The entry object
2918 * @param wrap If true, the entry will be wrapped once it reaches the end
2919 * of the object. Wrapping will occur immediately upon reaching the end of the object.
2924 elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
2926 ELM_CHECK_WIDTYPE(obj, widtype);
2927 Widget_Data *wd = elm_widget_data_get(obj);
2930 if (wd->char_linewrap == wrap) return;
2931 wd->char_linewrap = wrap;
2932 if(wd->char_linewrap)
2933 wd->linewrap = EINA_FALSE;
2934 t = eina_stringshare_add(elm_entry_entry_get(obj));
2935 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2936 elm_entry_entry_set(obj, t);
2937 eina_stringshare_del(t);
2942 * This sets the editable attribute of the entry.
2944 * @param obj The entry object
2945 * @param editable If true, the entry will be editable by the user.
2946 * If false, it will be set to the disabled state.
2951 elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
2953 ELM_CHECK_WIDTYPE(obj, widtype);
2954 Widget_Data *wd = elm_widget_data_get(obj);
2957 if (wd->editable == editable) return;
2958 wd->editable = editable;
2959 t = eina_stringshare_add(elm_entry_entry_get(obj));
2960 _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
2961 elm_entry_entry_set(obj, t);
2962 eina_stringshare_del(t);
2965 #ifdef HAVE_ELEMENTARY_X
2967 elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
2969 elm_drop_target_del(obj);
2974 * This gets the editable attribute of the entry.
2975 * See also elm_entry_editable_set().
2977 * @param obj The entry object
2978 * @return If true, the entry is editable by the user.
2979 * If false, it is not editable by the user
2984 elm_entry_editable_get(const Evas_Object *obj)
2986 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2987 Widget_Data *wd = elm_widget_data_get(obj);
2988 if (!wd) return EINA_FALSE;
2989 return wd->editable;
2993 * This drops any existing text selection within the entry.
2995 * @param obj The entry object
3000 elm_entry_select_none(Evas_Object *obj)
3002 ELM_CHECK_WIDTYPE(obj, widtype);
3003 Widget_Data *wd = elm_widget_data_get(obj);
3007 wd->selmode = EINA_FALSE;
3008 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3009 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3011 wd->have_selection = EINA_FALSE;
3012 edje_object_part_text_select_none(wd->ent, "elm.text");
3016 * This selects all text within the entry.
3018 * @param obj The entry object
3023 elm_entry_select_all(Evas_Object *obj)
3025 ELM_CHECK_WIDTYPE(obj, widtype);
3026 Widget_Data *wd = elm_widget_data_get(obj);
3030 wd->selmode = EINA_FALSE;
3031 edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
3032 edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
3034 wd->have_selection = EINA_TRUE;
3035 edje_object_part_text_select_all(wd->ent, "elm.text");
3039 * This function returns the geometry of the cursor.
3041 * It's useful if you want to draw something on the cursor (or where it is),
3042 * or for example in the case of scrolled entry where you want to show the
3045 * @param obj The entry object
3046 * @param x returned geometry
3047 * @param y returned geometry
3048 * @param w returned geometry
3049 * @param h returned geometry
3050 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3055 elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3057 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3058 Widget_Data *wd = elm_widget_data_get(obj);
3059 if (!wd) return EINA_FALSE;
3060 edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
3065 * This moves the cursor one place to the right within the entry.
3067 * @param obj The entry object
3068 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3073 elm_entry_cursor_next(Evas_Object *obj)
3075 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3076 Widget_Data *wd = elm_widget_data_get(obj);
3077 if (!wd) return EINA_FALSE;
3078 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3082 * This moves the cursor one place to the left within the entry.
3084 * @param obj The entry object
3085 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3090 elm_entry_cursor_prev(Evas_Object *obj)
3092 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3093 Widget_Data *wd = elm_widget_data_get(obj);
3094 if (!wd) return EINA_FALSE;
3095 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3099 * This moves the cursor one line up within the entry.
3101 * @param obj The entry object
3102 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3107 elm_entry_cursor_up(Evas_Object *obj)
3109 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3110 Widget_Data *wd = elm_widget_data_get(obj);
3111 if (!wd) return EINA_FALSE;
3112 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3116 * This moves the cursor one line down within the entry.
3118 * @param obj The entry object
3119 * @return EINA_TRUE upon success, EINA_FALSE upon failure
3124 elm_entry_cursor_down(Evas_Object *obj)
3126 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3127 Widget_Data *wd = elm_widget_data_get(obj);
3128 if (!wd) return EINA_FALSE;
3129 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3133 * This moves the cursor to the beginning of the entry.
3135 * @param obj The entry object
3140 elm_entry_cursor_begin_set(Evas_Object *obj)
3142 ELM_CHECK_WIDTYPE(obj, widtype);
3143 Widget_Data *wd = elm_widget_data_get(obj);
3145 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3149 * This moves the cursor to the end of the entry.
3151 * @param obj The entry object
3156 elm_entry_cursor_end_set(Evas_Object *obj)
3158 ELM_CHECK_WIDTYPE(obj, widtype);
3159 Widget_Data *wd = elm_widget_data_get(obj);
3161 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3165 * This moves the cursor to the beginning of the current line.
3167 * @param obj The entry object
3172 elm_entry_cursor_line_begin_set(Evas_Object *obj)
3174 ELM_CHECK_WIDTYPE(obj, widtype);
3175 Widget_Data *wd = elm_widget_data_get(obj);
3177 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3181 * This moves the cursor to the end of the current line.
3183 * @param obj The entry object
3188 elm_entry_cursor_line_end_set(Evas_Object *obj)
3190 ELM_CHECK_WIDTYPE(obj, widtype);
3191 Widget_Data *wd = elm_widget_data_get(obj);
3193 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3197 * This begins a selection within the entry as though
3198 * the user were holding down the mouse button to make a selection.
3200 * @param obj The entry object
3205 elm_entry_cursor_selection_begin(Evas_Object *obj)
3207 ELM_CHECK_WIDTYPE(obj, widtype);
3208 Widget_Data *wd = elm_widget_data_get(obj);
3210 edje_object_part_text_select_begin(wd->ent, "elm.text");
3214 * This ends a selection within the entry as though
3215 * the user had just released the mouse button while making a selection.
3217 * @param obj The entry object
3222 elm_entry_cursor_selection_end(Evas_Object *obj)
3224 ELM_CHECK_WIDTYPE(obj, widtype);
3225 Widget_Data *wd = elm_widget_data_get(obj);
3227 edje_object_part_text_select_extend(wd->ent, "elm.text");
3231 * TODO: fill this in
3233 * @param obj The entry object
3234 * @return TODO: fill this in
3239 elm_entry_cursor_is_format_get(const Evas_Object *obj)
3241 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3242 Widget_Data *wd = elm_widget_data_get(obj);
3243 if (!wd) return EINA_FALSE;
3244 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3248 * This returns whether the cursor is visible.
3250 * @param obj The entry object
3251 * @return If true, the cursor is visible.
3256 elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
3258 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3259 Widget_Data *wd = elm_widget_data_get(obj);
3260 if (!wd) return EINA_FALSE;
3261 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3265 * TODO: fill this in
3267 * @param obj The entry object
3268 * @return TODO: fill this in
3273 elm_entry_cursor_content_get(const Evas_Object *obj)
3275 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3276 Widget_Data *wd = elm_widget_data_get(obj);
3277 if (!wd) return NULL;
3278 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
3282 * This executes a "cut" action on the selected text in the entry.
3284 * @param obj The entry object
3289 elm_entry_selection_cut(Evas_Object *obj)
3291 ELM_CHECK_WIDTYPE(obj, widtype);
3292 Widget_Data *wd = elm_widget_data_get(obj);
3294 _cut(obj, NULL, NULL);
3298 * This executes a "copy" action on the selected text in the entry.
3300 * @param obj The entry object
3305 elm_entry_selection_copy(Evas_Object *obj)
3307 ELM_CHECK_WIDTYPE(obj, widtype);
3308 Widget_Data *wd = elm_widget_data_get(obj);
3310 _copy(obj, NULL, NULL);
3314 * This executes a "paste" action in the entry.
3316 * @param obj The entry object
3321 elm_entry_selection_paste(Evas_Object *obj)
3323 ELM_CHECK_WIDTYPE(obj, widtype);
3324 Widget_Data *wd = elm_widget_data_get(obj);
3326 _paste(obj, NULL, NULL);
3330 * This clears and frees the items in a entry's contextual (right click) menu.
3332 * @param obj The entry object
3337 elm_entry_context_menu_clear(Evas_Object *obj)
3339 ELM_CHECK_WIDTYPE(obj, widtype);
3340 Widget_Data *wd = elm_widget_data_get(obj);
3341 Elm_Entry_Context_Menu_Item *it;
3343 EINA_LIST_FREE(wd->items, it)
3345 eina_stringshare_del(it->label);
3346 eina_stringshare_del(it->icon_file);
3347 eina_stringshare_del(it->icon_group);
3353 * This adds an item to the entry's contextual menu.
3355 * @param obj The entry object
3356 * @param label The item's text label
3357 * @param icon_file The item's icon file
3358 * @param icon_type The item's icon type
3359 * @param func The callback to execute when the item is clicked
3360 * @param data The data to associate with the item for related functions
3365 elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
3367 ELM_CHECK_WIDTYPE(obj, widtype);
3368 Widget_Data *wd = elm_widget_data_get(obj);
3369 Elm_Entry_Context_Menu_Item *it;
3371 it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
3373 wd->items = eina_list_append(wd->items, it);
3375 it->label = eina_stringshare_add(label);
3376 it->icon_file = eina_stringshare_add(icon_file);
3377 it->icon_type = icon_type;
3379 it->data = (void *)data;
3383 * This disables the entry's contextual (right click) menu.
3385 * @param obj The entry object
3386 * @param disabled If true, the menu is disabled
3391 elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3393 ELM_CHECK_WIDTYPE(obj, widtype);
3394 Widget_Data *wd = elm_widget_data_get(obj);
3396 if (wd->context_menu == !disabled) return;
3397 wd->context_menu = !disabled;
3401 * This returns whether the entry's contextual (right click) menu is disabled.
3403 * @param obj The entry object
3404 * @return If true, the menu is disabled
3409 elm_entry_context_menu_disabled_get(const Evas_Object *obj)
3411 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3412 Widget_Data *wd = elm_widget_data_get(obj);
3413 if (!wd) return EINA_FALSE;
3414 return !wd->context_menu;
3418 * This appends a custom item provider to the list for that entry
3420 * This appends the given callback. The list is walked from beginning to end
3421 * with each function called given the item href string in the text. If the
3422 * function returns an object handle other than NULL (it should create an
3423 * and object to do this), then this object is used to replace that item. If
3424 * not the next provider is called until one provides an item object, or the
3425 * default provider in entry does.
3427 * @param obj The entry object
3428 * @param func The function called to provide the item object
3429 * @param data The data passed to @p func
3434 elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3436 ELM_CHECK_WIDTYPE(obj, widtype);
3437 Widget_Data *wd = elm_widget_data_get(obj);
3439 EINA_SAFETY_ON_NULL_RETURN(func);
3440 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3444 wd->item_providers = eina_list_append(wd->item_providers, ip);
3448 * This prepends a custom item provider to the list for that entry
3450 * This prepends the given callback. See elm_entry_item_provider_append() for
3453 * @param obj The entry object
3454 * @param func The function called to provide the item object
3455 * @param data The data passed to @p func
3460 elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3462 ELM_CHECK_WIDTYPE(obj, widtype);
3463 Widget_Data *wd = elm_widget_data_get(obj);
3465 EINA_SAFETY_ON_NULL_RETURN(func);
3466 Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
3470 wd->item_providers = eina_list_prepend(wd->item_providers, ip);
3474 * This removes a custom item provider to the list for that entry
3476 * This removes the given callback. See elm_entry_item_provider_append() for
3479 * @param obj The entry object
3480 * @param func The function called to provide the item object
3481 * @param data The data passed to @p func
3486 elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
3488 ELM_CHECK_WIDTYPE(obj, widtype);
3489 Widget_Data *wd = elm_widget_data_get(obj);
3491 Elm_Entry_Item_Provider *ip;
3493 EINA_SAFETY_ON_NULL_RETURN(func);
3494 EINA_LIST_FOREACH(wd->item_providers, l, ip)
3496 if ((ip->func == func) && (ip->data == data))
3498 wd->item_providers = eina_list_remove_list(wd->item_providers, l);
3506 * Append a filter function for text inserted in the entry
3508 * Append the given callback to the list. This functions will be called
3509 * whenever any text is inserted into the entry, with the text to be inserted
3510 * as a parameter. The callback function is free to alter the text in any way
3511 * it wants, but it must remember to free the given pointer and update it.
3512 * If the new text is to be discarded, the function can free it and set it text
3513 * parameter to NULL. This will also prevent any following filters from being
3516 * @param obj The entry object
3517 * @param func The function to use as text filter
3518 * @param data User data to pass to @p func
3523 elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3526 Elm_Entry_Text_Filter *tf;
3527 ELM_CHECK_WIDTYPE(obj, widtype);
3529 wd = elm_widget_data_get(obj);
3531 EINA_SAFETY_ON_NULL_RETURN(func);
3533 tf = ELM_NEW(Elm_Entry_Text_Filter);
3537 wd->text_filters = eina_list_append(wd->text_filters, tf);
3541 * Prepend a filter function for text insdrted in the entry
3543 * Prepend the given callback to the list. See elm_entry_text_filter_append()
3544 * for more information
3546 * @param obj The entry object
3547 * @param func The function to use as text filter
3548 * @param data User data to pass to @p func
3553 elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3556 Elm_Entry_Text_Filter *tf;
3557 ELM_CHECK_WIDTYPE(obj, widtype);
3559 wd = elm_widget_data_get(obj);
3561 EINA_SAFETY_ON_NULL_RETURN(func);
3563 tf = ELM_NEW(Elm_Entry_Text_Filter);
3567 wd->text_filters = eina_list_prepend(wd->text_filters, tf);
3571 * Remove a filter from the list
3573 * Removes the given callback from the filter list. See elm_entry_text_filter_append()
3574 * for more information.
3576 * @param obj The entry object
3577 * @param func The filter function to remove
3578 * @param data The user data passed when adding the function
3583 elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
3587 Elm_Entry_Text_Filter *tf;
3588 ELM_CHECK_WIDTYPE(obj, widtype);
3590 wd = elm_widget_data_get(obj);
3592 EINA_SAFETY_ON_NULL_RETURN(func);
3594 EINA_LIST_FOREACH(wd->text_filters, l, tf)
3596 if ((tf->func == func) && (tf->data == data))
3598 wd->text_filters = eina_list_remove_list(wd->text_filters, l);
3606 * This converts a markup (HTML-like) string into UTF-8.
3608 * @param s The string (in markup) to be converted
3609 * @return The converted string (in UTF-8)
3614 elm_entry_markup_to_utf8(const char *s)
3616 char *ss = _elm_util_mkup_to_text(s);
3617 if (!ss) ss = strdup("");
3622 * This converts a UTF-8 string into markup (HTML-like).
3624 * @param s The string (in UTF-8) to be converted
3625 * @return The converted string (in markup)
3630 elm_entry_utf8_to_markup(const char *s)
3632 char *ss = _elm_util_text_to_mkup(s);
3633 if (!ss) ss = strdup("");
3638 * Get the input method context in the entry widget
3640 * @param obj The entry object
3641 * @return The input method context
3645 EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
3647 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3648 Widget_Data *wd = elm_widget_data_get(obj);
3649 if (!wd || !wd->ent) return NULL;
3651 return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
3655 * Set whether entry should enable the return key on soft keyboard automatically
3657 * @param obj The entry object
3658 * @param on If true, entry enables the return key on soft keyboard automatically.
3663 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
3665 ELM_CHECK_WIDTYPE(obj, widtype);
3666 Widget_Data *wd = elm_widget_data_get(obj);
3669 wd->autoreturnkey = on;
3670 _check_enable_returnkey(obj);
3674 * Set whether entry should support auto capitalization
3676 * @param obj The entry object
3677 * @param on If true, entry suports auto capitalization.
3682 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
3684 ELM_CHECK_WIDTYPE(obj, widtype);
3685 Widget_Data *wd = elm_widget_data_get(obj);
3689 wd->autocapital = EINA_FALSE;
3691 wd->autocapital = autocap;
3693 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3694 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3695 wd->autocapital = EINA_FALSE;
3697 edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
3701 * Set whether entry should support auto period
3703 * @param obj The entry object
3704 * @param on If true, entry suports auto period.
3709 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
3711 ELM_CHECK_WIDTYPE(obj, widtype);
3712 Widget_Data *wd = elm_widget_data_get(obj);
3716 wd->autoperiod = EINA_FALSE;
3718 wd->autoperiod = autoperiod;
3720 if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
3721 wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
3722 wd->autoperiod = EINA_FALSE;
3724 edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
3728 * Set the font size on the entry object
3730 * @param obj The entry object
3731 * @param size font size
3736 elm_entry_fontsize_set(Evas_Object *obj, int fontsize)
3738 ELM_CHECK_WIDTYPE(obj, widtype);
3739 Widget_Data *wd = elm_widget_data_get(obj);
3740 Eina_Strbuf *fontbuf = NULL;
3745 t = eina_stringshare_add(elm_entry_entry_get(obj));
3746 fontbuf = eina_strbuf_new();
3747 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
3749 if (fontsize == 0) removeflag = 1; // remove fontsize tag
3751 if (_stringshare_key_value_replace(&t, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
3753 elm_entry_entry_set(obj, t);
3757 eina_strbuf_free(fontbuf);
3758 eina_stringshare_del(t);
3762 * Set the text align on the entry object
3764 * @param obj The entry object
3765 * @param align align mode
3770 elm_entry_text_align_set(Evas_Object *obj, const char *alignmode)
3772 ELM_CHECK_WIDTYPE(obj, widtype);
3773 Widget_Data *wd = elm_widget_data_get(obj);
3778 t = eina_stringshare_add(elm_entry_entry_get(obj));
3780 if (len <= 0) return;
3782 if (_stringshare_key_value_replace(&t, "align", alignmode, 0) == 0)
3783 elm_entry_entry_set(obj, t);
3787 eina_stringshare_del(t);
3791 * Set the text color on the entry object
3793 * @param obj The entry object
3794 * @param r Red property background color of The entry object
3795 * @param g Green property background color of The entry object
3796 * @param b Blue property background color of The entry object
3797 * @param a Alpha property background alpha of The entry object
3802 elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3804 ELM_CHECK_WIDTYPE(obj, widtype);
3805 Widget_Data *wd = elm_widget_data_get(obj);
3806 Eina_Strbuf *colorbuf = NULL;
3811 t = eina_stringshare_add(elm_entry_entry_get(obj));
3813 if (len <= 0) return;
3814 colorbuf = eina_strbuf_new();
3815 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
3817 if (_stringshare_key_value_replace(&t, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
3819 elm_entry_entry_set(obj, t);
3823 eina_strbuf_free(colorbuf);
3824 eina_stringshare_del(t);
3828 * Set background color of the entry
3830 * @param obj The entry object
3831 * @param r Red property background color of The entry object
3832 * @param g Green property background color of The entry object
3833 * @param b Blue property background color of The entry object
3834 * @param a Alpha property background alpha of The entry object
3838 elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
3840 ELM_CHECK_WIDTYPE(obj, widtype);
3841 Widget_Data *wd = elm_widget_data_get(obj);
3842 evas_object_color_set(wd->bg, r, g, b, a);
3844 if (wd->bgcolor == EINA_FALSE)
3847 edje_object_part_swallow(wd->ent, "entry.swallow.background", wd->bg);
3852 * Set the ellipsis behavior of the entry
3854 * @param obj The entry object
3855 * @param ellipsis To ellipsis text or not
3859 elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
3861 ELM_CHECK_WIDTYPE(obj, widtype);
3862 Widget_Data *wd = elm_widget_data_get(obj);
3863 if (wd->ellipsis == ellipsis) return;
3864 wd->ellipsis = ellipsis;
3870 * Filter inserted text based on user defined character and byte limits
3872 * Add this filter to an entry to limit the characters that it will accept
3873 * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
3874 * The funtion works on the UTF-8 representation of the string, converting
3875 * it from the set markup, thus not accounting for any format in it.
3877 * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
3878 * it as data when setting the filter. In it it's possible to set limits
3879 * by character count or bytes (any of them is disabled if 0), and both can
3880 * be set at the same time. In that case, it first checks for characters,
3883 * The function will cut the inserted text in order to allow only the first
3884 * number of characters that are still allowed. The cut is made in
3885 * characters, even when limiting by bytes, in order to always contain
3886 * valid ones and avoid half unicode characters making it in.
3891 elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
3893 Elm_Entry_Filter_Limit_Size *lim = data;
3896 const char *(*text_get)(const Evas_Object *);
3897 const char *widget_type;
3899 EINA_SAFETY_ON_NULL_RETURN(data);
3900 EINA_SAFETY_ON_NULL_RETURN(entry);
3901 EINA_SAFETY_ON_NULL_RETURN(text);
3903 /* hack. I don't want to copy the entire function to work with
3905 widget_type = elm_widget_type_get(entry);
3906 if (!strcmp(widget_type, "entry"))
3907 text_get = elm_entry_entry_get;
3908 else if (!strcmp(widget_type, "scrolled_entry"))
3909 text_get = elm_scrolled_entry_entry_get;
3913 current = elm_entry_markup_to_utf8(text_get(entry));
3915 if (lim->max_char_count > 0)
3918 len = evas_string_char_len_get(current);
3919 if (len >= lim->max_char_count)
3921 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3927 newlen = evas_string_char_len_get(*text);
3928 cut = strlen(*text);
3929 while ((len + newlen) > lim->max_char_count)
3931 cut = evas_string_char_prev_get(*text, cut, NULL);
3937 if (lim->max_byte_count > 0)
3939 len = strlen(current);
3940 if (len >= lim->max_byte_count)
3942 evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
3948 newlen = strlen(*text);
3949 while ((len + newlen) > lim->max_byte_count)
3951 int p = evas_string_char_prev_get(*text, newlen, NULL);
3952 newlen -= (newlen - p);
3955 (*text)[newlen] = 0;
3966 * Filter inserted text based on accepted or rejected sets of characters
3968 * Add this filter to an entry to restrict the set of accepted characters
3969 * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
3970 * This structure contains both accepted and rejected sets, but they are
3971 * mutually exclusive. If accepted is set, it will be used, otherwise it
3972 * goes on to the rejected set.
3975 elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
3977 Elm_Entry_Filter_Accept_Set *as = data;
3981 int read_idx, last_read_idx = 0, read_char;
3983 EINA_SAFETY_ON_NULL_RETURN(data);
3984 EINA_SAFETY_ON_NULL_RETURN(text);
3986 if ((!as->accepted) && (!as->rejected))
3992 goes_in = EINA_TRUE;
3997 goes_in = EINA_FALSE;
4001 read_idx = evas_string_char_next_get(*text, 0, &read_char);
4004 int cmp_idx, cmp_char;
4005 Eina_Bool in_set = EINA_FALSE;
4007 cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
4010 if (read_char == cmp_char)
4015 cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
4017 if (in_set == goes_in)
4019 int size = read_idx - last_read_idx;
4020 const char *src = (*text) + last_read_idx;
4022 memcpy(insert, *text + last_read_idx, size);
4025 last_read_idx = read_idx;
4026 read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
4032 * This sets the file (and implicitly loads it) for the text to display and
4033 * then edit. All changes are written back to the file after a short delay if
4034 * the entry object is set to autosave.
4036 * @param obj The entry object
4037 * @param file The path to the file to load and save
4038 * @param format The file format
4043 elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4045 ELM_CHECK_WIDTYPE(obj, widtype);
4046 Widget_Data *wd = elm_widget_data_get(obj);
4048 if (wd->delay_write)
4050 ecore_timer_del(wd->delay_write);
4051 wd->delay_write = NULL;
4053 if (wd->autosave) _save(obj);
4054 eina_stringshare_replace(&wd->file, file);
4055 wd->format = format;
4060 * Gets the file to load and save and the file format
4062 * @param obj The entry object
4063 * @param file The path to the file to load and save
4064 * @param format The file format
4069 elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4071 ELM_CHECK_WIDTYPE(obj, widtype);
4072 Widget_Data *wd = elm_widget_data_get(obj);
4074 if (file) *file = wd->file;
4075 if (format) *format = wd->format;
4079 * This function writes any changes made to the file set with
4080 * elm_entry_file_set()
4082 * @param obj The entry object
4087 elm_entry_file_save(Evas_Object *obj)
4089 ELM_CHECK_WIDTYPE(obj, widtype);
4090 Widget_Data *wd = elm_widget_data_get(obj);
4092 if (wd->delay_write)
4094 ecore_timer_del(wd->delay_write);
4095 wd->delay_write = NULL;
4098 wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
4102 * This sets the entry object to 'autosave' the loaded text file or not.
4104 * @param obj The entry object
4105 * @param autosave Autosave the loaded file or not
4110 elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
4112 ELM_CHECK_WIDTYPE(obj, widtype);
4113 Widget_Data *wd = elm_widget_data_get(obj);
4115 wd->autosave = !!autosave;
4119 * This gets the entry object's 'autosave' status.
4121 * @param obj The entry object
4122 * @return Autosave the loaded file or not
4127 elm_entry_autosave_get(const Evas_Object *obj)
4129 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4130 Widget_Data *wd = elm_widget_data_get(obj);
4131 if (!wd) return EINA_FALSE;
4132 return wd->autosave;
4136 * Control pasting of text and images for the widget.
4138 * Normally the entry allows both text and images to be pasted. By setting
4139 * textonly to be true, this prevents images from being pasted.
4141 * Note this only changes the behaviour of text.
4143 * @param obj The entry object
4144 * @param pmode paste mode - 0 is text only, 1 is text+image+other.
4149 elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
4151 Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
4152 ELM_CHECK_WIDTYPE(obj, widtype);
4153 Widget_Data *wd = elm_widget_data_get(obj);
4155 textonly = !!textonly;
4156 if (wd->textonly == textonly) return;
4157 wd->textonly = !!textonly;
4161 * Getting elm_entry text paste/drop mode.
4163 * In textonly mode, only text may be pasted or dropped into the widget.
4165 * @param obj The entry object
4166 * @return If the widget only accepts text from pastes.
4171 elm_entry_cnp_textonly_get(Evas_Object *obj)
4173 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4174 Widget_Data *wd = elm_widget_data_get(obj);
4175 if (!wd) return EINA_FALSE;
4176 return wd->textonly;
4180 * This sets the attribute to show the input panel automatically.
4182 * @param obj The entry object
4183 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
4188 elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled)
4190 ELM_CHECK_WIDTYPE(obj, widtype);
4191 Widget_Data *wd = elm_widget_data_get(obj);
4194 wd->input_panel_enable = enabled;
4195 edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", enabled);
4199 * Set the input panel layout of the entry
4201 * @param obj The entry object
4202 * @param layout the layout to set
4207 elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout)
4209 ELM_CHECK_WIDTYPE(obj, widtype);
4210 Widget_Data *wd = elm_widget_data_get(obj);
4213 Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
4216 wd->input_panel_layout = layout;
4218 ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
4222 * Set the magnifier style of the entry
4224 * @param obj The entry object
4225 * @param type the magnifier style to set
4230 elm_entry_magnifier_type_set(Evas_Object *obj, int type)
4232 ELM_CHECK_WIDTYPE(obj, widtype);
4233 Widget_Data *wd = elm_widget_data_get(obj);
4236 wd->mgf_type = type;
4237 _magnifier_create(obj);