Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src


Modified Files:
        etox.c 


Log Message:
A little reworking of the delete function, the visible clip box after deleting
all text is a known issue.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -3 -r1.97 -r1.98
--- etox.c      13 Oct 2004 14:30:19 -0000      1.97
+++ etox.c      21 Oct 2004 19:13:04 -0000      1.98
@@ -478,41 +478,83 @@
 void etox_delete_text(Evas_Object * obj, unsigned int index, unsigned int len)
 {
        Etox *et;
-       Etox_Line *start, *idx;
+       Etox_Line *start, *idx, *end;
        Evas_Object *bit;
+       Evas_List *ll;
        int orig_index = index;
 
        CHECK_PARAM_POINTER("obj", obj);
 
        et = evas_object_smart_data_get(obj);
 
+       /*
+        * If the line containing the index cannot be located, there is
+        * nothing useful to be done.
+        */
        start = etox_index_to_line(et, &index);
        if (!start) return;
 
+       /*
+        * Break the line at the found character in preparation for removing
+        * the characters in the split section. The lines between will be
+        * deleted.
+        */
        bit = etox_line_index_to_bit(start, &index);
        etox_line_split(start, bit, index);
 
-       index++;
+       /*
+        * Locate the next character's line, this was newly created when
+        * breaking the text.
+        */
+       index = orig_index + 1;
        idx = etox_index_to_line(et, &index);
        if (!idx) return;
 
-       bit = etox_line_index_to_bit(idx, &index);
-       if (!bit) {
-               evas_list_remove(et->lines, idx);
-               etox_line_free(idx);
-               return;
+       /*
+        * Find the last bit in the selection, if the length goes off the end
+        * of the etox, this will be NULL, and the loop will remove the
+        * remaining text in the etox.
+        */
+       index = orig_index + len;
+       end = etox_index_to_line(et, &index);
+       if (end) {
+               bit = etox_line_index_to_bit(end, &index);
+               if (bit)
+                       etox_line_split(end, bit, index);
        }
 
+       index = orig_index + len + 1;
+       end = etox_index_to_line(et, &index);
+
+       ll = evas_list_find_list(et->lines, idx);
+
        /*
-        * these +1's are here cuz the etox length seems to be +1 for some
-        * reason so this just accomidates that
+        * Remove all lines until the end of the selected text is reached.
         */
+       while (idx && idx != end) {
+               int len;
+               idx = ll->data;
+               ll = ll->next;
+               et->lines = evas_list_remove(et->lines, idx);
+               len = idx->length;
+               etox_line_free(idx);
+               et->length -= len;
+       }
+
+       if (start && end)
+               etox_line_merge_append(start, end);
+
+       /*
        if (idx->length == len) {
+       */
+               /*
+                * Remove the last bit
+                */
+/*
                etox_line_remove(idx, bit);
                evas_list_remove(et->lines, idx);
                etox_line_free(idx);
                et->length -= len;
-
        }
        else if (idx->length > len) {
                Etox_Line *end = NULL;
@@ -535,19 +577,26 @@
                etox_line_free(idx);
                etox_line_free(end);
 
-       } else {
+       }
+       else {
                etox_line_remove(idx, bit);
                evas_list_remove(et->lines, idx);
                etox_line_free(idx);
+               et->length -= len;
+               */
 
                /* FIXME */
+/*
                printf("WARNING: etox_delete_text, this isn't finished\n");
        }
+       */
        etox_line_minimize(start);
 
        etox_layout(et);
        if (et->lines && evas_object_visible_get(obj))
                evas_object_show(et->clip);
+       else
+               evas_object_hide(et->clip);
 }
 
 /**
@@ -604,6 +653,8 @@
        etox_layout(et);
        if (et->lines && evas_object_visible_get(obj))
                evas_object_show(et->clip);
+       else
+               evas_object_hide(et->clip);
 }
 
 /**




-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to