Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_text.c ewl_text.h 


Log Message:
- Add ewl_text_clear(Ewl_Text). This is what _insert would do on a NULL before. 
Make
  sure it clears out selections and triggers.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_text.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- ewl_text.c  17 Nov 2005 15:36:54 -0000      1.52
+++ ewl_text.c  21 Nov 2005 03:55:47 -0000      1.53
@@ -297,6 +297,47 @@
 }
 
 /**
+ * @param t: The Ewl_Text to clear
+ * @return Returns no value
+ */
+void
+ewl_text_clear(Ewl_Text *t)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("t", t);
+       DCHECK_TYPE("t", t, "text");
+
+       if (t->length > 0)
+       {
+               ewl_text_cursor_position_set(t, 0);
+               ewl_text_text_delete(t, t->length);
+       }
+       t->text = NULL;
+       t->length = 0;
+       t->total_size = 0;
+       t->cursor_position = 0;
+
+       /* clean out the triggers */
+       if (t->triggers)
+       {
+               Ewl_Text_Trigger *trig;
+
+               while ((trig = ecore_list_remove_first(t->triggers)))
+               {
+                       trig->text_parent = NULL;
+                       ewl_widget_destroy(EWL_WIDGET(trig));
+               }
+       }
+
+       /* cleanup the selection */
+       ewl_text_trigger_base_set(t->selection, 0);
+       ewl_text_trigger_start_pos_set(t->selection, 0);
+        ewl_text_trigger_length_set(t->selection, 0);
+       
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
  * @param t: The Ewl_Text to set the text into
  * @param text: The text to set into the widget
  * @return Returns no value
@@ -308,11 +349,9 @@
        DCHECK_PARAM_PTR("t", t);
        DCHECK_TYPE("t", t, "text");
 
-       t->cursor_position = 0;
-       ewl_text_text_insert(t, NULL, t->cursor_position);
+       ewl_text_clear(t);
        ewl_text_text_insert(t, text, t->cursor_position);
 
-
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -329,7 +368,6 @@
 
        ewl_text_text_insert(t, text, 0);
 
-
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -347,7 +385,6 @@
 
        ewl_text_text_insert(t, text, t->length);
 
-
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -368,15 +405,7 @@
 
        if (!text)
        {
-               if (t->length > 0)
-               {
-                       ewl_text_cursor_position_set(t, 0);
-                       ewl_text_text_delete(t, t->length);
-               }
-               t->text = NULL;
-               t->length = 0;
-               t->total_size = 0;
-               t->cursor_position = 0;
+               ewl_text_clear(t);
        }
        else if (!t->text)
        {
@@ -4721,4 +4750,3 @@
        DRETURN_INT(idx, DLEVEL_STABLE);
 }
 
-
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_text.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ewl_text.h  17 Nov 2005 06:45:23 -0000      1.21
+++ ewl_text.h  21 Nov 2005 03:55:47 -0000      1.22
@@ -74,6 +74,8 @@
 
 char           *ewl_text_text_get(Ewl_Text *t);
 void            ewl_text_text_set(Ewl_Text *t, const char *text);
+void            ewl_text_clear(Ewl_Text *t);
+
 void            ewl_text_text_prepend(Ewl_Text *t, const char *text);
 void            ewl_text_text_append(Ewl_Text *t, const char *text);
 void            ewl_text_text_insert(Ewl_Text *t, const char *text, 




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to