Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/evas

Dir     : e17/libs/evas/src/lib/canvas


Modified Files:
        evas_object_textblock.c 


Log Message:


get rid of most whitespace. still need to handle end conditions

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_textblock.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -3 -r1.65 -r1.66
--- evas_object_textblock.c     8 Aug 2005 14:36:12 -0000       1.65
+++ evas_object_textblock.c     8 Aug 2005 15:41:38 -0000       1.66
@@ -734,6 +734,100 @@
      "ω", "ω"
 };
 
+static int
+_is_white(int c)
+{
+   /*
+    * unicode list of whitespace chars
+    *
+    * 0009..000D <control-0009>..<control-000D>
+    * 0020 SPACE
+    * 0085 <control-0085>
+    * 00A0 NO-BREAK SPACE
+    * 1680 OGHAM SPACE MARK
+    * 180E MONGOLIAN VOWEL SEPARATOR
+    * 2000..200A EN QUAD..HAIR SPACE
+    * 2028 LINE SEPARATOR
+    * 2029 PARAGRAPH SEPARATOR
+    * 202F NARROW NO-BREAK SPACE
+    * 205F MEDIUM MATHEMATICAL SPACE
+    * 3000 IDEOGRAPHIC SPACE
+    */
+   if (
+       (c == 0x20) ||
+       ((c >= 0x9) && (c <= 0xd)) ||
+       (c == 0x85) ||
+       (c == 0xa0) ||
+       (c == 0x1680) ||
+       (c == 0x180e) ||
+       ((c >= 0x2000) && (c <= 0x200a)) ||
+       (c == 0x2028) ||
+       (c == 0x2029) ||
+       (c == 0x202f) ||
+       (c == 0x205f) ||
+       (c == 0x3000)
+       )
+     return 1;
+   return 0;
+}
+
+static char *
+_clean_white(int clean_start, int clean_end, char *str)
+{
+   char *p, *p2, *str2 = NULL;
+   int white, pwhite, start, ok;
+
+   str2 = malloc(strlen(str) + 2);
+   p = str;
+   p2 = str2;
+   white = 0;
+   pwhite = 0;
+   start = 1;
+   ok = 1;
+   while (*p != 0)
+     {
+       pwhite = white;
+       if (isspace(*p) || _is_white(*p)) white = 1;
+       else white = 0;
+       if ((pwhite) && (white)) ok = 0;
+       else
+         {
+            if (!clean_start)
+              {
+                 if ((start) && (pwhite) && (!white))
+                   {
+                      *p2 = ' ';
+                      p2++;
+                   }
+              }
+            ok = 1;
+            if (!white) start = 0;
+         }
+       if (clean_start)
+         {
+            if ((start) && (ok)) ok = 0;
+         }
+       if (ok)
+         {
+            *p2 = *p;
+            p2++;
+         }
+       p++;
+     }
+   *p2 = 0;
+   if (clean_end)
+     {
+       while (p2 > str2)
+         {
+            p2--;
+            if (!(isspace(*p2) || _is_white(*p2))) break;
+            *p2 = 0;
+         }
+     }
+   free(str);
+   return str2;
+}
+
 void
 evas_object_textblock2_text_markup_set(Evas_Object *obj, const char *text)
 {
@@ -818,6 +912,7 @@
                              {
                                 strncpy(ts, s, p - s);
                                 ts[p - s] = 0;
+                                ts = _clean_white(0, 0, ts);
                                 evas_textblock2_cursor_text_append(o->cursor, 
ts);
                                 free(ts);
                              }
@@ -848,6 +943,7 @@
                              {
                                 strncpy(ts, s, p - s);
                                 ts[p - s] = 0;
+                                ts = _clean_white(0, 0, ts);
                                 evas_textblock2_cursor_text_append(o->cursor, 
ts);
                                 free(ts);
                              }
@@ -1449,43 +1545,6 @@
    return fmt2;
 }
 
-static int
-_is_white(int c)
-{
-   /*
-    * unicode list of whitespace chars
-    *
-    * 0009..000D <control-0009>..<control-000D>
-    * 0020 SPACE
-    * 0085 <control-0085>
-    * 00A0 NO-BREAK SPACE
-    * 1680 OGHAM SPACE MARK
-    * 180E MONGOLIAN VOWEL SEPARATOR
-    * 2000..200A EN QUAD..HAIR SPACE
-    * 2028 LINE SEPARATOR
-    * 2029 PARAGRAPH SEPARATOR
-    * 202F NARROW NO-BREAK SPACE
-    * 205F MEDIUM MATHEMATICAL SPACE
-    * 3000 IDEOGRAPHIC SPACE
-    */
-   if (
-       (c == 0x20) ||
-       ((c >= 0x9) && (c <= 0xd)) ||
-       (c == 0x85) ||
-       (c == 0xa0) ||
-       (c == 0x1680) ||
-       (c == 0x180e) ||
-       ((c >= 0x2000) && (c <= 0x200a)) ||
-       (c == 0x2028) ||
-       (c == 0x2029) ||
-       (c == 0x202f) ||
-       (c == 0x205f) ||
-       (c == 0x3000)
-       )
-     return 1;
-   return 0;
-}
-
 static void
 _layout(Evas_Object *obj, int calc_only, int w, int h, int *w_ret, int *h_ret)
 {




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to