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;
+typedef struct _Elm_Entry_Markup_Filter Elm_Entry_Markup_Filter;
struct _Widget_Data
{
Eina_List *items;
Eina_List *item_providers;
Eina_List *text_filters;
+ Eina_List *markup_filters;
Ecore_Job *hovdeljob;
Mod_Api *api; // module api if supplied
int cursor_pos;
void *data;
};
-struct _Elm_Entry_Text_Filter
+struct _Elm_Entry_Markup_Filter
{
Elm_Entry_Filter_Cb func;
void *data;
return ECORE_CALLBACK_CANCEL;
}
-static Elm_Entry_Text_Filter *
+static Elm_Entry_Markup_Filter *
_filter_new(Elm_Entry_Filter_Cb func, void *data)
{
- Elm_Entry_Text_Filter *tf = ELM_NEW(Elm_Entry_Text_Filter);
+ Elm_Entry_Markup_Filter *tf = ELM_NEW(Elm_Entry_Markup_Filter);
if (!tf) return NULL;
tf->func = func;
}
static void
-_filter_free(Elm_Entry_Text_Filter *tf)
+_filter_free(Elm_Entry_Markup_Filter *tf)
{
if (tf->func == elm_entry_filter_limit_size)
{
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Entry_Context_Menu_Item *it;
Elm_Entry_Item_Provider *ip;
- Elm_Entry_Text_Filter *tf;
+ Elm_Entry_Markup_Filter *tf;
evas_event_freeze(evas_object_evas_get(obj));
{
_filter_free(tf);
}
+ EINA_LIST_FREE(wd->markup_filters, tf)
+ {
+ _filter_free(tf);
+ }
if (wd->delay_write) ecore_timer_del(wd->delay_write);
free(wd);
{
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
- Elm_Entry_Text_Filter *tf;
+ Elm_Entry_Markup_Filter *tf;
if (type == EDJE_TEXT_FILTER_FORMAT)
return;
}
}
+static void
+_markup_filter(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, char **text)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ Eina_List *l;
+ Elm_Entry_Markup_Filter *tf;
+
+ EINA_LIST_FOREACH(wd->markup_filters, l, tf)
+ {
+ tf->func(tf->data, data, text);
+ if (!*text)
+ break;
+ }
+}
+
/* This function is used to insert text by chunks in jobs */
static Eina_Bool
_text_append_idler(void *data)
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);
+ edje_object_markup_filter_callback_add(wd->ent,"elm.text", _markup_filter, obj);
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
_mouse_down, obj);
elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
{
Widget_Data *wd;
- Elm_Entry_Text_Filter *tf;
+ Elm_Entry_Markup_Filter *tf;
ELM_CHECK_WIDTYPE(obj, widtype);
wd = elm_widget_data_get(obj);
elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
{
Widget_Data *wd;
- Elm_Entry_Text_Filter *tf;
+ Elm_Entry_Markup_Filter *tf;
ELM_CHECK_WIDTYPE(obj, widtype);
wd = elm_widget_data_get(obj);
{
Widget_Data *wd;
Eina_List *l;
- Elm_Entry_Text_Filter *tf;
+ Elm_Entry_Markup_Filter *tf;
ELM_CHECK_WIDTYPE(obj, widtype);
wd = elm_widget_data_get(obj);
}
}
+EAPI void
+elm_entry_markup_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
+{
+ Widget_Data *wd;
+ Elm_Entry_Markup_Filter *tf;
+ ELM_CHECK_WIDTYPE(obj, widtype);
+
+ wd = elm_widget_data_get(obj);
+
+ EINA_SAFETY_ON_NULL_RETURN(func);
+
+ tf = _filter_new(func, data);
+ if (!tf) return;
+
+ wd->markup_filters = eina_list_append(wd->markup_filters, tf);
+}
+
+EAPI void
+elm_entry_markup_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
+{
+ Widget_Data *wd;
+ Elm_Entry_Markup_Filter *tf;
+ ELM_CHECK_WIDTYPE(obj, widtype);
+
+ wd = elm_widget_data_get(obj);
+
+ EINA_SAFETY_ON_NULL_RETURN(func);
+
+ tf = _filter_new(func, data);
+ if (!tf) return;
+
+ wd->markup_filters = eina_list_prepend(wd->markup_filters, tf);
+}
+
+EAPI void
+elm_entry_markup_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data)
+{
+ Widget_Data *wd;
+ Eina_List *l;
+ Elm_Entry_Markup_Filter *tf;
+ ELM_CHECK_WIDTYPE(obj, widtype);
+
+ wd = elm_widget_data_get(obj);
+
+ EINA_SAFETY_ON_NULL_RETURN(func);
+
+ EINA_LIST_FOREACH(wd->markup_filters, l, tf)
+ {
+ if ((tf->func == func) && ((!data) || (tf->data == data)))
+ {
+ wd->markup_filters = eina_list_remove_list(wd->markup_filters, l);
+ _filter_free(tf);
+ return;
+ }
+ }
+}
+
EAPI char *
elm_entry_markup_to_utf8(const char *s)
{