summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-08-18 17:34:02 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-08-18 17:34:02 +0900
commit4ad272a8c3183790a65b7f2c0ccfb57b4688219a (patch)
treef8a6bedf0170722dff93f6a2c4b17b945cfa39e8 /src/lib/evas
parent463291548d759a847246927f42294e29ba67aad0 (diff)
evas_object_textblock: utf8_to_markup support all escapse chars
Summary: update evas_textblock_text_utf8_to_markup to support all escape characters Test Plan: ``` #define EFL_EO_API_SUPPORT 1 #define EFL_BETA_API_SUPPORT 1 #include<Eina.h> #include<Efl.h> #include <Elementary.h> EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win,*textblock; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(win, EINA_TRUE); textblock = evas_object_textblock_add(win); char * aaa = evas_textblock_text_utf8_to_markup(textblock,"A<<>>\"A\'\tA"); // aaa == "A&lt;&lt;&gt;&gt;&quot;A&apos;<tab/>A"; evas_object_size_hint_weight_set(textblock,EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(textblock,EVAS_HINT_FILL,EVAS_HINT_FILL); evas_object_show(textblock); evas_object_move(textblock,0,0); evas_object_resize(textblock,320,480); evas_object_resize(win,320,480); evas_object_show(win); elm_run(); return 0; } ELM_MAIN() ``` Reviewers: lauromoura, CHAN, woohyun, bu5hm4n, bowonryu, tasn, herdsman Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8843
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index e9b89dec98..f8ddf1cee6 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -8570,7 +8570,8 @@ _escaped_char_match(const char *s, int *adv)
8570 int n_ret = _escaped_value_search(s, list, len); 8570 int n_ret = _escaped_value_search(s, list, len);
8571 if (n_ret != -1) 8571 if (n_ret != -1)
8572 { 8572 {
8573 *adv = (int) list[n_ret]->value_len; 8573 if (adv)
8574 *adv = (int) list[n_ret]->value_len;
8574 return list[n_ret]->escape; 8575 return list[n_ret]->escape;
8575 } 8576 }
8576 else 8577 else
@@ -8579,7 +8580,8 @@ _escaped_char_match(const char *s, int *adv)
8579 n_ret = _escaped_value_search(s, list, len); 8580 n_ret = _escaped_value_search(s, list, len);
8580 if (n_ret != -1) 8581 if (n_ret != -1)
8581 { 8582 {
8582 *adv = (int)list[n_ret]->value_len; 8583 if (adv)
8584 *adv = (int)list[n_ret]->value_len;
8583 return list[n_ret]->escape; 8585 return list[n_ret]->escape;
8584 } 8586 }
8585 } 8587 }
@@ -8996,6 +8998,7 @@ static void
8996_markup_get_text_utf8_append(Eina_Strbuf *sbuf, const char *text) 8998_markup_get_text_utf8_append(Eina_Strbuf *sbuf, const char *text)
8997{ 8999{
8998 int ch, pos = 0, pos2 = 0; 9000 int ch, pos = 0, pos2 = 0;
9001 const char * replacement;
8999 9002
9000 for (;;) 9003 for (;;)
9001 { 9004 {
@@ -9007,23 +9010,21 @@ _markup_get_text_utf8_append(Eina_Strbuf *sbuf, const char *text)
9007 eina_strbuf_append(sbuf, "<br/>"); 9010 eina_strbuf_append(sbuf, "<br/>");
9008 else if (ch == _TAB) 9011 else if (ch == _TAB)
9009 eina_strbuf_append(sbuf, "<tab/>"); 9012 eina_strbuf_append(sbuf, "<tab/>");
9010 else if (ch == '<')
9011 eina_strbuf_append(sbuf, "&lt;");
9012 else if (ch == '>')
9013 eina_strbuf_append(sbuf, "&gt;");
9014 else if (ch == '&')
9015 eina_strbuf_append(sbuf, "&amp;");
9016 else if (ch == '"')
9017 eina_strbuf_append(sbuf, "&quot;");
9018 else if (ch == '\'')
9019 eina_strbuf_append(sbuf, "&apos;");
9020 else if (ch == _PARAGRAPH_SEPARATOR)
9021 eina_strbuf_append(sbuf, "<ps/>");
9022 else if (ch == _REPLACEMENT_CHAR) 9013 else if (ch == _REPLACEMENT_CHAR)
9023 eina_strbuf_append(sbuf, "&#xfffc;"); 9014 eina_strbuf_append(sbuf, "&#xfffc;");
9024 else if (ch != '\r') 9015 else if (ch == _PARAGRAPH_SEPARATOR)
9016 eina_strbuf_append(sbuf, "<ps/>");
9017 else
9025 { 9018 {
9026 eina_strbuf_append_length(sbuf, text + pos, pos2 - pos); 9019 replacement = _escaped_char_match(text + pos, NULL);
9020 if (replacement)
9021 {
9022 eina_strbuf_append(sbuf, replacement);
9023 }
9024 else if (ch != '\r')
9025 {
9026 eina_strbuf_append_length(sbuf, text + pos, pos2 - pos);
9027 }
9027 } 9028 }
9028 } 9029 }
9029} 9030}