From f6c7633f831c34cf14e629ab55ccb7ced79478cc Mon Sep 17 00:00:00 2001 From: Subodh Kumar Date: Fri, 14 Aug 2015 13:10:56 +0530 Subject: [PATCH] [2.4][edje_entry] Fix to pass proper text and cursor position to imf in case of selection @tizen_fix Change-Id: I62beb5ce8027d00fe3e64de5320bb02ddc2d0359 Signed-off-by: Subodh Kumar --- src/lib/edje/edje_entry.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index c86057b..d787ca7 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -4287,6 +4287,9 @@ _edje_entry_imf_cursor_info_set(Entry *en) } #ifdef HAVE_ECORE_IMF +// TIZEN_ONLY (20150814): Pass correct cursor position and correct text to imf when selection is there +// FIXME: Need to be pushed in upstream +/* static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos) { @@ -4335,7 +4338,74 @@ _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_ } return EINA_TRUE; +}*/ + +static Eina_Bool +_edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos) +{ + Edje *ed = data; + Edje_Real_Part *rp = ed->focused_part; + Entry *en = NULL; + const char *str; + char *plain_text; + Eina_Strbuf *buf = NULL; + + if (!rp) return EINA_FALSE; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + else + en = rp->typedata.text->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return EINA_FALSE; + + if (text) + { + str = _edje_entry_text_get(rp); + if (str) + { + plain_text = evas_textblock_text_markup_to_utf8(NULL, str); + + if (plain_text) + { + if (en->have_selection) + { + buf = eina_strbuf_new(); + + if (en->sel_start) + eina_strbuf_append_n(buf, plain_text, evas_textblock_cursor_pos_get(en->sel_start)); + else + eina_strbuf_append(buf, plain_text); + + *text = strdup(eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); + } + else + *text = strdup(plain_text); + + free(plain_text); + plain_text = NULL; + } + else + *text = strdup(""); + } + else + *text = strdup(""); + } + + if (cursor_pos) + { + if (en->have_selection && en->sel_start) + *cursor_pos = evas_textblock_cursor_pos_get(en->sel_start); + else if (en->cursor) + *cursor_pos = evas_textblock_cursor_pos_get(en->cursor); + else + *cursor_pos = 0; + } + + return EINA_TRUE; } +// static void _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info) -- 2.7.4