From a682384e436ee191efe4740c7745117b083a7a4c Mon Sep 17 00:00:00 2001 From: tasn Date: Sun, 14 Aug 2011 11:26:45 +0000 Subject: [PATCH] Evas textblock: Fixed cursor_content_get's handling of formats. Formats are now correctly enclosed with <> when returned, instead of just the text being returned. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@62439 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_object_textblock.c | 35 +++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index d7a6e29..b8072a1 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -7272,11 +7272,40 @@ evas_textblock_cursor_content_get(const Evas_Textblock_Cursor *cur) if (!cur || !cur->node) return NULL; if (evas_textblock_cursor_format_is_visible_get(cur)) { - const char *tmp; - tmp = evas_textblock_node_format_text_get( + size_t len; + const char *fstr; + char *ret; + int pop = 0; + fstr = evas_textblock_node_format_text_get( _evas_textblock_node_visible_at_pos_get( evas_textblock_cursor_format_get(cur))); - return (tmp) ? strdup(tmp) : NULL; + + if (!fstr) + return NULL; + + if (*fstr == '-') pop = 1; + while ((*fstr == ' ') || (*fstr == '+') || (*fstr == '-')) fstr++; + len = strlen(fstr); + + { + char *tmp; + if (pop) + { + ret = tmp = malloc(len + 3 + 1); /* and the null */ + memcpy(tmp, " and the null */ + *tmp = '<'; + tmp++; + } + memcpy(tmp, fstr, len); + memcpy(tmp + len, ">", 2); /* Including the null */ + } + + return ret; } ustr = eina_ustrbuf_string_get(cur->node->unicode); -- 2.7.4