forked from enlightenment/efl
Evas textblock: Added evas_textblock_text_utf8_to_markup.
SVN revision: 66197
This commit is contained in:
parent
4d61bb8329
commit
bdab64acae
|
@ -566,3 +566,4 @@
|
|||
* Textblock: Made "br" and "tab" default tags for newline and tab.
|
||||
* Textblock: Added "b" and "i" as default tags that can be overridden
|
||||
by style, and added the infra to support this.
|
||||
* Textblock: Added evas_textblock_text_utf8_to_markup
|
||||
|
|
|
@ -8120,11 +8120,25 @@ EAPI const char *evas_textblock_escape_string_range_get(const c
|
|||
* the actual char and etc.
|
||||
*
|
||||
* @param obj the textblock object to work with.
|
||||
* @param text the markup text
|
||||
* @param text the markup text (if NULL, return NULL)
|
||||
* @return an allocated plain text version of the markup
|
||||
* @since 1.2.0
|
||||
*/
|
||||
EAPI char *evas_textblock_text_markup_to_utf8(const Evas_Object *obj, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2);
|
||||
EAPI char *evas_textblock_text_markup_to_utf8(const Evas_Object *obj, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* Return the markup version of the plain text.
|
||||
*
|
||||
* Replaces \n -> <br/> \t -> <tab/> and etc. Generally needed before you pass
|
||||
* plain text to be set in a textblock.
|
||||
*
|
||||
* @param obj the textblock object to work with (if NULL, it just does the
|
||||
* default behaviour, i.e with no extra object information).
|
||||
* @param text the markup text (if NULL, return NULL)
|
||||
* @return an allocated plain text version of the markup
|
||||
* @since 1.2.0
|
||||
*/
|
||||
EAPI char *evas_textblock_text_utf8_to_markup(const Evas_Object *obj, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
|
||||
|
||||
/**
|
||||
* Creates a new textblock style.
|
||||
|
|
|
@ -5123,6 +5123,8 @@ evas_object_textblock_text_markup_get(const Evas_Object *obj)
|
|||
EAPI char *
|
||||
evas_textblock_text_markup_to_utf8(const Evas_Object *obj, const char *text)
|
||||
{
|
||||
if (!text) return NULL;
|
||||
|
||||
/* FIXME: Can be done better, this is the least redundant way of doing it,
|
||||
* but by far the slowest, when the time comes, this should be
|
||||
* re-implemented. */
|
||||
|
@ -5150,6 +5152,50 @@ evas_textblock_text_markup_to_utf8(const Evas_Object *obj, const char *text)
|
|||
return ret;
|
||||
}
|
||||
|
||||
EAPI char *
|
||||
evas_textblock_text_utf8_to_markup(const Evas_Object *obj, const char *text)
|
||||
{
|
||||
Eina_Strbuf *sbuf;
|
||||
char *str = NULL;
|
||||
int ch, pos = 0, pos2 = 0;
|
||||
|
||||
(void) obj;
|
||||
|
||||
if (!text) return NULL;
|
||||
|
||||
sbuf = eina_strbuf_new();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
pos = pos2;
|
||||
pos2 = evas_string_char_next_get(text, pos2, &ch);
|
||||
if ((ch <= 0) || (pos2 <= 0)) break;
|
||||
|
||||
if (ch == '\n')
|
||||
eina_strbuf_append(sbuf, "<br/>");
|
||||
else if (ch == '\t')
|
||||
eina_strbuf_append(sbuf, "<tab/>");
|
||||
else if (ch == '<')
|
||||
eina_strbuf_append(sbuf, "<");
|
||||
else if (ch == '>')
|
||||
eina_strbuf_append(sbuf, ">");
|
||||
else if (ch == '&')
|
||||
eina_strbuf_append(sbuf, "&");
|
||||
else if (ch == 0x2029) /* PS */
|
||||
eina_strbuf_append(sbuf, "<ps/>");
|
||||
else if (ch == 0xFFFC ) /* Object Replacement Char */
|
||||
eina_strbuf_append(sbuf, "");
|
||||
else
|
||||
{
|
||||
eina_strbuf_append_length(sbuf, text + pos, pos2 - pos);
|
||||
}
|
||||
}
|
||||
str = eina_strbuf_string_steal(sbuf);
|
||||
eina_strbuf_free(sbuf);
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
/* cursors */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue