================================================================
[framework/uifw/elementary.git] / src / lib / elm_entry.c
index 5a502fd..4d049e9 100644 (file)
@@ -1,12 +1,10 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 #include <Elementary.h>
+#include <Elementary_Cursor.h>
 #include "elm_priv.h"
 #include "elm_module_priv.h"
+
 /**
  * @defgroup Entry Entry
- * @ingroup Elementary
  *
  * An entry is a convenience widget which shows
  * a box that the user can enter text into.  Unlike a
  * input.  Entry widgets are capable of expanding past the
  * boundaries of the window, thus resizing the window to its
  * own length.
- * 
+ *
  * You can also insert "items" in the entry with:
- * 
+ *
  * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
- * 
+ *
  * for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
  * vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
  * supports a list of emoticon names by default. These are:
- * 
+ *
  * - emoticon/angry
  * - emoticon/angry-shout
  * - emoticon/crazy-laugh
  * These are built-in currently, but you can add your own item provieer that
  * can create inlined objects in the text and fill the space allocated to the
  * item with a custom object of your own.
- * 
+ *
  * See the entry test for some more examples of use of this.
- * 
+ *
+ * Entries have functions to load a text file, display it,
+ * allowing editing of it and saving of changes back to the file loaded.
+ * Changes are written back to the original file after a short delay.
+ * The file to load and save to is specified by elm_entry_file_set().
+ *
  * Signals that you can add callbacks for are:
  * - "changed" - The text within the entry was changed
- * - "activated" - The entry has received focus and the cursor
+ * - "activated" - The entry has had editing finished and changes are to be committed (generally when enter key is pressed)
  * - "press" - The entry has been clicked
  * - "longpressed" - The entry has been clicked for a couple seconds
  * - "clicked" - The entry has been clicked
 typedef struct _Mod_Api Mod_Api;
 
 typedef struct _Widget_Data Widget_Data;
+typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
+typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
 
 struct _Widget_Data
 {
    Evas_Object *ent;
-   Evas_Object *popup;/*copy paste UI - elm_popup*/
-   Evas_Object *ctxpopup;/*copy paste UI - elm_ctxpopup*/
-   Evas_Object *bg;   
+   Evas_Object *bg;
    Evas_Object *hoversel;
    Ecore_Job *deferred_recalc_job;
    Ecore_Event_Handler *sel_notify_handler;
    Ecore_Event_Handler *sel_clear_handler;
    Ecore_Timer *longpress_timer;
+   Ecore_Timer *delay_write;
    /* Only for clipboard */
    const char *cut_sel;
    const char *text;
    Evas_Coord wrap_w;
    int ellipsis_threshold;
+   const char *file;
+   Elm_Text_Format format;
    Evas_Coord lastw;
    Evas_Coord downx, downy;
    Evas_Coord cx, cy, cw, ch;
    Eina_List *items;
    Eina_List *item_providers;
+   Eina_List *text_filters;
    Ecore_Job *hovdeljob;
    Mod_Api *api; // module api if supplied
    int max_no_of_bytes;
@@ -127,30 +134,54 @@ struct _Widget_Data
    Eina_Bool editable : 1;
    Eina_Bool selection_asked : 1;
    Eina_Bool have_selection : 1;
+   Eina_Bool handler_moving : 1;
    Eina_Bool selmode : 1;
    Eina_Bool deferred_cur : 1;
    Eina_Bool disabled : 1;
    Eina_Bool double_clicked : 1;
+   Eina_Bool long_pressed : 1;
    Eina_Bool context_menu : 1;
    Eina_Bool drag_selection_asked : 1;
    Eina_Bool bgcolor : 1;
    Eina_Bool ellipsis : 1;
+   Eina_Bool can_write : 1;
+   Eina_Bool autosave : 1;
    Eina_Bool autoreturnkey : 1;
    Eina_Bool input_panel_enable : 1;
-   Eina_Bool autocapitalize : 1;
+   Eina_Bool autocapital : 1;
    Elm_Input_Panel_Layout input_panel_layout;
    Eina_Bool autoperiod : 1;
 };
 
+struct _Elm_Entry_Context_Menu_Item
+{
+   Evas_Object *obj;
+   const char *label;
+   const char *icon_file;
+   const char *icon_group;
+   Elm_Icon_Type icon_type;
+   Evas_Smart_Cb func;
+   void *data;
+};
+
 struct _Elm_Entry_Item_Provider
 {
    Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
    void *data;
 };
 
+struct _Elm_Entry_Text_Filter
+{
+   void (*func) (void *data, Evas_Object *entry, char **text);
+   void *data;
+};
+
 static const char *widtype = NULL;
+// start for cbhm
+static Evas_Object *cnpwidgetdata = NULL;
+// end for cbhm
 
-static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Drop_Data *);
+static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Selection_Data *);
 static void _del_hook(Evas_Object *obj);
 static void _theme_hook(Evas_Object *obj);
 static void _disable_hook(Evas_Object *obj);
@@ -160,8 +191,11 @@ static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static const char *_getbase(Evas_Object *obj);
 static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
+static void _signal_selection_end(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
+static void _signal_handler_move_start(void *data, Evas_Object *obj, const char *emission, const char *source);
+static void _signal_handler_move_end(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
@@ -172,7 +206,6 @@ static int _stringshare_key_value_replace(const char **srcstring, char *key, con
 static int _is_width_over(Evas_Object *obj);
 static void _ellipsis_entry_to_width(Evas_Object *obj);
 static void _reverse_ellipsis_entry(Evas_Object *obj);
-static int _textinput_control_function(void *data,void *input_data);
 static int _entry_length_get(Evas_Object *obj);
 
 static const char SIG_CHANGED[] = "changed";
@@ -191,9 +224,6 @@ static const char SIG_SELECTION_CHANGED[] = "selection,changed";
 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
-#ifdef HAVE_CONFORMANT_AUTOSCROLL
-static const char SIG_IMPREGION_CHANGED[] = "impregion,changed";
-#endif
 static const Evas_Smart_Cb_Description _signals[] = {
   {SIG_CHANGED, ""},
   {SIG_ACTIVATED, ""},
@@ -221,6 +251,7 @@ struct _Mod_Api
    void (*obj_hook) (Evas_Object *obj);
    void (*obj_unhook) (Evas_Object *obj);
    void (*obj_longpress) (Evas_Object *obj);
+   void (*obj_hidemenu) (Evas_Object *obj);
    void (*obj_mouseup) (Evas_Object *obj);
 };
 
@@ -239,18 +270,184 @@ _module(Evas_Object *obj __UNUSED__)
      _elm_module_symbol_get(m, "obj_unhook");
    ((Mod_Api *)(m->api)      )->obj_longpress = // called on long press menu
      _elm_module_symbol_get(m, "obj_longpress");
-    ((Mod_Api *)(m->api)      )->obj_mouseup = // called on mouseup
-   _elm_module_symbol_get(m, "obj_mouseup");
+   ((Mod_Api *)(m->api)      )->obj_hidemenu = // called on hide menu
+      _elm_module_symbol_get(m, "obj_hidemenu");
+   ((Mod_Api *)(m->api)      )->obj_mouseup = // called on mouseup
+      _elm_module_symbol_get(m, "obj_mouseup");
    ok: // ok - return api
    return m->api;
 }
 
+static char *
+_buf_append(char *buf, const char *str, int *len, int *alloc)
+{
+   int len2 = strlen(str);
+   if ((*len + len2) >= *alloc)
+     {
+        char *buf2 = realloc(buf, *alloc + len2 + 512);
+        if (!buf2) return NULL;
+        buf = buf2;
+        *alloc += (512 + len2);
+     }
+   strcpy(buf + *len, str);
+   *len += len2;
+   return buf;
+}
+
+static char *
+_load_file(const char *file)
+{
+   FILE *f;
+   size_t size;
+   int alloc = 0, len = 0;
+   char *text = NULL, buf[PATH_MAX];
+
+   f = fopen(file, "rb");
+   if (!f) return NULL;
+   while ((size = fread(buf, 1, sizeof(buf), f)))
+     {
+        char *tmp_text;
+        buf[size] = 0;
+        tmp_text = _buf_append(text, buf, &len, &alloc);
+        if (!tmp_text) break;
+        text = tmp_text;
+     }
+   fclose(f);
+   return text;
+}
+
+static char *
+_load_plain(const char *file)
+{
+   char *text;
+
+   text = _load_file(file);
+   if (text)
+     {
+        char *text2;
+
+        text2 = elm_entry_utf8_to_markup(text);
+        free(text);
+        return text2;
+     }
+   return NULL;
+}
+
+static void
+_load(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   char *text;
+   if (!wd) return;
+   if (!wd->file)
+     {
+        elm_entry_entry_set(obj, "");
+        return;
+     }
+   switch (wd->format)
+     {
+      case ELM_TEXT_FORMAT_PLAIN_UTF8:
+         text = _load_plain(wd->file);
+         break;
+      case ELM_TEXT_FORMAT_MARKUP_UTF8:
+         text = _load_file(wd->file);
+         break;
+      default:
+         text = NULL;
+         break;
+     }
+   if (text)
+     {
+        elm_entry_entry_set(obj, text);
+        free(text);
+     }
+   else
+     elm_entry_entry_set(obj, "");
+}
+
+static void
+_save_markup_utf8(const char *file, const char *text)
+{
+   FILE *f;
+
+   if ((!text) || (!text[0]))
+     {
+        ecore_file_unlink(file);
+        return;
+     }
+   f = fopen(file, "wb");
+   if (!f)
+     {
+        // FIXME: report a write error
+        return;
+     }
+   fputs(text, f); // FIXME: catch error
+   fclose(f);
+}
+
+static void
+_save_plain_utf8(const char *file, const char *text)
+{
+   char *text2;
+
+   text2 = elm_entry_markup_to_utf8(text);
+   if (!text2)
+     return;
+   _save_markup_utf8(file, text2);
+   free(text2);
+}
+
+static void
+_save(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (!wd->file) return;
+   switch (wd->format)
+     {
+      case ELM_TEXT_FORMAT_PLAIN_UTF8:
+       _save_plain_utf8(wd->file, elm_entry_entry_get(obj));
+       break;
+      case ELM_TEXT_FORMAT_MARKUP_UTF8:
+       _save_markup_utf8(wd->file, elm_entry_entry_get(obj));
+       break;
+      default:
+       break;
+     }
+}
+
+static Eina_Bool
+_delay_write(void *data)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return ECORE_CALLBACK_CANCEL;
+   _save(data);
+   wd->delay_write = NULL;
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_del_pre_hook(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->delay_write)
+     {
+        ecore_timer_del(wd->delay_write);
+        wd->delay_write = NULL;
+        if (wd->autosave) _save(obj);
+     }
+}
+
 static void
 _del_hook(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    Elm_Entry_Context_Menu_Item *it;
    Elm_Entry_Item_Provider *ip;
+   Elm_Entry_Text_Filter *tf;
+
+   if (wd->file) eina_stringshare_del(wd->file);
 
    if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
    if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
@@ -276,6 +473,10 @@ _del_hook(Evas_Object *obj)
      {
         free(ip);
      }
+   EINA_LIST_FREE(wd->text_filters, tf)
+     {
+        free(tf);
+     }
    free(wd);
 }
 
@@ -290,8 +491,11 @@ _theme_hook(Evas_Object *obj)
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
    eina_stringshare_del(t);
+   if (elm_widget_disabled_get(obj))
+      edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
+   edje_object_message_signal_process(wd->ent);
    edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
-   edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
+   edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
    edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
    edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable);
 
@@ -331,7 +535,6 @@ _elm_win_recalc_job(void *data)
    wd->deferred_recalc_job = NULL;
    evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
    resh = 0;
-   minminw = 0;
    edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
    minminw = minw;
@@ -351,7 +554,7 @@ _sizing_eval(Evas_Object *obj)
    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
    Evas_Coord resw, resh;
    if (!wd) return;
-   if (wd->linewrap || wd->char_linewrap)
+   if ((wd->linewrap) || (wd->char_linewrap))
      {
        evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
        if ((resw == wd->lastw) && (!wd->changed)) return;
@@ -390,62 +593,61 @@ _check_enable_returnkey(Evas_Object *obj)
 
    if (!wd->autoreturnkey) return;
 
-   if (_entry_length_get(obj) == 0) 
+   if (_entry_length_get(obj) == 0)
      {
-       ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
+        ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_TRUE);
      }
-   else 
+   else
      {
-       ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
+        ecore_imf_context_input_panel_key_disabled_set(ic, ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, ECORE_IMF_INPUT_PANEL_KEY_ENTER, EINA_FALSE);
      }
 }
 
-#ifdef HAVE_CONFORMANT_AUTOSCROLL
-static Evas_Object *
-_imp_region_get_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
-{
-   Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return NULL;
-   edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
-                                             &cx, &cy, &cw, &ch);
-   if (x) *x = cx;
-   if (y) *y = cy;
-   if (w) *w = cw;
-   if (h) *h = ch;
-   return NULL;
-}
-#endif
-
 static void
 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Object *top = elm_widget_top_get(obj);
+   Evas_Object *parent_obj = obj;
+   Evas_Object *above = NULL;
+
    if (!wd) return;
    if (!wd->editable) return;
    if (elm_widget_focus_get(obj))
      {
-       evas_object_focus_set(wd->ent, 1);
+       evas_object_focus_set(wd->ent, EINA_TRUE);
        edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
-
        if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
-       // start for cbhm
-       if (top) 
-       {
-//             ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
-       }
-       // end for cbhm
        evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
        _check_enable_returnkey(obj);
+
+          while (parent_obj)
+          {
+                  above = evas_object_above_get(parent_obj);
+                  if (above)
+                          evas_object_data_set(parent_obj, "raise", above);
+                  evas_object_raise(parent_obj);
+                  parent_obj = elm_widget_parent_get(parent_obj);
+          }
      }
    else
      {
        edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
-       edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", "");
-       evas_object_focus_set(wd->ent, 0);
+       evas_object_focus_set(wd->ent, EINA_FALSE);
        if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
        evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
+
+          while (parent_obj)
+          {
+                  above = evas_object_data_get(parent_obj, "raise");
+                  if (above)
+                          evas_object_stack_below(parent_obj, above);
+                  parent_obj = elm_widget_parent_get(parent_obj);
+          }
+          if ((wd->api) && (wd->api->obj_hidemenu))
+          {
+                  wd->api->obj_hidemenu(data);
+          }
      }
 }
 
@@ -465,12 +667,19 @@ _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *so
    edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
 }
 
-static void *
-_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))
+static void
+_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)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return NULL;
-   return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
+   edje_object_signal_callback_del_full(wd->ent, emission, source, func_cb,
+                                        data);
+}
+
+static void
+_on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h);
 }
 
 static void
@@ -510,7 +719,7 @@ _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
-   if (wd->linewrap || wd->char_linewrap)
+   if ((wd->linewrap) || (wd->char_linewrap))
      {
         _sizing_eval(data);
      }
@@ -537,12 +746,12 @@ static void
 _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
-   if (!wd) return; 
+   if (!wd) return;
    if (wd->hoversel) evas_object_hide(wd->hoversel);
    if (wd->selmode)
      {
         if (!wd->password)
-          edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
+          edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
      }
    elm_widget_scroll_freeze_pop(data);
    if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
@@ -550,6 +759,20 @@ _dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 }
 
 static void
+_selectall(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return;
+   wd->selmode = EINA_TRUE;
+   if (!wd->password)
+      edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
+   edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
+   edje_object_part_text_select_all(wd->ent, "elm.text");
+   //elm_widget_scroll_hold_push(data);
+   elm_object_scroll_freeze_pop(data);
+}
+
+static void
 _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
@@ -557,9 +780,10 @@ _select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
    wd->selmode = EINA_TRUE;
    edje_object_part_text_select_none(wd->ent, "elm.text");
    if (!wd->password)
-     edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
+     edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
    edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
-   elm_widget_scroll_hold_push(data);
+   elm_object_scroll_freeze_pop(data);
+   //elm_widget_scroll_hold_push(data);
 }
 
 static void
@@ -572,7 +796,7 @@ _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
      {
 #ifdef HAVE_ELEMENTARY_X
         wd->selection_asked = EINA_TRUE;
-       elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data);
+        elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL);
 #endif
      }
 }
@@ -597,7 +821,7 @@ _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 
    /* Store it */
    wd->selmode = EINA_FALSE;
-   edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+   edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
    edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
    elm_widget_scroll_hold_pop(data);
    _store_selection(ELM_SEL_CLIPBOARD, data);
@@ -610,12 +834,12 @@ _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
-   wd->selmode = EINA_FALSE;
-   edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
-   edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
+   //wd->selmode = EINA_FALSE;
+   //edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
+   //edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
    elm_widget_scroll_hold_pop(data);
    _store_selection(ELM_SEL_CLIPBOARD, data);
-//   edje_object_part_text_select_none(wd->ent, "elm.text");
+   //edje_object_part_text_select_none(wd->ent, "elm.text");
 }
 
 static void
@@ -624,7 +848,7 @@ _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
    wd->selmode = EINA_FALSE;
-   edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+   edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
    edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
    elm_widget_scroll_hold_pop(data);
    edje_object_part_text_select_none(wd->ent, "elm.text");
@@ -638,17 +862,28 @@ _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
 
    // start for cbhm
    ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
+   cnpwidgetdata = data;
    elm_cbhm_helper_init(obj);
    elm_cbhm_send_raw_data("show");
    // end for cbhm
 }
 
+// start for cbhm
+static void
+_cnpinit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return;
+   cnpwidgetdata = data;
+}
+// end for cbhm
+
+
 static void
 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
 {
    Elm_Entry_Context_Menu_Item *it = data;
    Evas_Object *obj2 = it->obj;
-
    if (it->func) it->func(it->data, obj2, NULL);
 }
 
@@ -660,13 +895,6 @@ _long_press(void *data)
    const Eina_List *l;
    const Elm_Entry_Context_Menu_Item *it;
    if (!wd) return ECORE_CALLBACK_CANCEL;
-
-   if (wd->longpress_timer)
-     {
-       ecore_timer_del(wd->longpress_timer);
-       wd->longpress_timer = NULL;
-     } 
-
    if ((wd->api) && (wd->api->obj_longpress))
      {
         wd->api->obj_longpress(data);
@@ -682,7 +910,7 @@ _long_press(void *data)
           (wd->ent, "context_menu_orientation");
         if ((context_menu_orientation) &&
             (!strcmp(context_menu_orientation, "horizontal")))
-          elm_hoversel_horizontal_set(wd->hoversel, 1);
+          elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
         elm_object_style_set(wd->hoversel, "entry");
         elm_widget_sub_object_add(data, wd->hoversel);
         elm_hoversel_label_set(wd->hoversel, "Text");
@@ -737,7 +965,7 @@ _long_press(void *data)
              evas_object_show(wd->hoversel);
              elm_hoversel_hover_begin(wd->hoversel);
           }
-        edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+        edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
         edje_object_part_text_select_abort(wd->ent, "elm.text");
      }
    wd->longpress_timer = NULL;
@@ -755,9 +983,11 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void
    if (ev->button != 1) return;
    //   if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
    if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
-   wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
+   wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
    wd->downx = ev->canvas.x;
    wd->downy = ev->canvas.y;
+
+   wd->long_pressed = EINA_FALSE;
 }
 
 static void
@@ -769,17 +999,19 @@ _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *
    if (ev->button != 1) return;
 
    if (!wd->double_clicked)
-   {
-          if ((wd->api) && (wd->api->obj_mouseup))
-                {
-               wd->api->obj_mouseup(data);
-                }
-   }
+     {
+        if ((wd->api) && (wd->api->obj_mouseup))
+          {
+             wd->api->obj_mouseup(data);
+          }
+     }
    if (wd->longpress_timer)
      {
        ecore_timer_del(wd->longpress_timer);
        wd->longpress_timer = NULL;
-     } 
+     }
+
+   elm_object_scroll_freeze_pop(data);
 }
 
 static void
@@ -840,8 +1072,11 @@ _getbase(Evas_Object *obj)
    if (!wd) return "base";
    if (wd->editable)
      {
-       if((wd->password)&&(wd->show_last_character)) return "custom-password"; 
-       else if(wd->password) return "base-password";
+        if (wd->password)
+          {
+             if (wd->show_last_character) return "custom-password";
+             else return "base-password";
+          }
        else
          {
             if (wd->single_line) return "base-single";
@@ -855,8 +1090,11 @@ _getbase(Evas_Object *obj)
      }
    else
      {
-       if((wd->password)&&(wd->show_last_character)) return "custom-password"; 
-       else if(wd->password) return "base-password";
+        if (wd->password)
+          {
+             if (wd->show_last_character) return "custom-password";
+             else return "base-password";
+          }
        else
          {
             if (wd->single_line) return "base-single-noedit";
@@ -871,181 +1109,6 @@ _getbase(Evas_Object *obj)
    return "base";
 }
 
-static char *
-_str_append(char *str, const char *txt, int *len, int *alloc)
-{
-   int txt_len = strlen(txt);
-
-   if (txt_len <= 0) return str;
-   if ((*len + txt_len) >= *alloc)
-     {
-       char *str2;
-       int alloc2;
-
-       alloc2 = *alloc + txt_len + 128;
-       str2 = realloc(str, alloc2);
-       if (!str2) return str;
-       *alloc = alloc2;
-       str = str2;
-     }
-   strcpy(str + *len, txt);
-   *len += txt_len;
-   return str;
-}
-
-/*FIXME: Sholud be implemented somewhere else, it really depends on the context
- * because some markups can be implemented otherwise according to style.
- * probably doing it in textblock and making it translate according to it's
- * style is correct. */
-static char *
-_strncpy(char* dest, const char* src, size_t count)
-{
-   if (!dest) 
-     {
-       ERR( "dest is NULL" );
-       return NULL;
-     }
-   if (!src) 
-     {
-       ERR( "src is NULL" );
-       return NULL;
-     }
-   if (count < 0)
-     {
-       ERR( "count is smaller than 0" );
-       return NULL;
-     }
-
-   return strncpy( dest, src, count );
-}
-
-static char *
-_mkup_to_text(const char *mkup)
-{
-   char *str = NULL;
-   int str_len = 0, str_alloc = 0;
-   char *s, *p;
-   char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
-
-   if (!mkup) return NULL;
-   s=p=NULL;
-   tag_start = tag_end = esc_start = esc_end = NULL;
-   p = (char *)mkup;
-   s = p;
-   for (;;)
-     {
-       if (((p!=NULL)&&(*p == 0)) ||
-           (tag_end) || (esc_end) ||
-           (tag_start) || (esc_start))
-         {
-            if (tag_end)
-              {
-                 char *ttag;
-
-                 ttag = malloc(tag_end - tag_start);
-                 if (ttag)
-                   {
-                      _strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
-                      ttag[tag_end - tag_start - 1] = 0;
-                      if (!strcmp(ttag, "br"))
-                        str = _str_append(str, "\n", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\n"))
-                        str = _str_append(str, "\n", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\\n"))
-                        str = _str_append(str, "\n", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\t"))
-                        str = _str_append(str, "\t", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\\t"))
-                        str = _str_append(str, "\t", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
-                        str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
-                      free(ttag);
-                   }
-                 tag_start = tag_end = NULL;
-              }
-            else if (esc_end)
-              {
-                 ts = malloc(esc_end - esc_start + 1);
-                 if (ts)
-                   {
-                      const char *esc;
-                      _strncpy(ts, esc_start, esc_end - esc_start);
-                      ts[esc_end - esc_start] = 0;
-                      esc = evas_textblock_escape_string_get(ts);
-                      if (esc)
-                        str = _str_append(str, esc, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                 esc_start = esc_end = NULL;
-              }
-            else if ((p!=NULL)&&(*p == 0))
-              {
-                 ts = malloc(p - s + 1);
-                 if (ts)
-                   {
-                      _strncpy(ts, s, p - s);
-                      ts[p - s] = 0;
-                      str = _str_append(str, ts, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                  break;
-              }
-         }
-       if ((p!=NULL)&&(*p == '<'))
-         {
-            if (!esc_start)
-              {
-                 tag_start = p;
-                 tag_end = NULL;
-                 ts = malloc(p - s + 1);
-                 if (ts)
-                   {
-                      _strncpy(ts, s, p - s);
-                      ts[p - s] = 0;
-                      str = _str_append(str, ts, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                 s = NULL;
-              }
-         }
-       else if ((p!=NULL)&&(*p == '>'))
-         {
-            if (tag_start)
-              {
-                 tag_end = p;
-                 s = p + 1;
-              }
-         }
-       else if ((p!=NULL)&&(*p == '&'))
-         {
-            if (!tag_start)
-              {
-                 esc_start = p;
-                 esc_end = NULL;
-                 ts = malloc(p - s + 1);
-                 if (ts)
-                   {
-                      _strncpy(ts, s, p - s);
-                      ts[p - s] = 0;
-                      str = _str_append(str, ts, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                 s = NULL;
-              }
-         }
-       else if ((p!=NULL)&&(*p == ';'))
-         {
-            if (esc_start)
-              {
-                 esc_end = p;
-                 s = p + 1;
-              }
-         }
-       p++;
-     }
-   return str;
-}
-
 static int
 _entry_length_get(Evas_Object *obj)
 {
@@ -1053,7 +1116,7 @@ _entry_length_get(Evas_Object *obj)
    const char *str = elm_entry_entry_get(obj);
    if (!str) return 0;
 
-   char *plain_str = _mkup_to_text(str);
+   char *plain_str = _elm_util_mkup_to_text(str);
    if (!plain_str) return 0;
 
    len = strlen(plain_str);
@@ -1062,41 +1125,6 @@ _entry_length_get(Evas_Object *obj)
    return len;
 }
 
-static char *
-_text_to_mkup(const char *text)
-{
-   char *str = NULL;
-   int str_len = 0, str_alloc = 0;
-   int ch, pos = 0, pos2 = 0;
-
-   if (!text) return NULL;
-   for (;;)
-     {
-       pos = pos2;
-        pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
-        if ((ch <= 0) || (pos2 <= 0)) break;
-       if (ch == '\n')
-          str = _str_append(str, "<br>", &str_len, &str_alloc);
-       else if (ch == '\t')
-          str = _str_append(str, "<\t>", &str_len, &str_alloc);
-       else if (ch == '<')
-          str = _str_append(str, "&lt;", &str_len, &str_alloc);
-       else if (ch == '>')
-          str = _str_append(str, "&gt;", &str_len, &str_alloc);
-       else if (ch == '&')
-          str = _str_append(str, "&amp;", &str_len, &str_alloc);
-       else
-         {
-            char tstr[16];
-
-            _strncpy(tstr, text + pos, pos2 - pos);
-            tstr[pos2 - pos] = 0;
-            str = _str_append(str, tstr, &str_len, &str_alloc);
-         }
-     }
-   return str;
-}
-
 static void
 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
 {
@@ -1106,8 +1134,48 @@ _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emiss
    _sizing_eval(data);
    if (wd->text) eina_stringshare_del(wd->text);
    wd->text = NULL;
-   _check_enable_returnkey(data);   
+   _check_enable_returnkey(data);
    evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
+   if (wd->delay_write)
+     {
+       ecore_timer_del(wd->delay_write);
+       wd->delay_write = NULL;
+     }
+   if ((!wd->autosave) || (!wd->file)) return;
+   wd->delay_write = ecore_timer_add(2.0, _delay_write, data);
+}
+
+static void
+_signal_handler_move_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   elm_object_scroll_freeze_push(data);
+
+   if ((wd->api) && (wd->api->obj_hidemenu))
+     {
+        wd->api->obj_hidemenu(data);
+     }
+}
+
+static void
+_signal_handler_move_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   elm_object_scroll_freeze_pop(data);
+
+   if (wd->have_selection)
+      _long_press(data);
+}
+
+static void
+_signal_selection_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+/*     
+   Widget_Data *wd = elm_widget_data_get(data);
+   Evas_Object *entry;
+   if (!wd) return;
+*/
+   _long_press(data);
 }
 
 static void
@@ -1140,13 +1208,26 @@ _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emi
 static void
 _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
 {
+   Evas_Coord cx, cy, cw, ch;
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
    wd->have_selection = EINA_TRUE;
    wd->selmode = EINA_TRUE;
    evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
    elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
-                  elm_entry_selection_get(data));
+                     elm_entry_selection_get(data));
+
+   edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
+   if (!wd->deferred_recalc_job)
+      elm_widget_show_region_set(data, cx, cy, cw, ch + elm_finger_size_get());
+   else
+     {
+        wd->deferred_cur = EINA_TRUE;
+        wd->cx = cx;
+        wd->cy = cy;
+        wd->cw = cw;
+        wd->ch = ch + elm_finger_size_get();
+     }
 }
 
 static void
@@ -1201,7 +1282,8 @@ _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char
        if ((top) && (elm_win_xwindow_get(top)))
          {
              wd->selection_asked = EINA_TRUE;
-             elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data);
+             elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data,
+                               NULL, NULL);
          }
 #endif
      }
@@ -1249,9 +1331,6 @@ _signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emis
        wd->cw = cw;
        wd->ch = ch;
      }
-#ifdef HAVE_CONFORMANT_AUTOSCROLL
-   evas_object_smart_callback_call(data, SIG_IMPREGION_CHANGED, NULL);
-#endif
 }
 
 static void
@@ -1351,10 +1430,15 @@ _signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission
    if (!wd) return;
    wd->double_clicked = EINA_FALSE;
    evas_object_smart_callback_call(data, SIG_PRESS, NULL);
+
+   if ((wd->api) && (wd->api->obj_hidemenu))
+     {
+        wd->api->obj_hidemenu(data);
+     }
 }
 
 static void
-_signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+_signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
@@ -1377,7 +1461,7 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
    Widget_Data *wd = elm_widget_data_get(data);
    Ecore_X_Event_Selection_Notify *ev = event;
    if (!wd) return ECORE_CALLBACK_PASS_ON;
-   if (!wd->selection_asked && !wd->drag_selection_asked)
+   if ((!wd->selection_asked) && (!wd->drag_selection_asked))
       return ECORE_CALLBACK_PASS_ON;
 
    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
@@ -1390,7 +1474,7 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
          {
             if (text_data->text)
               {
-                 char *txt = _text_to_mkup(text_data->text);
+                 char *txt = _elm_util_text_to_mkup(text_data->text);
 
                  if (txt)
                    {
@@ -1410,7 +1494,7 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
          {
             if (text_data->text)
               {
-                 char *txt = _text_to_mkup(text_data->text);
+                 char *txt = _elm_util_text_to_mkup(text_data->text);
 
                  if (txt)
                    {
@@ -1423,8 +1507,8 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
        wd->drag_selection_asked = EINA_FALSE;
 
         ecore_x_dnd_send_finished();
-
      }
+
    return ECORE_CALLBACK_PASS_ON;
 }
 
@@ -1434,8 +1518,8 @@ _event_selection_clear(void *data, int type __UNUSED__, void *event)
 /*
    Widget_Data *wd = elm_widget_data_get(data);
    Ecore_X_Event_Selection_Clear *ev = event;
-   if (!wd) return 1;
-   if (!wd->have_selection) return 1;
+   if (!wd) return ECORE_CALLBACK_PASS_ON;
+   if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
    if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
        (ev->selection == ECORE_X_SELECTION_PRIMARY))
      {
@@ -1443,26 +1527,30 @@ _event_selection_clear(void *data, int type __UNUSED__, void *event)
      }
    return 1;*/
 
-       // start for cbhm
+   // start for cbhm
    Evas_Object *top = elm_widget_top_get(data);
    Ecore_X_Event_Selection_Clear *ev = event;
 
    if (!top)
-          return ECORE_CALLBACK_PASS_ON;
+      return ECORE_CALLBACK_PASS_ON;
 
-       if (ev->selection != ECORE_X_SELECTION_SECONDARY)
-       {
-               return ECORE_CALLBACK_PASS_ON;
-       }
+   if (ev->selection != ECORE_X_SELECTION_SECONDARY)
+     {
+        return ECORE_CALLBACK_PASS_ON;
+     }
 
-       elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data);
-       // end for cbhm
+   if (cnpwidgetdata == data)
+     {
+        elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
+     }
+
+   // end for cbhm
    return ECORE_CALLBACK_PASS_ON;
 }
 
 
 static Eina_Bool
-_drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Drop_Data *drop)
+_drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Selection_Data *drop)
 {
    Widget_Data *wd;
    Eina_Bool rv;
@@ -1470,13 +1558,13 @@ _drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Drop_Data *drop)
    wd = elm_widget_data_get(obj);
 
    if (!wd) return EINA_FALSE;
-//printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
+   printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
 
    edje_object_part_text_cursor_copy(wd->ent, "elm.text",
                                      EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
    rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
                                           EDJE_CURSOR_MAIN,drop->x,drop->y);
-//   if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
+   if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
    elm_entry_entry_insert(obj, drop->data);
    edje_object_part_text_cursor_copy(wd->ent, "elm.text",
                                      EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
@@ -1492,17 +1580,32 @@ _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__,
    Evas_Object *o;
    Eina_List *l;
    Elm_Entry_Item_Provider *ip;
-   int ok = 0;
 
    EINA_LIST_FOREACH(wd->item_providers, l, ip)
      {
         o = ip->func(ip->data, data, item);
         if (o) return o;
      }
+   if (!strncmp(item, "file://", 7))
+     {
+        const char *fname = item + 7;
+       
+        o = evas_object_image_filled_add(evas_object_evas_get(data));
+        evas_object_image_file_set(o, fname, NULL);
+        if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE)
+          {
+             evas_object_show(o);
+          }
+        else
+          {
+             evas_object_del(o);
+             o = edje_object_add(evas_object_evas_get(data));
+             _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
+          }
+        return o;
+     }
    o = edje_object_add(evas_object_evas_get(data));
-   if (!strncmp(item, "emoticon/", 9))
-     ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
-   if (!ok)
+   if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data)))
      _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
    return o;
 }
@@ -1518,7 +1621,7 @@ _get_value_in_key_string(const char *oldstring, char *key, char **value)
      {
         starttag = curlocater;
         endtag = curlocater + strlen(key);
-        if (endtag == NULL || *endtag != '=') 
+        if (endtag == NULL || *endtag != '=')
           {
             foundflag = 0;
             return -1;
@@ -1526,7 +1629,7 @@ _get_value_in_key_string(const char *oldstring, char *key, char **value)
 
         firstindex = abs(oldstring - curlocater);
         firstindex += strlen(key)+1; // strlen("key") + strlen("=")
-        *value = (char*)oldstring + firstindex;
+        *value = (char*)(oldstring + firstindex);
 
         while (oldstring != starttag)
           {
@@ -1535,9 +1638,9 @@ _get_value_in_key_string(const char *oldstring, char *key, char **value)
                 foundflag = 0;
                 break;
               }
-            if (*starttag == '<') 
+            if (*starttag == '<')
               break;
-            else 
+            else
               starttag--;
             if (starttag == NULL) break;
           }
@@ -1549,16 +1652,16 @@ _get_value_in_key_string(const char *oldstring, char *key, char **value)
                 foundflag = 0;
                 break;
               }
-            if (*endtag == '>') 
+            if (*endtag == '>')
               break;
-            else 
+            else
               endtag++;
             if (endtag == NULL) break;
           }
 
-        if (foundflag != 0 && *starttag == '<' && *endtag == '>') 
+        if (foundflag != 0 && *starttag == '<' && *endtag == '>')
           foundflag = 1;
-        else 
+        else
           foundflag = 0;
      }
    else
@@ -1583,13 +1686,13 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int
    srcstring = eina_strbuf_string_get(srcbuf);
    curlocater = strstr(srcstring, key);
 
-   if (curlocater == NULL)
+   if (!curlocater || !srcstring)
      {
        insertflag = 1;
      }
    else
      {
-       do 
+       do
          {
            starttag = strchr(srcstring, '<');
            endtag = strchr(srcstring, '>');
@@ -1614,17 +1717,11 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int
              {
                replocater = curlocater + strlen(key) + 1;
 
-               while (*replocater == ' ' || *replocater == '=')
-                          {
+               while ((*replocater) && (*replocater != ' ') && (*replocater != '>'))
                  replocater++;
-                          }
-
-                while (*replocater != NULL && *replocater != ' ' && *replocater != '>')
-                  replocater++;
 
                if (replocater-curlocater > strlen(key)+1)
                  {
-                   replocater--;
                    eina_strbuf_append_n(diffbuf, curlocater, replocater-curlocater+1);
                  }
                else
@@ -1638,7 +1735,7 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int
          }
        else
          {
-           insertflag = 1; 
+           insertflag = 1;
          }
      }
 
@@ -1667,15 +1764,15 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf, char *key, const char *value, int
 
    if (repbuf) eina_strbuf_free(repbuf);
    if (diffbuf) eina_strbuf_free(diffbuf);
-  
-   return 0;           
+
+   return 0;
 }
 
 static int
 _stringshare_key_value_replace(const char **srcstring, char *key, const char *value, int deleteflag)
 {
-   Eina_Strbuf *sharebuf = NULL;   
-   
+   Eina_Strbuf *sharebuf = NULL;
+
    sharebuf = eina_strbuf_new();
    eina_strbuf_append(sharebuf, *srcstring);
    _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
@@ -1714,7 +1811,7 @@ _reverse_ellipsis_entry(Evas_Object *obj)
    Widget_Data *wd = elm_widget_data_get(obj);
    int cur_fontsize = 0;
    Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
-   char **kvalue = NULL;
+   char *kvalue = NULL;
    const char *minfont, *deffont, *maxfont;
    const char *ellipsis_string = "...";
    int minfontsize, maxfontsize, minshowcount;
@@ -1734,7 +1831,7 @@ _reverse_ellipsis_entry(Evas_Object *obj)
 
    if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
      {
-       if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
+       if (kvalue != NULL) cur_fontsize = atoi(kvalue);
      }
 
    txtbuf = eina_strbuf_new();
@@ -1749,7 +1846,7 @@ _reverse_ellipsis_entry(Evas_Object *obj)
    if (_is_width_over(obj) != 1)
      {
        int rev_fontsize = cur_fontsize;
-  
+
        do {
            rev_fontsize++;
            if (rev_fontsize > atoi(deffont))
@@ -1800,7 +1897,7 @@ _ellipsis_entry_to_width(Evas_Object *obj)
    Widget_Data *wd = elm_widget_data_get(obj);
    int cur_fontsize = 0, len, jumpcount;
    Eina_Strbuf *fontbuf = NULL, *txtbuf = NULL;
-   char **kvalue = NULL;
+   char *kvalue = NULL;
    const char *minfont, *deffont, *maxfont;
    const char *ellipsis_string = "...";
    int minfontsize, maxfontsize, minshowcount;
@@ -1822,7 +1919,7 @@ _ellipsis_entry_to_width(Evas_Object *obj)
 
    if (_get_value_in_key_string(edje_object_part_text_get(wd->ent, "elm.text"), "font_size", &kvalue) == 0)
      {
-       if (*kvalue != NULL) cur_fontsize = atoi((char*)kvalue);
+       if (kvalue != NULL) cur_fontsize = atoi(kvalue);
      }
 
    txtbuf = eina_strbuf_new();
@@ -1851,12 +1948,12 @@ _ellipsis_entry_to_width(Evas_Object *obj)
        else
          {
            len = _entry_length_get(obj);
-           cur_str = edje_object_part_text_get(wd->ent, "elm.text");
+           cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
            cur_len = strlen(cur_str);
            tagend = 0;
            for (i = 0; i < len; i++)
              {
-               if(cur_str[i] == '>' && cur_str[i+1] != NULL && 
+               if(cur_str[i] == '>' && cur_str[i+1] != '\0' &&
                   cur_str[i+1] != '<')
                  {
                    tagend = i;
@@ -1866,7 +1963,7 @@ _ellipsis_entry_to_width(Evas_Object *obj)
            jumpcount = 0;
            while (jumpcount < len-strlen(ellipsis_string))
              {
-               cur_str = edje_object_part_text_get(wd->ent, "elm.text");
+               cur_str = (char*)edje_object_part_text_get(wd->ent, "elm.text");
 
                if (txtbuf != NULL)
                  {
@@ -1880,9 +1977,9 @@ _ellipsis_entry_to_width(Evas_Object *obj)
                edje_object_part_text_set(wd->ent, "elm.text", eina_strbuf_string_get(txtbuf));
                edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
 
-               if (_is_width_over(obj)) 
+               if (_is_width_over(obj))
                  jumpcount++;
-               else 
+               else
                  break;
              }
          }
@@ -1893,40 +1990,59 @@ _ellipsis_entry_to_width(Evas_Object *obj)
    _sizing_eval(obj);
 }
 
-static int _textinput_control_function(void *data,void *input_data)
+static Eina_Bool *_textinput_control_function(void *data,void *input_data)
 {
-   /*calculate character count*/
+   /* calculate character count */
    Evas_Object *entry = (Evas_Object *)data;
    Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
    char buf[10]="\0";
    size_t byte_len;
    size_t insert_text_len=0;
-   char *text = edje_object_part_text_get(wd->ent, "elm.text");
-   char *insert_text;  
+   char *text = (char*)edje_object_part_text_get(wd->ent, "elm.text");
+   char *insert_text;
    size_t remain_bytes;
-   if(text!=NULL)
+   if (text != NULL)
      {
-       byte_len = strlen(text);/*no of bytes*/
-       remain_bytes = wd->max_no_of_bytes-byte_len;
-       sprintf(buf,"%d",remain_bytes);
-       edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
-       if(input_data)
-         {
-           insert_text =  (char *)input_data;
-           insert_text_len = strlen(insert_text);
-           if(remain_bytes<insert_text_len)
-             {
-               evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
-               return EINA_TRUE;
-             }
-           if(byte_len>=wd->max_no_of_bytes)
-             {
-               evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
-               return EINA_TRUE;
-             }
-         }
+        byte_len = strlen(text); /* no of bytes */
+        remain_bytes = wd->max_no_of_bytes - byte_len;
+        sprintf(buf,"%d",remain_bytes);
+        //edje_object_part_text_set(wd->ent, "elm_entry_remain_byte_count", buf);
+        if (input_data)
+          {
+             insert_text =  (char *)input_data;
+             insert_text_len = strlen(insert_text);
+             if (remain_bytes < insert_text_len)
+               {
+                  evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
+                  return EINA_TRUE;
+               }
+             if (byte_len >= wd->max_no_of_bytes)
+               {
+                  evas_object_smart_callback_call(entry, "maxlength,reached", NULL);
+                  return EINA_TRUE;
+               }
+          }
+     }
+   return EINA_FALSE;
+}
+
+
+static void
+_text_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, Edje_Text_Filter_Type type, char **text)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   Eina_List *l;
+   Elm_Entry_Text_Filter *tf;
+
+   if (type == EDJE_TEXT_FILTER_FORMAT)
+     return;
+
+   EINA_LIST_FOREACH(wd->text_filters, l, tf)
+     {
+        tf->func(tf->data, data, text);
+        if (!*text)
+           break;
      }
-   return EINA_FALSE;  
 }
 
 /**
@@ -1944,8 +2060,11 @@ elm_entry_add(Evas_Object *parent)
    Evas *e;
    Widget_Data *wd;
 
+   EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+
    wd = ELM_NEW(Widget_Data);
    e = evas_object_evas_get(parent);
+   if (!e) return NULL;
    wd->bgcolor = EINA_FALSE;
    wd->bg = evas_object_rectangle_add(e);
    evas_object_color_set(wd->bg, 0, 0, 0, 0);
@@ -1956,15 +2075,16 @@ elm_entry_add(Evas_Object *parent)
    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
    elm_widget_data_set(obj, wd);
    elm_widget_del_hook_set(obj, _del_hook);
+   elm_widget_del_pre_hook_set(obj, _del_pre_hook);
    elm_widget_theme_hook_set(obj, _theme_hook);
    elm_widget_disable_hook_set(obj, _disable_hook);
    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
+   elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
-   elm_widget_can_focus_set(obj, 1);
-#ifdef HAVE_CONFORMANT_AUTOSCROLL
-   elm_widget_imp_region_get_hook_set(obj, _imp_region_get_hook, NULL);
-#endif
+   elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
+   elm_widget_can_focus_set(obj, EINA_TRUE);
+   elm_widget_highlight_ignore_set(obj, EINA_TRUE);
 
    wd->linewrap     = EINA_TRUE;
    wd->ellipsis     = EINA_FALSE;
@@ -1972,11 +2092,14 @@ elm_entry_add(Evas_Object *parent)
    wd->editable     = EINA_TRUE;
    wd->disabled     = EINA_FALSE;
    wd->context_menu = EINA_TRUE;
+   wd->autosave     = EINA_TRUE;
+   wd->autoperiod   = EINA_TRUE;
 
    wd->ellipsis_threshold = 0;
 
    wd->ent = edje_object_add(e);
    edje_object_item_provider_set(wd->ent, _get_item, obj);
+   edje_object_text_insert_filter_callback_add(wd->ent,"elm.text", _text_filter, obj);
    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
@@ -1989,8 +2112,14 @@ elm_entry_add(Evas_Object *parent)
    _elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
    edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
                                    _signal_entry_changed, obj);
+   edje_object_signal_callback_add(wd->ent, "handler,move,start", "elm.text",
+                                   _signal_handler_move_start, obj);
+   edje_object_signal_callback_add(wd->ent, "handler,move,end", "elm.text",
+                                   _signal_handler_move_end, obj);
    edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
                                    _signal_selection_start, obj);
+   edje_object_signal_callback_add(wd->ent, "selection,end", "elm.text",
+                                   _signal_selection_end, obj);
    edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
                                    _signal_selection_changed, obj);
    edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
@@ -2017,8 +2146,8 @@ elm_entry_add(Evas_Object *parent)
                                    _signal_key_enter, obj);
    edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
                                    _signal_mouse_down, obj);
-   edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
-                                   _signal_mouse_up, obj);
+   edje_object_signal_callback_add(wd->ent, "mouse,clicked,1", "elm.text",
+                                   _signal_mouse_clicked, obj);
    edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
                                    _signal_mouse_double, obj);
    edje_object_part_text_set(wd->ent, "elm.text", "");
@@ -2065,7 +2194,7 @@ EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extensi
    ext_mod->cut = _cut;
    ext_mod->paste = _paste;
    ext_mod->select = _select;
-   ext_mod->selectall = NULL; /* to be implemented*/
+   ext_mod->selectall = _selectall;
    ext_mod->ent = wd->ent;
    ext_mod->items = wd->items;
    ext_mod->longpress_timer = wd->longpress_timer;
@@ -2073,6 +2202,7 @@ EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extensi
    ext_mod->have_selection = wd->have_selection;
    ext_mod->password = wd->password;
    ext_mod->selmode = wd->selmode;
+   ext_mod->cnpinit = _cnpinit;
    ext_mod->context_menu = wd->context_menu;
 }
 
@@ -2101,7 +2231,7 @@ elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
    t = eina_stringshare_add(elm_entry_entry_get(obj));
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
-   edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
+   edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
    edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
    ic = elm_entry_imf_context_get(obj);
    if (ic)
@@ -2146,9 +2276,8 @@ elm_entry_maximum_bytes_set(Evas_Object *obj, int max_no_of_bytes)
    Widget_Data *wd = elm_widget_data_get(obj);
 
    wd->max_no_of_bytes = max_no_of_bytes;
-   edje_object_signal_emit(wd->ent, "elm,state,remain,bytes,show", "elm");
    edje_object_part_textinput_callback_set(wd->ent, "elm.text", _textinput_control_function,obj);
- }
+}
 
 
 /**
@@ -2170,10 +2299,11 @@ elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
    if (!wd) return;
    if (wd->password == password) return;
    wd->password = password;
-   wd->show_last_character = EINA_FALSE;
    wd->single_line = EINA_TRUE;
    wd->linewrap = EINA_FALSE;
    wd->char_linewrap = EINA_FALSE;
+   if (_elm_config->password_show_last_character)
+     wd->show_last_character = EINA_TRUE;
    t = eina_stringshare_add(elm_entry_entry_get(obj));
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
@@ -2181,54 +2311,20 @@ elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
    if (password)
      {
         if (wd->autoperiod)
-          {
-             elm_entry_autoperiod_set(obj, EINA_FALSE);
-          }
+           elm_entry_autoperiod_set(obj, EINA_FALSE);
 
-        if (wd->autocapitalize)
-          {
-             elm_entry_autocapitalization_set(obj, EINA_FALSE);
-          }
+        if (wd->autocapital)
+           elm_entry_autocapitalization_set(obj, EINA_FALSE);
      }
 
    ic = elm_entry_imf_context_get(obj);
    if (ic)
-     {
-       ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
-     }
+      ecore_imf_context_input_panel_layout_set(ic, wd->input_panel_layout);
 
    eina_stringshare_del(t);
    _sizing_eval(obj);
 }
 
-/**
- * This set's the entry in password mode with out masking the last character entered by user,
- * and later masking the character after 2 seconds.
- * @param obj The entry object
- * @param show_last_character The show_last_character flag (1 for "password mode along with showing last character" 
- * 0 for default).
- *
- * @ingroup Entry
- */
-EAPI void         
-elm_entry_password_show_last_character_set(Evas_Object *obj, Eina_Bool show_last_character)
-{
-   Widget_Data *wd = elm_widget_data_get(obj);
-   const char *t;
-   if (!wd) return;
-   if ((wd->password == show_last_character)&&(wd->show_last_character ==show_last_character))  return;
-   wd->show_last_character = show_last_character;
-   wd->password = show_last_character;
-   wd->single_line = EINA_TRUE;
-   wd->linewrap = EINA_FALSE;
-   wd->char_linewrap = EINA_FALSE;
-   t = eina_stringshare_add(elm_entry_entry_get(obj));
-    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
-   elm_entry_entry_set(obj, t);
-   eina_stringshare_del(t);
-   _sizing_eval(obj);
-}
 
 /**
  * This returns whether password mode is enabled.
@@ -2296,6 +2392,10 @@ elm_entry_entry_get(const Evas_Object *obj)
    Widget_Data *wd = elm_widget_data_get(obj);
    const char *text;
    if (!wd) return NULL;
+
+   if ((wd->text)&&(wd->password))
+   return elm_entry_markup_to_utf8(wd->text);
+
    if (wd->text) return wd->text;
    text = edje_object_part_text_get(wd->ent, "elm.text");
    if (!text)
@@ -2304,6 +2404,7 @@ elm_entry_entry_get(const Evas_Object *obj)
        return NULL;
      }
    eina_stringshare_replace(&wd->text, text);
+   if(wd->password)return elm_entry_markup_to_utf8(wd->text);
    return wd->text;
 }
 
@@ -2325,8 +2426,13 @@ elm_entry_selection_get(const Evas_Object *obj)
 }
 
 /**
- * This inserts text in @p entry at the beginning of the entry
- * object.
+ * This inserts text in @p entry where the current cursor position.
+ * 
+ * This inserts text at the cursor position is as if it was typed 
+ * by the user (note this also allows markup which a user
+ * can't just "type" as it would be converted to escaped text, so this
+ * call can be used to insert things like emoticon items or bold push/pop
+ * tags, other font and color change tags etc.)
  *
  * @param obj The entry object
  * @param entry The text to insert
@@ -2340,6 +2446,10 @@ elm_entry_entry_insert(Evas_Object *obj, const char *entry)
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    edje_object_part_text_insert(wd->ent, "elm.text", entry);
+   // start for cbhm
+   if (cnpwidgetdata == obj)
+      ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
+   // end for cbhm
    wd->changed = EINA_TRUE;
    _sizing_eval(obj);
 }
@@ -2502,7 +2612,7 @@ elm_entry_select_none(Evas_Object *obj)
    if (wd->selmode)
      {
        wd->selmode = EINA_FALSE;
-       edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+       edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
        edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
      }
    wd->have_selection = EINA_FALSE;
@@ -2525,7 +2635,7 @@ elm_entry_select_all(Evas_Object *obj)
    if (wd->selmode)
      {
        wd->selmode = EINA_FALSE;
-       edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+       edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_FALSE);
        edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
      }
    wd->have_selection = EINA_TRUE;
@@ -2907,7 +3017,7 @@ elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *dat
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   if (!func) return;
+   EINA_SAFETY_ON_NULL_RETURN(func);
    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
    if (!ip) return;
    ip->func = func;
@@ -2933,7 +3043,7 @@ elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *da
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   if (!func) return;
+   EINA_SAFETY_ON_NULL_RETURN(func);
    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
    if (!ip) return;
    ip->func = func;
@@ -2961,7 +3071,7 @@ elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *dat
    Eina_List *l;
    Elm_Entry_Item_Provider *ip;
    if (!wd) return;
-   if (!func) return;
+   EINA_SAFETY_ON_NULL_RETURN(func);
    EINA_LIST_FOREACH(wd->item_providers, l, ip)
      {
         if ((ip->func == func) && (ip->data == data))
@@ -2974,6 +3084,106 @@ elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *dat
 }
 
 /**
+ * Append a filter function for text inserted in the entry
+ *
+ * Append the given callback to the list. This functions will be called
+ * whenever any text is inserted into the entry, with the text to be inserted
+ * as a parameter. The callback function is free to alter the text in any way
+ * it wants, but it must remember to free the given pointer and update it.
+ * If the new text is to be discarded, the function can free it and set it text
+ * parameter to NULL. This will also prevent any following filters from being
+ * called.
+ *
+ * @param obj The entry object
+ * @param func The function to use as text filter
+ * @param data User data to pass to @p func
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
+{
+   Widget_Data *wd;
+   Elm_Entry_Text_Filter *tf;
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
+   wd = elm_widget_data_get(obj);
+
+   EINA_SAFETY_ON_NULL_RETURN(func);
+
+   tf = ELM_NEW(Elm_Entry_Text_Filter);
+   if (!tf) return;
+   tf->func = func;
+   tf->data = data;
+   wd->text_filters = eina_list_append(wd->text_filters, tf);
+}
+
+/**
+ * Prepend a filter function for text insdrted in the entry
+ *
+ * Prepend the given callback to the list. See elm_entry_text_filter_append()
+ * for more information
+ *
+ * @param obj The entry object
+ * @param func The function to use as text filter
+ * @param data User data to pass to @p func
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
+{
+   Widget_Data *wd;
+   Elm_Entry_Text_Filter *tf;
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
+   wd = elm_widget_data_get(obj);
+
+   EINA_SAFETY_ON_NULL_RETURN(func);
+
+   tf = ELM_NEW(Elm_Entry_Text_Filter);
+   if (!tf) return;
+   tf->func = func;
+   tf->data = data;
+   wd->text_filters = eina_list_prepend(wd->text_filters, tf);
+}
+
+/**
+ * Remove a filter from the list
+ *
+ * Removes the given callback from the filter list. See elm_entry_text_filter_append()
+ * for more information.
+ *
+ * @param obj The entry object
+ * @param func The filter function to remove
+ * @param data The user data passed when adding the function
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
+{
+   Widget_Data *wd;
+   Eina_List *l;
+   Elm_Entry_Text_Filter *tf;
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
+   wd = elm_widget_data_get(obj);
+
+   EINA_SAFETY_ON_NULL_RETURN(func);
+
+   EINA_LIST_FOREACH(wd->text_filters, l, tf)
+     {
+        if ((tf->func == func) && (tf->data == data))
+          {
+             wd->text_filters = eina_list_remove_list(wd->text_filters, l);
+             free(tf);
+             return;
+          }
+     }
+}
+
+/**
  * This converts a markup (HTML-like) string into UTF-8.
  *
  * @param s The string (in markup) to be converted
@@ -2984,7 +3194,7 @@ elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *dat
 EAPI char *
 elm_entry_markup_to_utf8(const char *s)
 {
-   char *ss = _mkup_to_text(s);
+   char *ss = _elm_util_mkup_to_text(s);
    if (!ss) ss = strdup("");
    return ss;
 }
@@ -3000,7 +3210,7 @@ elm_entry_markup_to_utf8(const char *s)
 EAPI char *
 elm_entry_utf8_to_markup(const char *s)
 {
-   char *ss = _text_to_mkup(s);
+   char *ss = _elm_util_text_to_mkup(s);
    if (!ss) ss = strdup("");
    return ss;
 }
@@ -3018,7 +3228,7 @@ EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd || !wd->ent) return NULL;
-  
+
    return edje_object_part_text_imf_context_get(wd->ent, "elm.text");
 }
 
@@ -3030,7 +3240,7 @@ EAPI Ecore_IMF_Context *elm_entry_imf_context_get(Evas_Object *obj)
  *
  * @ingroup Entry
  */
-EAPI void 
+EAPI void
 elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
@@ -3049,7 +3259,7 @@ elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on)
  *
  * @ingroup Entry
  */
-EAPI void 
+EAPI void
 elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
@@ -3057,11 +3267,15 @@ elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
    if (!wd) return;
 
    if (wd->password)
-       wd->autocapitalize = EINA_FALSE;
+       wd->autocapital = EINA_FALSE;
    else
-       wd->autocapitalize = autocap;
+       wd->autocapital = autocap;
 
-   edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize);
+   if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
+       wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
+       wd->autocapital = EINA_FALSE;
+
+   edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapital);
 }
 
 /**
@@ -3072,7 +3286,7 @@ elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap)
  *
  * @ingroup Entry
  */
-EAPI void 
+EAPI void
 elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
@@ -3084,6 +3298,10 @@ elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod)
    else
        wd->autoperiod = autoperiod;
 
+   if (wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_URL ||
+       wd->input_panel_layout == ELM_INPUT_PANEL_LAYOUT_EMAIL)
+       wd->autoperiod = EINA_FALSE;
+
    edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod);
 }
 
@@ -3187,7 +3405,6 @@ elm_entry_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsig
    eina_stringshare_del(t);
 }
 
-
 /**
  * Set background color of the entry
  *
@@ -3231,6 +3448,270 @@ elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
 }
 
 /**
+ * Filter inserted text based on user defined character and byte limits
+ *
+ * Add this filter to an entry to limit the characters that it will accept
+ * based the the contents of the provided Elm_Entry_Filter_Limit_Size.
+ * The funtion works on the UTF-8 representation of the string, converting
+ * it from the set markup, thus not accounting for any format in it.
+ *
+ * The user must create an Elm_Entry_Filter_Limit_Size structure and pass
+ * it as data when setting the filter. In it it's possible to set limits
+ * by character count or bytes (any of them is disabled if 0), and both can
+ * be set at the same time. In that case, it first checks for characters,
+ * then bytes.
+ *
+ * The function will cut the inserted text in order to allow only the first
+ * number of characters that are still allowed. The cut is made in
+ * characters, even when limiting by bytes, in order to always contain
+ * valid ones and avoid half unicode characters making it in.
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text)
+{
+   Elm_Entry_Filter_Limit_Size *lim = data;
+   char *current;
+   int len, newlen;
+   const char *(*text_get)(const Evas_Object *);
+   const char *widget_type;
+
+   EINA_SAFETY_ON_NULL_RETURN(data);
+   EINA_SAFETY_ON_NULL_RETURN(entry);
+   EINA_SAFETY_ON_NULL_RETURN(text);
+
+   /* hack. I don't want to copy the entire function to work with
+    * scrolled_entry */
+   widget_type = elm_widget_type_get(entry);
+   if (!strcmp(widget_type, "entry"))
+      text_get = elm_entry_entry_get;
+   else if (!strcmp(widget_type, "scrolled_entry"))
+      text_get = elm_scrolled_entry_entry_get;
+   else /* huh? */
+      return;
+
+   current = elm_entry_markup_to_utf8(text_get(entry));
+
+   if (lim->max_char_count > 0)
+     {
+        int cut;
+        len = evas_string_char_len_get(current);
+        if (len >= lim->max_char_count)
+          {
+             free(*text);
+             free(current);
+             *text = NULL;
+             return;
+          }
+        newlen = evas_string_char_len_get(*text);
+        cut = strlen(*text);
+        while ((len + newlen) > lim->max_char_count)
+          {
+             cut = evas_string_char_prev_get(*text, cut, NULL);
+             newlen--;
+          }
+        (*text)[cut] = 0;
+     }
+
+   if (lim->max_byte_count > 0)
+     {
+        len = strlen(current);
+        if (len >= lim->max_byte_count)
+          {
+             free(*text);
+             free(current);
+             *text = NULL;
+             return;
+          }
+        newlen = strlen(*text);
+        while ((len + newlen) > lim->max_byte_count)
+          {
+             int p = evas_string_char_prev_get(*text, newlen, NULL);
+             newlen -= (newlen - p);
+          }
+        if (newlen)
+           (*text)[newlen] = 0;
+        else
+          {
+             free(*text);
+             *text = NULL;
+          }
+     }
+   free(current);
+}
+
+/**
+ * Filter inserted text based on accepted or rejected sets of characters
+ *
+ * Add this filter to an entry to restrict the set of accepted characters
+ * based on the sets in the provided Elm_Entry_Filter_Accept_Set.
+ * This structure contains both accepted and rejected sets, but they are
+ * mutually exclusive. If accepted is set, it will be used, otherwise it
+ * goes on to the rejected set.
+ */
+EAPI void
+elm_entry_filter_accept_set(void *data, Evas_Object *entry __UNUSED__, char **text)
+{
+   Elm_Entry_Filter_Accept_Set *as = data;
+   const char *set;
+   char *insert;
+   Eina_Bool goes_in;
+   int read_idx, last_read_idx = 0, read_char;
+
+   EINA_SAFETY_ON_NULL_RETURN(data);
+   EINA_SAFETY_ON_NULL_RETURN(text);
+
+   if ((!as->accepted) && (!as->rejected))
+      return;
+
+   if (as->accepted)
+     {
+        set = as->accepted;
+        goes_in = EINA_TRUE;
+     }
+   else
+     {
+        set = as->rejected;
+        goes_in = EINA_FALSE;
+     }
+
+   insert = *text;
+   read_idx = evas_string_char_next_get(*text, 0, &read_char);
+   while (read_char)
+     {
+        int cmp_idx, cmp_char;
+        Eina_Bool in_set = EINA_FALSE;
+
+        cmp_idx = evas_string_char_next_get(set, 0, &cmp_char);
+        while (cmp_char)
+          {
+             if (read_char == cmp_char)
+               {
+                  in_set = EINA_TRUE;
+                  break;
+               }
+             cmp_idx = evas_string_char_next_get(set, cmp_idx, &cmp_char);
+          }
+        if (in_set == goes_in)
+          {
+             int size = read_idx - last_read_idx;
+             const char *src = (*text) + last_read_idx;
+             if (src != insert)
+                memcpy(insert, *text + last_read_idx, size);
+             insert += size;
+          }
+        last_read_idx = read_idx;
+        read_idx = evas_string_char_next_get(*text, read_idx, &read_char);
+     }
+   *insert = 0;
+}
+
+/**
+ * This sets the file (and implicitly loads it) for the text to display and
+ * then edit. All changes are written back to the file after a short delay if
+ * the entry object is set to autosave.
+ *
+ * @param obj The entry object
+ * @param file The path to the file to load and save
+ * @param format The file format
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->delay_write)
+     {
+       ecore_timer_del(wd->delay_write);
+       wd->delay_write = NULL;
+     }
+   if (wd->autosave) _save(obj);
+   eina_stringshare_replace(&wd->file, file);
+   wd->format = format;
+   _load(obj);
+}
+
+/**
+ * Gets the file to load and save and the file format
+ *
+ * @param obj The entry object
+ * @param file The path to the file to load and save
+ * @param format The file format
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (file) *file = wd->file;
+   if (format) *format = wd->format;
+}
+
+/**
+ * This function writes any changes made to the file set with
+ * elm_entry_file_set()
+ *
+ * @param obj The entry object
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_file_save(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->delay_write)
+     {
+       ecore_timer_del(wd->delay_write);
+       wd->delay_write = NULL;
+     }
+   _save(obj);
+   wd->delay_write = ecore_timer_add(2.0, _delay_write, obj);
+}
+
+/**
+ * This sets the entry object to 'autosave' the loaded text file or not.
+ *
+ * @param obj The entry object
+ * @param autosave Autosave the loaded file or not
+ *
+ * @ingroup Entry
+ */
+EAPI void
+elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->autosave = !!autosave;
+}
+
+/**
+ * This gets the entry object's 'autosave' status.
+ *
+ * @param obj The entry object
+ * @return Autosave the loaded file or not
+ *
+ * @ingroup Entry
+ */
+EAPI Eina_Bool
+elm_entry_autosave_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->autosave;
+}
+
+/**
  * This sets the attribute to show the input panel automatically.
  *
  * @param obj The entry object
@@ -3263,13 +3744,11 @@ elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   
+
    Ecore_IMF_Context *ic = elm_entry_imf_context_get(obj);
    if (!ic) return;
 
    wd->input_panel_layout = layout;
-   
+
    ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
 }
-
-/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/