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:


wherd wap!

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_textblock.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- evas_object_textblock.c     31 Jan 2005 16:49:13 -0000      1.15
+++ evas_object_textblock.c     1 Feb 2005 07:17:00 -0000       1.16
@@ -10,7 +10,6 @@
  * 
  * things to add:
  * 
- * * word wrap
  * * underline support
  * * double underline support
  * * strikethrough support
@@ -71,6 +70,7 @@
       int               inset, x, y, ascent, descent, mascent, mdescent;
    } line;
    double               align, valign;
+   unsigned char        word_wrap : 1;
 };
 
 /* a node of formatting data */
@@ -273,6 +273,11 @@
             layout->color.a = a;
          }
      }
+   else if (!strcmp(key, "wrap"))
+     {
+       if (!strcmp(data, "word")) layout->word_wrap = 1;
+       else layout->word_wrap = 0;
+     }
 }
 
 static void
@@ -453,6 +458,43 @@
      }
 }
 
+static int
+evas_object_textblock_char_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
 evas_object_textblock_layout(Evas_Object *obj)
 {
@@ -554,6 +596,26 @@
             /* text doesnt fit */
             else
               {
+                 /* handle word wrap */
+                 if (layout.word_wrap)
+                   {
+                      int ppos, pos, chr;
+                      
+                      pos = evas_string_char_prev_get(text, chrpos, &chr);
+                      if (!evas_object_textblock_char_is_white(chr))
+                        {
+                           ppos = pos = chrpos;
+                           while ((!evas_object_textblock_char_is_white(chr))
+                                  &&
+                                  (pos >= 0))
+                             {
+                                ppos = pos;
+                                pos = evas_string_char_prev_get(text, pos, 
&chr);
+                             }
+                           if (ppos < 0) ppos = 0;
+                           chrpos = ppos;
+                        }
+                   }
                  /* if the first char in the line can't fit!!! */
                  if ((chrpos == 0) && (lnode == line_start))
                    {




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to