Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src


Modified Files:
        Etox.h Etox_private.h etox.c etox_context.c etox_line.c 
        etox_line.h 


Log Message:
More work on line wrapping, inserts a red "+" at the beginning of wrapped
lines for the time being. Text wrapping is now enabled by default. Also modified
the test programs to handle window resizing. I have seen one odd wrapping
case, I'll commit another fix once I figure out how to reproduce it.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/Etox.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- Etox.h      28 Jul 2003 22:04:31 -0000      1.35
+++ Etox.h      1 Aug 2003 21:12:13 -0000       1.36
@@ -18,6 +18,8 @@
        ETOX_ALIGN_BOTTOM = 8
 };
 
+#define ETOX_ALIGN_MASK 0xF
+
 /*
  * The color struct simply keeps track of the various colors available
  */
@@ -250,6 +252,7 @@
 /*
  * Context management functions
  */
+Etox_Context *etox_context_new();
 Etox_Context *etox_context_save(Etox * et);
 void etox_context_load(Etox * et, Etox_Context * context);
 void etox_context_free(Etox_Context * context);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/Etox_private.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- Etox_private.h      23 Jul 2003 16:37:39 -0000      1.16
+++ Etox_private.h      1 Aug 2003 21:12:13 -0000       1.17
@@ -33,9 +33,12 @@
 };
 
 void etox_layout(Etox * et);
+Estyle * etox_split_bit(Etox_Line *line, Estyle *bit, int index);
 
 Etox_Line * etox_coord_to_line(Etox *et, int y);
 Etox_Line * etox_index_to_line(Etox *et, int *i);
+
+void etox_print_lines(Etox *et);
 
 #include "etox_line.h"
 #include "etox_obstacle.h"
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -3 -r1.50 -r1.51
--- etox.c      31 Jul 2003 21:39:30 -0000      1.50
+++ etox.c      1 Aug 2003 21:12:13 -0000       1.51
@@ -21,37 +21,12 @@
        et = (Etox *) calloc(1, sizeof(Etox));
 
        et->evas = evas;
+       evas_font_path_append(evas, PACKAGE_DATA_DIR "/fonts");
 
        /*
-        * Allocate space for the default context
+        * Allocate the default context
         */
-       et->context = (Etox_Context *) calloc(1, sizeof(Etox_Context));
-
-       /*
-        * Setup the default color
-        */
-       et->context->r = 255;
-       et->context->g = 255;
-       et->context->b = 255;
-       et->context->a = 255;
-
-       /*
-        * Setup the default style
-        */
-       et->context->style = strdup("outline");
-
-       /*
-        * Set up the default font
-        */
-       evas_font_path_append(evas,
-                       PACKAGE_DATA_DIR "/fonts");
-       et->context->font = strdup("nationff");
-       et->context->font_size = 14;
-
-       /*
-        * Setup the default alignment
-        */
-       et->context->flags = ETOX_ALIGN_LEFT | ETOX_ALIGN_BOTTOM;
+       et->context = etox_context_new();
 
        /*
         * Set the clip rectangle for the etox
@@ -59,16 +34,6 @@
        et->clip = evas_object_rectangle_add(evas);
        evas_object_color_set(et->clip, 255, 255, 255, 255);
 
-       /*
-        * Set up a default blank wrap marker
-        */
-       et->context->marker.text = "";
-       et->context->marker.style = "plain";
-       et->context->marker.r = 255;
-       et->context->marker.g = 255;
-       et->context->marker.b = 255;
-       et->context->marker.a = 255;
-
        return et;
 }
 
@@ -96,7 +61,7 @@
         * passed in to etox_new_all.
         */
        et = etox_new(evas);
-       et->context->flags = align;
+       et->context->flags = align | ETOX_SOFT_WRAP;
        et->x = x;
        et->y = y;
        et->w = w;
@@ -122,14 +87,15 @@
        CHECK_PARAM_POINTER("et", et);
 
        etox_clear(et);
-       FREE(et->context->style);
+       etox_context_free(et->context);
        etox_selection_free_by_etox(et);
 
-       for (l = et->obstacles; l; l = evas_list_remove(l, obst)) {
+       l = et->obstacles;
+       while (l) {
                obst = l->data;
+               l = evas_list_remove(l, obst);
                FREE(obst);
        }
-
 }
 
 /**
@@ -629,6 +595,8 @@
        if (et->w == w && et->h == h)
                return;
 
+       et->w = w;
+
        /*
         * Layout lines if appropriate.
         */
@@ -1130,6 +1098,8 @@
                if ((et->context->flags & ETOX_SOFT_WRAP) && (line->w > et->w))
                                etox_line_wrap(et, line);
 
+               etox_print_lines(et);
+
                l = l->next;
                y += line->h;
        }
@@ -1185,4 +1155,17 @@
                *i -= len - line->length;
 
        return line;
+}
+
+void
+etox_print_lines(Etox *et)
+{
+       int i = 0;
+       Evas_List *l;
+
+       for (l = et->lines; l; l = l->next) {
+               printf("Line %d:\n", i);
+               etox_line_print_bits(l->data);
+               i++;
+       }
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_context.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- etox_context.c      24 Jul 2003 05:34:44 -0000      1.8
+++ etox_context.c      1 Aug 2003 21:12:13 -0000       1.9
@@ -9,11 +9,45 @@
  */
 Etox_Context *etox_context_new()
 {
-       Etox_Context *ret;
+       Etox_Context *context;
 
-       ret = (Etox_Context *) calloc(1, sizeof(Etox_Context));
+       context = (Etox_Context *) calloc(1, sizeof(Etox_Context));
 
-       return ret;
+       /*
+        * Setup the default color
+        */
+       context->r = 255;
+       context->g = 255;
+       context->b = 255;
+       context->a = 255;
+
+       /*
+        * Setup the default style
+        */
+       context->style = strdup("none");
+
+       /*
+        * Set up the default font
+        */
+       context->font = strdup("nationff");
+       context->font_size = 14;
+
+       /*
+        * Setup the default alignment
+        */
+       context->flags = ETOX_ALIGN_LEFT | ETOX_ALIGN_BOTTOM | ETOX_SOFT_WRAP;
+
+       /*
+        * Set up a default blank wrap marker
+        */
+       context->marker.text = "+";
+       context->marker.style = "plain";
+       context->marker.r = 255;
+       context->marker.g = 0;
+       context->marker.b = 0;
+       context->marker.a = 255;
+
+       return context;
 }
 
 /**
@@ -301,7 +335,7 @@
 {
        CHECK_PARAM_POINTER_RETURN("et", et, FALSE);
 
-       return et->context->flags;
+       return et->context->flags & ETOX_ALIGN_MASK;
 }
 
 /*
@@ -315,7 +349,7 @@
 {
        CHECK_PARAM_POINTER("et", et);
 
-       et->context->flags = align;
+       et->context->flags = align | (et->context->flags & ~ETOX_ALIGN_MASK);
 }
 
 /**
@@ -331,9 +365,9 @@
        CHECK_PARAM_POINTER("et", et);
 
        if (boolean)
-               et->context->flags = et->context->flags | ETOX_SOFT_WRAP;
+               et->context->flags |= ETOX_SOFT_WRAP;
        else
-               et->context->flags = et->context->flags & ~ETOX_SOFT_WRAP;
+               et->context->flags &= ~ETOX_SOFT_WRAP;
 }
 
 /**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- etox_line.c 31 Jul 2003 21:39:30 -0000      1.16
+++ etox_line.c 1 Aug 2003 21:12:13 -0000       1.17
@@ -404,6 +404,9 @@
                while (isspace(tmp[index]))
                        index++;
                FREE(tmp);
+       }
+
+       if (index < estyle_length(bit)) {
 
                etox_line_split(line, bit, index);
                ll = evas_list_find_list(et->lines, line);
@@ -434,31 +437,45 @@
        Etox_Line *newline;
        Estyle *split = NULL;
 
-       etox_line_remove(line, bit);
+       ll = evas_list_find_list(line->bits, bit);
+       ll = ll->next;
+
+       /*
+        * add the newline after the current one
+        */
+       newline = etox_line_new(line->flags | ETOX_LINE_WRAPPED);
+       newline->et = line->et;
+       line->et->lines = evas_list_append_relative(line->et->lines, newline,
+                       line);
 
-       /* split the edge bit */
-       split = estyle_split(bit, index);
-       etox_line_append(line, bit);
-
-       /* if split successful, set up the new bit */
-       if (split) {
-
-               newline = etox_line_new(line->flags | ETOX_LINE_WRAPPED);
-               newline->et = line->et;
-               etox_line_append(newline, split);
-
-               ll = evas_list_find_list(line->bits, bit);
-
-               /* move the remaining bits to the new line */
-               for (ll = ll->next; ll; ll = ll->next) {
-                       bit = ll->data;
-                       etox_line_remove(line, bit);
-                       etox_line_append(newline, bit);
-               }
-
-               /* add the newline after the current one */
-               line->et->lines = evas_list_append_relative(line->et->lines,
-                               newline, line);
+       /*
+        * If the bit starts on the boundary, simply move it to the next line.
+        */
+       if (index) {
+               /* split the edge bit */
+               split = etox_split_bit(line, bit, index);
+               etox_line_remove(line, split);
+       }
+       else {
+               split = bit;
+               etox_line_remove(line, bit);
+       }
+
+       etox_line_append(newline, split);
+
+       /*
+        * move the remaining bits to the new line
+        */
+       while (ll) {
+               /*
+                * Immediately move to the next object, as the node in the
+                * list pointed to by ll will get removed.
+                */
+               bit = ll->data;
+               ll = ll->next;
+
+               etox_line_remove(line, bit);
+               etox_line_append(newline, bit);
        }
 }
 
@@ -466,6 +483,7 @@
 etox_line_unwrap(Etox *et, Etox_Line *line)
 {
        Evas_List *l, *prevline;
+       Estyle *marker;
 
        if (!et->lines)
                return;
@@ -479,7 +497,9 @@
                        break;
 
                /* remove the wrap marker bit */
-               line->bits = evas_list_remove(line->bits, line->bits->data);
+               marker = line->bits->data;
+               line->bits = evas_list_remove(line->bits, marker);
+               estyle_free(marker);
 
                /* remove the line from the list */
                et->lines = evas_list_remove(et->lines, line);
@@ -534,4 +554,16 @@
                *i -= (len - estyle_length(bit));
 
        return bit;
+}
+
+void
+etox_line_print_bits(Etox_Line *line)
+{
+       int i = 0;
+       Evas_List *l;
+
+       for (l = line->bits; l; l = l->next) {
+               printf("\tBit %d: %s\n", i, estyle_get_text(l->data));
+               i++;
+       }
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- etox_line.h 31 Jul 2003 21:39:30 -0000      1.8
+++ etox_line.h 1 Aug 2003 21:12:13 -0000       1.9
@@ -19,5 +19,6 @@
 void etox_line_unwrap(Etox *et, Etox_Line *line);
 Estyle *etox_line_coord_to_bit(Etox_Line *line, int x);
 Estyle *etox_line_index_to_bit(Etox_Line *line, int *i);
+void etox_line_print_bits(Etox_Line *line);
 
 #endif




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to