From: tasn Date: Thu, 15 Dec 2011 13:03:43 +0000 (+0000) Subject: Evas textblock: Use macros for the unicode chars/strings. X-Git-Tag: 2.0_alpha~153^2~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=694ad2ead8c76a9ef9a7873f8d05f375d9965a0a;p=framework%2Fuifw%2Fevas.git Evas textblock: Use macros for the unicode chars/strings. 1. Make Obj replacement and Par Sep less confusing. 2. We'll may, at some point, use the Unicode NewLine char instead of \n. so it's now easily replaceable. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@66255 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 6136fd8..64f3d27 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -78,12 +78,19 @@ static const char o_type[] = "textblock"; /* The char to be inserted instead of visible formats */ -#define EVAS_TEXTBLOCK_REPLACEMENT_CHAR 0xFFFC +#define _REPLACEMENT_CHAR 0xFFFC #define _PARAGRAPH_SEPARATOR 0x2029 +#define _NEWLINE '\n' +#define _TAB '\t' + +#define _REPLACEMENT_CHAR_UTF8 "\xEF\xBF\xBC" +#define _PARAGRAPH_SEPARATOR_UTF8 "\xE2\x80\xA9" +#define _NEWLINE_UTF8 "\n" +#define _TAB_UTF8 "\t" #define EVAS_TEXTBLOCK_IS_VISIBLE_FORMAT_CHAR(ch) \ - (((ch) == EVAS_TEXTBLOCK_REPLACEMENT_CHAR) || \ - ((ch) == '\n') || \ - ((ch) == '\t') || \ + (((ch) == _REPLACEMENT_CHAR) || \ + ((ch) == _NEWLINE) || \ + ((ch) == _TAB) || \ ((ch) == _PARAGRAPH_SEPARATOR)) /* private struct for textblock object internal data */ @@ -4995,7 +5002,8 @@ evas_object_textblock_text_markup_prepend(Evas_Textblock_Cursor *cur, const char } } /* Unicode object replcament char */ - else if (!strncmp("\xEF\xBF\xBC", p, 3)) + else if (!strncmp(_REPLACEMENT_CHAR_UTF8, p, + strlen(_REPLACEMENT_CHAR_UTF8))) { /*FIXME: currently just remove them, maybe do something * fancier in the future, atm it breaks if this char @@ -5188,13 +5196,13 @@ evas_textblock_text_markup_to_utf8(const Evas_Object *obj, const char *text) if (!match) match = ttag; if (_IS_PARAGRAPH_SEPARATOR_SIMPLE(match)) - eina_strbuf_append(sbuf, "\xE2\x80\xA9"); + eina_strbuf_append(sbuf, _PARAGRAPH_SEPARATOR_UTF8); else if (_IS_LINE_SEPARATOR(match)) - eina_strbuf_append(sbuf, "\n"); + eina_strbuf_append(sbuf, _NEWLINE_UTF8); else if (_IS_TAB(match)) - eina_strbuf_append(sbuf, "\t"); + eina_strbuf_append(sbuf, _TAB_UTF8); else if (!strncmp(match, "item", 4)) - eina_strbuf_append(sbuf, "\xEF\xBF\xBC"); + eina_strbuf_append(sbuf, _REPLACEMENT_CHAR_UTF8); free(ttag); } @@ -5283,9 +5291,9 @@ evas_textblock_text_utf8_to_markup(const Evas_Object *obj, const char *text) pos2 = evas_string_char_next_get(text, pos2, &ch); if ((ch <= 0) || (pos2 <= 0)) break; - if (ch == '\n') + if (ch == _NEWLINE) eina_strbuf_append(sbuf, "
"); - else if (ch == '\t') + else if (ch == _TAB) eina_strbuf_append(sbuf, ""); else if (ch == '<') eina_strbuf_append(sbuf, "<"); @@ -5293,9 +5301,9 @@ evas_textblock_text_utf8_to_markup(const Evas_Object *obj, const char *text) eina_strbuf_append(sbuf, ">"); else if (ch == '&') eina_strbuf_append(sbuf, "&"); - else if (ch == 0x2029) /* PS */ + else if (ch == _PARAGRAPH_SEPARATOR) eina_strbuf_append(sbuf, ""); - else if (ch == 0xFFFC ) /* Object Replacement Char */ + else if (ch == _REPLACEMENT_CHAR) eina_strbuf_append(sbuf, ""); else { @@ -7394,11 +7402,11 @@ evas_textblock_cursor_format_append(Evas_Textblock_Cursor *cur, const char *form if (_IS_PARAGRAPH_SEPARATOR(o, format)) insert_char = _PARAGRAPH_SEPARATOR; else if (_IS_LINE_SEPARATOR(format)) - insert_char = '\n'; + insert_char = _NEWLINE; else if (_IS_TAB(format)) - insert_char = '\t'; + insert_char = _TAB; else - insert_char = EVAS_TEXTBLOCK_REPLACEMENT_CHAR; + insert_char = _REPLACEMENT_CHAR; eina_ustrbuf_insert_char(cur->node->unicode, insert_char, cur->pos);