and use new util calls from entry too and remove old code.
authorCarsten Haitzler <raster@rasterman.com>
Mon, 20 Dec 2010 06:05:59 +0000 (06:05 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Mon, 20 Dec 2010 06:05:59 +0000 (06:05 +0000)
SVN revision: 55650

src/lib/elm_entry.c

index 0ed1835cd0d0fec3e2ebd65393aab8452fe76544..2ddc36dda49e8a2d146cd195bb9f69c17944470e 100644 (file)
@@ -940,196 +940,6 @@ _getbase(Evas_Object *obj)
    return "base";
 }
 
-static char *
-_str_append(char *str, const char *txt, int *len, int *alloc)
-{
-   int txt_len = strlen(txt);
-
-   if (txt_len <= 0) return str;
-   if ((*len + txt_len) >= *alloc)
-     {
-       char *str2;
-       int alloc2;
-
-       alloc2 = *alloc + txt_len + 128;
-       str2 = realloc(str, alloc2);
-       if (!str2) return str;
-       *alloc = alloc2;
-       str = str2;
-     }
-   strcpy(str + *len, txt);
-   *len += txt_len;
-   return str;
-}
-
-/*FIXME: Sholud be implemented somewhere else, it really depends on the context
- * because some markups can be implemented otherwise according to style.
- * probably doing it in textblock and making it translate according to it's
- * style is correct. */
-static char *
-_mkup_to_text(const char *mkup)
-{
-   char *str = NULL;
-   int str_len = 0, str_alloc = 0;
-   char *s, *p;
-   char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
-
-   if (!mkup) return NULL;
-   tag_start = tag_end = esc_start = esc_end = NULL;
-   p = (char *)mkup;
-   s = p;
-   for (;;)
-     {
-       if ((!*p) ||
-           (tag_end) || (esc_end) ||
-           (tag_start) || (esc_start))
-         {
-            if (tag_end)
-              {
-                 char *ttag;
-
-                 ttag = malloc(tag_end - tag_start);
-                 if (ttag)
-                   {
-                      strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
-                      ttag[tag_end - tag_start - 1] = 0;
-                      if (!strcmp(ttag, "br"))
-                        str = _str_append(str, "\n", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\n"))
-                        str = _str_append(str, "\n", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\\n"))
-                        str = _str_append(str, "\n", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\t"))
-                        str = _str_append(str, "\t", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "\\t"))
-                        str = _str_append(str, "\t", &str_len, &str_alloc);
-                      else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
-                        str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
-                      free(ttag);
-                   }
-                 tag_start = tag_end = NULL;
-              }
-            else if (esc_end)
-              {
-                 ts = malloc(esc_end - esc_start + 1);
-                 if (ts)
-                   {
-                      const char *esc;
-                      strncpy(ts, esc_start, esc_end - esc_start);
-                      ts[esc_end - esc_start] = 0;
-                      esc = evas_textblock_escape_string_get(ts);
-                      if (esc)
-                        str = _str_append(str, esc, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                 esc_start = esc_end = NULL;
-              }
-            else if ((!*p) && (s))
-              {
-                 ts = malloc(p - s + 1);
-                 if (ts)
-                   {
-                      strncpy(ts, s, p - s);
-                      ts[p - s] = 0;
-                      str = _str_append(str, ts, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                  break;
-              }
-         }
-       if (*p == '<')
-         {
-            if ((s) && (!esc_start))
-              {
-                 tag_start = p;
-                 tag_end = NULL;
-                 ts = malloc(p - s + 1);
-                 if (ts)
-                   {
-                      strncpy(ts, s, p - s);
-                      ts[p - s] = 0;
-                      str = _str_append(str, ts, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                 s = NULL;
-              }
-         }
-       else if (*p == '>')
-         {
-            if (tag_start)
-              {
-                 tag_end = p;
-                 s = p + 1;
-              }
-         }
-       else if (*p == '&')
-         {
-            if ((s) && (!tag_start))
-              {
-                 esc_start = p;
-                 esc_end = NULL;
-                 ts = malloc(p - s + 1);
-                 if (ts)
-                   {
-                      strncpy(ts, s, p - s);
-                      ts[p - s] = 0;
-                      str = _str_append(str, ts, &str_len, &str_alloc);
-                      free(ts);
-                   }
-                 s = NULL;
-              }
-         }
-       else if (*p == ';')
-         {
-            if (esc_start)
-              {
-                 esc_end = p;
-                 s = p + 1;
-              }
-         }
-       p++;
-     }
-   return str;
-}
-
-
-static char *
-_text_to_mkup(const char *text)
-{
-   char *str = NULL;
-   int str_len = 0, str_alloc = 0;
-   int ch, pos = 0, pos2 = 0;
-
-   if (!text) return NULL;
-   for (;;)
-     {
-       pos = pos2;
-        pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
-        if ((ch <= 0) || (pos2 <= 0)) break;
-       if (ch == '\n')
-          str = _str_append(str, "<br>", &str_len, &str_alloc);
-       else if (ch == '\t')
-          str = _str_append(str, "<\t>", &str_len, &str_alloc);
-       else if (ch == '<')
-          str = _str_append(str, "&lt;", &str_len, &str_alloc);
-       else if (ch == '>')
-          str = _str_append(str, "&gt;", &str_len, &str_alloc);
-       else if (ch == '&')
-          str = _str_append(str, "&amp;", &str_len, &str_alloc);
-        else if (ch == 0x2029) /* PS */
-          str = _str_append(str, "<ps>", &str_len, &str_alloc);
-       else
-         {
-            char tstr[16];
-
-            strncpy(tstr, text + pos, pos2 - pos);
-            tstr[pos2 - pos] = 0;
-            str = _str_append(str, tstr, &str_len, &str_alloc);
-         }
-     }
-   return str;
-}
-
 static void
 _signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
 {
@@ -1422,7 +1232,7 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
          {
             if (text_data->text)
               {
-                 char *txt = _text_to_mkup(text_data->text);
+                 char *txt = _elm_util_text_to_mkup(text_data->text);
 
                  if (txt)
                    {
@@ -1442,7 +1252,7 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
          {
             if (text_data->text)
               {
-                 char *txt = _text_to_mkup(text_data->text);
+                 char *txt = _elm_util_text_to_mkup(text_data->text);
 
                  if (txt)
                    {
@@ -2578,7 +2388,7 @@ elm_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Ob
 EAPI char *
 elm_entry_markup_to_utf8(const char *s)
 {
-   char *ss = _mkup_to_text(s);
+   char *ss = _elm_util_mkup_to_text(s);
    if (!ss) ss = strdup("");
    return ss;
 }
@@ -2594,7 +2404,7 @@ elm_entry_markup_to_utf8(const char *s)
 EAPI char *
 elm_entry_utf8_to_markup(const char *s)
 {
-   char *ss = _text_to_mkup(s);
+   char *ss = _elm_util_text_to_mkup(s);
    if (!ss) ss = strdup("");
    return ss;
 }