From 4b1edd906c7a26a1f724c28a88f8d55679494679 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 4 Feb 2013 00:57:50 +0000 Subject: [PATCH] efl/edje_entry: support &, < and > in preedit string SVN revision: 83575 --- ChangeLog | 4 +++ NEWS | 1 + src/lib/edje/edje_entry.c | 60 +++++++++++++-------------------------- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index d203df5c99..ae060daaa9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-02-04 Jihoon Kim (jihoon) + + * edje entry : Support &, < and > in preedit string. + 2013-02-02 Chidambar Zinnoury (ilLogict) * Update French translation. diff --git a/NEWS b/NEWS index c88cf32151..c001a838be 100644 --- a/NEWS +++ b/NEWS @@ -92,6 +92,7 @@ Improvements: * edje entry : Remove ecore_imf_context_cursor_position_set in functions related to selection. * Translations updates: - french. + * edje entry : Support &, < and > in preedit string Fixes: * Fix a memory leak in ecore_con_dns when using ecore_con_server_connect diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index 70ef36ce88..f6a5560da2 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -3739,11 +3739,16 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx EINA int cursor_pos; int preedit_start_pos, preedit_end_pos; char *preedit_string; + char *markup_txt = NULL; + char *tagname[] = {"", "preedit", "preedit_sel", "preedit_sel", + "preedit_sub1", "preedit_sub2", "preedit_sub3", "preedit_sub4"}; int i; + size_t preedit_type_size = sizeof(tagname) / sizeof(tagname[0]); Eina_Bool preedit_end_state = EINA_FALSE; Eina_List *attrs = NULL, *l = NULL; Ecore_IMF_Preedit_Attr *attr; Eina_Strbuf *buf; + Eina_Strbuf *preedit_attr_str; if ((!rp)) return; @@ -3784,49 +3789,22 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx EINA { EINA_LIST_FOREACH(attrs, l, attr) { - if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB1) + if (attr->preedit_type > ECORE_IMF_PREEDIT_TYPE_NONE && + attr->preedit_type <= preedit_type_size) { - eina_strbuf_append(buf, ""); - eina_strbuf_append_n(buf, preedit_string + attr->start_index, - attr->end_index - attr->start_index); - eina_strbuf_append(buf, ""); - } + preedit_attr_str = eina_strbuf_new(); + if (preedit_attr_str) + { + eina_strbuf_append_n(preedit_attr_str, preedit_string + attr->start_index, attr->end_index - attr->start_index); + markup_txt = evas_textblock_text_utf8_to_markup(NULL, eina_strbuf_string_get(preedit_attr_str)); - else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB2 || - attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3) - { - eina_strbuf_append(buf, ""); - eina_strbuf_append_n(buf, preedit_string + attr->start_index, - attr->end_index - attr->start_index); - eina_strbuf_append(buf, ""); - } - else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4) - { - eina_strbuf_append(buf, ""); - eina_strbuf_append_n(buf, preedit_string + attr->start_index, - attr->end_index - attr->start_index); - eina_strbuf_append(buf, ""); - } - else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB5) - { - eina_strbuf_append(buf, ""); - eina_strbuf_append_n(buf, preedit_string + attr->start_index, - attr->end_index - attr->start_index); - eina_strbuf_append(buf, ""); - } - else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB6) - { - eina_strbuf_append(buf, ""); - eina_strbuf_append_n(buf, preedit_string + attr->start_index, - attr->end_index - attr->start_index); - eina_strbuf_append(buf, ""); - } - else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB7) - { - eina_strbuf_append(buf, ""); - eina_strbuf_append_n(buf, preedit_string + attr->start_index, - attr->end_index - attr->start_index); - eina_strbuf_append(buf, ""); + if (markup_txt) + { + eina_strbuf_append_printf(buf, "<%s>%s", tagname[attr->preedit_type], markup_txt, tagname[attr->preedit_type]); + free(markup_txt); + } + eina_strbuf_free(preedit_attr_str); + } } } }