* @see elm_entry_file_set()
*/
EAPI Eina_Bool elm_entry_autosave_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+
+ /**
+ * @enum _Elm_CNP_Mode
+ * @typedef Elm_CNP_Mode
+ * Enum of entry's copy & paste policy.
+ *
+ * @see elm_entry_cnp_mode_set()
+ * @see elm_entry_cnp_mode_get()
+ */
+ typedef enum _Elm_CNP_Mode {
+ ELM_CNP_MODE_MARKUP = 0, /**< copy & paste text with markup tag */
+ ELM_CNP_MODE_NO_IMAGE = 1, /**< copy & paste text without item(image) tag */
+ ELM_CNP_MODE_PLAINTEXT = 2 /**< copy & paste text without markup tag */
+ } Elm_CNP_Mode;
+
+ /**
+ * Control pasting of text and images for the widget.
+ *
+ * Normally the entry allows both text and images to be pasted.
+ * By setting textonly to be ELM_CNP_MODE_NO_IMAGE, this prevents images from being copy or past.
+ * By setting textonly to be ELM_CNP_MODE_PLAINTEXT, this remove all tags in text .
+ *
+ * @note this only changes the behaviour of text.
+ *
+ * @param obj The entry object
+ * @param mode One of #Elm_CNP_Mode: #ELM_CNP_MODE_MARKUP,
+ * #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT.
+ */
+ EAPI void elm_entry_cnp_mode_set(Evas_Object *obj, Elm_CNP_Mode cnp_mode) EINA_ARG_NONNULL(1);
+ /**
+ * Getting elm_entry text paste/drop mode.
+ *
+ * Normally the entry allows both text and images to be pasted.
+ * This gets the copy & paste mode of the entry.
+ *
+ * @param obj The entry object
+ * @return mode One of #Elm_CNP_Mode: #ELM_CNP_MODE_MARKUP,
+ * #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT.
+ */
+ EAPI Elm_CNP_Mode elm_entry_cnp_mode_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+
/**
* Control pasting of text and images for the widget.
*
Eina_Bool bgcolor : 1;
Eina_Bool can_write : 1;
Eina_Bool autosave : 1;
- Eina_Bool textonly : 1;
Eina_Bool usedown : 1;
Eina_Bool scroll : 1;
Eina_Bool input_panel_enable : 1;
Eina_Bool autoperiod : 1;
Eina_Bool matchlist_list_clicked : 1;
Eina_Bool matchlist_case_sensitive : 1;
+ Elm_CNP_Mode cnp_mode : 2;
};
struct _Elm_Entry_Context_Menu_Item
if (wd->sel_notify_handler)
{
#ifdef HAVE_ELEMENTARY_X
- Elm_Sel_Format formats;
+ Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
wd->selection_asked = EINA_TRUE;
- formats = ELM_SEL_FORMAT_MARKUP;
- if (!wd->textonly)
+ if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
+ formats = ELM_SEL_FORMAT_TEXT;
+ else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
formats |= ELM_SEL_FORMAT_IMAGE;
elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL);
#endif
{
Widget_Data *wd = elm_widget_data_get(obj);
const char *sel;
- char *sel_str;
+ char *sel_str = NULL;
+ Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
if (!wd) return;
sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
- sel_str = strdup(sel);
- if (!sel_str)
- return;
- if (wd->textonly)
+ if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
+ {
+ sel_str = elm_entry_markup_to_utf8(sel);
+ if (!sel_str)
+ return;
+ formats = ELM_SEL_FORMAT_TEXT;
+ }
+ else
{
- while (EINA_TRUE)
+ sel_str = strdup(sel);
+ if (!sel_str)
+ return;
+ if (wd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
{
- char *startTag = NULL;
- char *endTag = NULL;
-
- startTag = strstr(sel_str, "<item");
- if (!startTag)
- startTag = strstr(sel_str, "</item");
- if (startTag)
- endTag = strstr(startTag, ">");
- else
- break;
- if (!endTag || startTag > endTag)
- break;
-
- size_t sindex = startTag - sel_str;
- size_t eindex = endTag - sel_str + 1;
-
- Eina_Strbuf *buf = eina_strbuf_new();
- if (buf)
+ while (EINA_TRUE)
{
- eina_strbuf_append(buf, sel_str);
- eina_strbuf_remove(buf, sindex, eindex);
- sel_str = eina_strbuf_string_steal(buf);
- eina_strbuf_free(buf);
+ char *startTag = NULL;
+ char *endTag = NULL;
+
+ startTag = strstr(sel_str, "<item");
+ if (!startTag)
+ startTag = strstr(sel_str, "</item");
+ if (startTag)
+ endTag = strstr(startTag, ">");
+ else
+ break;
+ if (!endTag || startTag > endTag)
+ break;
+
+ size_t sindex = startTag - sel_str;
+ size_t eindex = endTag - sel_str + 1;
+
+ Eina_Strbuf *buf = eina_strbuf_new();
+ if (buf)
+ {
+ eina_strbuf_append(buf, sel_str);
+ eina_strbuf_remove(buf, sindex, eindex);
+ sel_str = eina_strbuf_string_steal(buf);
+ eina_strbuf_free(buf);
+ }
}
}
}
- elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel_str);
+ elm_selection_set(seltype, obj, formats, sel_str);
if (seltype == ELM_SEL_CLIPBOARD)
- eina_stringshare_replace(&wd->cut_sel, sel_str);
+ eina_stringshare_replace(&wd->cut_sel, sel);
free(sel_str);
}
#endif
cnpwidgetdata = data;
elm_cbhm_helper_init(obj);
- if (elm_entry_cnp_textonly_get(obj))
+ if (elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP)
elm_cbhm_send_raw_data("show0");
else
elm_cbhm_send_raw_data("show1");
if (cnpwidgetdata == data)
{
+ Widget_Data *wd = elm_widget_data_get(data);
+ Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP;
evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
- elm_selection_get(ELM_SEL_SECONDARY,ELM_SEL_FORMAT_MARKUP,data,NULL,NULL);
+ if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
+ formats = ELM_SEL_FORMAT_TEXT;
+ else if (wd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
+ formats |= ELM_SEL_FORMAT_IMAGE;
+ elm_selection_get(ELM_SEL_SECONDARY, formats ,data, NULL, NULL);
}
// end for cbhm
wd->disabled = EINA_FALSE;
wd->context_menu = EINA_TRUE;
wd->autosave = EINA_TRUE;
- wd->textonly = EINA_FALSE;
+ wd->cnp_mode = ELM_CNP_MODE_MARKUP;
wd->autoperiod = EINA_TRUE;
wd->ent = edje_object_add(e);
ext_mod->selmode = wd->selmode;
ext_mod->cnpinit = _cnpinit;
ext_mod->context_menu = wd->context_menu;
- ext_mod->textonly = wd->textonly;
+ ext_mod->cnp_mode = wd->cnp_mode;
}
EAPI void
if (wd->single_line == single_line) return;
wd->single_line = single_line;
wd->linewrap = ELM_WRAP_NONE;
- elm_entry_cnp_textonly_set(obj, EINA_TRUE);
+ elm_entry_cnp_mode_set(obj, ELM_CNP_MODE_NO_IMAGE);
_theme_hook(obj);
if (wd->scroller)
{
EAPI void
elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ elm_entry_cnp_mode_set(obj, textonly ? ELM_CNP_MODE_NO_IMAGE : ELM_CNP_MODE_MARKUP);
+}
+
+EAPI Eina_Bool
+elm_entry_cnp_textonly_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ return elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP;
+}
+
+EAPI void
+elm_entry_cnp_mode_set(Evas_Object *obj, Elm_CNP_Mode cnp_mode)
+{
Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- textonly = !!textonly;
- if (wd->textonly == textonly) return;
- wd->textonly = !!textonly;
- if (!textonly) format |= ELM_SEL_FORMAT_IMAGE;
+ if (wd->cnp_mode == cnp_mode) return;
+ wd->cnp_mode = cnp_mode;
+ if (wd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
+ format = ELM_SEL_FORMAT_TEXT;
+ else if (cnp_mode == ELM_CNP_MODE_MARKUP) format |= ELM_SEL_FORMAT_IMAGE;
#ifdef HAVE_ELEMENTARY_X
elm_drop_target_add(obj, format, _drag_drop_cb, NULL);
#endif
}
-EAPI Eina_Bool
-elm_entry_cnp_textonly_get(const Evas_Object *obj)
+EAPI Elm_CNP_Mode
+elm_entry_cnp_mode_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->textonly;
+ return wd->cnp_mode;
}
EAPI void