From: Hyoyoung Chang <hyoyoung.chang@samsung.com>
authorHyoyoung Chang <hyoyoung.chang@samsung.com>
Fri, 5 Aug 2011 23:03:55 +0000 (23:03 +0000)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 5 Aug 2011 23:03:55 +0000 (23:03 +0000)
Subject: [E-devel] [patch] elm_cnp_helper - adding paragraph separator(<ps>) handling
Date: Fri, 05 Aug 2011 13:09:41 +0900

Dear developers.

This patch is about elm_cnp_helper.
When using elm_entry, sometimes newline isn't copied.
That's because <ps> tag. It's represent of 'paragraph separator'.
(Other case is using <br>. It works well)
I just adding <ps> handling for separated paragraph.

SVN revision: 62153

src/lib/elm_cnp_helper.c

index 47f172f..ee9511c 100644 (file)
@@ -78,7 +78,7 @@ struct _Cnp_Selection
 struct _Escape
 {
    const char *escape;
-   const char  value;
+   const char  *value;
 };
 
 struct _Tmp_Info
@@ -147,16 +147,19 @@ static int vcard_receive(Cnp_Selection *sed, Ecore_X_Event_Selection_Notify *not
 
 static Eina_Bool pasteimage_append(char *file, Evas_Object *entry);
 
+#define _PARAGRAPH_SEPARATOR "\xE2\x80\xA9"
+
 /* Optimisation: Turn this into a 256 byte table:
  *     then can lookup in one index, not N checks */
 static const Escape escapes[] = {
-       { "<br>",   '\n' },
-       { "<\t>",   '\t' },
-       { "gt;",    '>'  },
-       { "lt;",    '<'  },
-       { "amp;",   '&'  },
-       { "quot;",  '\'' },
-       { "dquot;", '"'  }
+  { "<ps>",  _PARAGRAPH_SEPARATOR },
+  { "<br>",  "\n" },
+  { "<\t>",  "\t" },
+  { "gt;",   ">" },
+  { "lt;",    "<" },
+  { "amp;",   "&" },
+  { "quot;",  "\'" },
+  { "dquot;", "\"" }
 };
 #define N_ESCAPES ((int)(sizeof(escapes) / sizeof(escapes[0])))
 
@@ -1035,7 +1038,7 @@ remove_tags(const char *p, int *len)
    int i;
    if (!p) return NULL;
 
-   q = malloc(strlen(p) + 1);
+   q = malloc(strlen(p)+1);
    if (!q) return NULL;
    ret = q;
 
@@ -1047,6 +1050,11 @@ remove_tags(const char *p, int *len)
              if ((p[1] == 'b') && (p[2] == 'r') &&
                  ((p[3] == ' ') || (p[3] == '/') || (p[3] == '>')))
                *q++ = '\n';
+             else if ((p[1] == 'p') && (p[2] == 's') && (p[3] == '>'))
+               {
+                  strcpy(q, _PARAGRAPH_SEPARATOR);
+                  q += (sizeof(_PARAGRAPH_SEPARATOR)-1);
+               }
              while ((*p) && (*p != '>')) p++;
              p++;
           }
@@ -1058,8 +1066,8 @@ remove_tags(const char *p, int *len)
                   if (!strncmp(p,escapes[i].escape, strlen(escapes[i].escape)))
                     {
                        p += strlen(escapes[i].escape);
-                       *q = escapes[i].value;
-                       q++;
+                       strcpy(q, escapes[i].value);
+                       q += strlen(escapes[i].value);
                        break;
                     }
                }
@@ -1087,9 +1095,10 @@ mark_up(const char *start, int inlen, int *lenp)
      {
         for (i = 0 ; i < N_ESCAPES ; i ++)
           {
-             if (*p == escapes[i].value)
+             if (*p == escapes[i].value[0])
                {
-                  l += strlen(escapes[i].escape);
+                  if (!strncmp(p, escapes[i].value, strlen(escapes[i].value)))
+                    l += strlen(escapes[i].escape);
                   break;
                }
           }
@@ -1103,11 +1112,14 @@ mark_up(const char *start, int inlen, int *lenp)
      {
         for (i = 0; i < N_ESCAPES; i++)
           {
-             if (*p == escapes[i].value)
+             if (*p == escapes[i].value[0])
                {
-                  strcpy(q, escapes[i].escape);
-                  q += strlen(escapes[i].escape);
-                  p ++;
+                  if (!strncmp(p, escapes[i].value, strlen(escapes[i].value)))
+                    {
+                       strcpy(q, escapes[i].escape);
+                       q += strlen(escapes[i].escape);
+                       p += strlen(escapes[i].value);
+                    }
                   break;
                }
           }