Enlightenment CVS committal

Author  : moom
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_main.c etk_string.h etk_textblock.c etk_textblock.h 


Log Message:
* [Textblock] etk_textblock_range_text_get() now works


===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_main.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- etk_main.c  13 Aug 2006 19:20:28 -0000      1.30
+++ etk_main.c  21 Aug 2006 11:18:28 -0000      1.31
@@ -137,7 +137,6 @@
       etk_signal_shutdown();
       etk_type_shutdown();
       
-      etk_textblock_shutdown();
       etk_tooltips_shutdown();
       etk_dnd_shutdown();
       etk_engine_shutdown();
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_string.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- etk_string.h        25 Jul 2006 01:09:25 -0000      1.4
+++ etk_string.h        21 Aug 2006 11:18:28 -0000      1.5
@@ -42,7 +42,7 @@
 Etk_String *etk_string_copy(const Etk_String *string);
 
 const char *etk_string_get(Etk_String *string);
-int etk_string_length_get(Etk_String *string);
+int         etk_string_length_get(Etk_String *string);
 Etk_String *etk_string_truncate(Etk_String *string, int length);
 Etk_String *etk_string_delete(Etk_String *string, int pos, int size);
 Etk_String *etk_string_clear(Etk_String *string);
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_textblock.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- etk_textblock.c     20 Aug 2006 20:41:20 -0000      1.27
+++ etk_textblock.c     21 Aug 2006 11:18:28 -0000      1.28
@@ -16,6 +16,7 @@
 #define ETK_TB_OBJECT_DEFAULT_HEIGHT 300
 #define ETK_TB_EMPTY_LINE_WIDTH 3
 
+/* TODO: in the theme */
 #define ETK_TB_OBJECT_SHOW_CURSOR_DELAY 0.75
 #define ETK_TB_OBJECT_HIDE_CURSOR_DELAY 0.25
 
@@ -172,16 +173,6 @@
  **************************/
 
 /**
- * @internal
- * @brief Shutdowns the textblock system.
- * It justs frees the hash table used to store the results of 
etk_textblock_char_size_get()
- */
-void etk_textblock_shutdown()
-{
-   
-}
-
-/**
  * @brief Gets the type of an Etk_Textblock
  * @return Returns the type of an Etk_Textblock
  */
@@ -1169,6 +1160,36 @@
 }
 
 /**
+ * @brief Gets the cursor's iterator of the textblock object
+ * @param tbo a textblock object
+ * @return Returns the cursor's iterator of the textblock object
+ * @warning You should not free the returned iterator
+ */
+Etk_Textblock_Iter *etk_textblock_object_cursor_get(Evas_Object *tbo)
+{
+   Etk_Textblock_Object_SD *tbo_sd;
+   
+   if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo)))
+      return NULL;
+   return tbo_sd->cursor;
+}
+
+/**
+ * @brief Gets the selection bound's iterator of the textblock object
+ * @param tbo a textblock object
+ * @return Returns the selection bound's iterator of the textblock object
+ * @warning You should not free the returned iterator
+ */
+Etk_Textblock_Iter *etk_textblock_object_selection_bound_get(Evas_Object *tbo)
+{
+   Etk_Textblock_Object_SD *tbo_sd;
+   
+   if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo)))
+      return NULL;
+   return tbo_sd->selection;
+}
+
+/**
  * @brief Sets whether the cursor of the textblock object is visible or not
  * @param tbo a textblock object
  * @param visible ETK_TRUE to show the cursor, ETK_FALSE to hide it
@@ -1218,36 +1239,6 @@
    return tbo_sd->cursor_visible;
 }
 
-/**
- * @brief Gets the cursor's iterator of the textblock object
- * @param tbo a textblock object
- * @return Returns the cursor's iterator of the textblock object
- * @warning You should not free the returned iterator
- */
-Etk_Textblock_Iter *etk_textblock_object_cursor_get(Evas_Object *tbo)
-{
-   Etk_Textblock_Object_SD *tbo_sd;
-   
-   if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo)))
-      return NULL;
-   return tbo_sd->cursor;
-}
-
-/**
- * @brief Gets the selection bound's iterator of the textblock object
- * @param tbo a textblock object
- * @return Returns the selection bound's iterator of the textblock object
- * @warning You should not free the returned iterator
- */
-Etk_Textblock_Iter *etk_textblock_object_selection_bound_get(Evas_Object *tbo)
-{
-   Etk_Textblock_Object_SD *tbo_sd;
-   
-   if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo)))
-      return NULL;
-   return tbo_sd->selection;
-}
-
 /**************************
  * Misc funcs
  **************************/
@@ -2070,11 +2061,13 @@
 /* Gets recursively the text of the node */ 
 static void _etk_textblock_node_text_get(Etk_Textblock_Node *node, Etk_Bool 
markup, Etk_String *text, Etk_Textblock_Iter *start_iter, Etk_Textblock_Iter 
*end_iter)
 {
-   if (!node || !text)
-      return;
-   
    Etk_String *start_tag = NULL;
    Etk_String *end_tag = NULL;
+   int text_len;
+   Etk_Bool end_of_line = ETK_TRUE;
+   
+   if (!node || !text)
+      return;
    
    if (markup)
    {
@@ -2191,18 +2184,91 @@
    /* Builds the text of the node */
    etk_string_append(text, etk_string_get(start_tag));
    
-   if (node->text)
-      etk_string_append(text, etk_string_get(node->text));
-   else
+   /* Add the text of the node */
+   text_len = etk_string_length_get(node->text);
+   if (text_len > 0)
+   {
+      const char *node_text;
+      int start_pos;
+      int len;
+      
+      node_text = etk_string_get(node->text);
+      start_pos = (start_iter && node == start_iter->node) ? start_iter->index 
: 0;
+      start_pos = ETK_MIN(start_pos, text_len - 1);
+      if (end_iter && node == end_iter->node)
+      {
+         len = end_iter->pos - start_pos;
+         len = ETK_MIN(len, text_len - start_pos);
+         etk_string_append_sized(text, &node_text[start_pos], len);
+      }
+      else
+         etk_string_append(text, &node_text[start_pos]);
+   }
+   
+   /* Adds recursively the text of the children */
+   if (node->children)
    {
+      Evas_List *node_hierarchy;
+      Etk_Textblock_Node *start_node, *end_node;
       Etk_Textblock_Node *n;
+      int depth;
+      Etk_Bool add_child;
+      Etk_Bool found;
+      
+      depth = 0;
+      for (n = node; n; n = n->parent)
+         depth++;
+      
+      if (!start_iter)
+         start_node = NULL;
+      else
+      {
+         node_hierarchy = NULL;
+         found = ETK_FALSE;
+         for (n = start_iter->node; n; n = n->parent)
+         {
+            node_hierarchy = evas_list_prepend(node_hierarchy, n);
+            if (node == n)
+               found = ETK_TRUE;
+         }
+         start_node = found ? evas_list_nth(node_hierarchy, depth) : NULL;
+         evas_list_free(node_hierarchy);
+      }
       
+      if (!end_iter)
+         end_node = NULL;
+      else
+      {
+         node_hierarchy = NULL;
+         found = ETK_FALSE;
+         for (n = end_iter->node; n; n = n->parent)
+         {
+            node_hierarchy = evas_list_prepend(node_hierarchy, n);
+            if (node == n)
+            {
+               end_of_line = ETK_FALSE;
+               found = ETK_TRUE;
+            }
+         }
+         end_node = found ? evas_list_nth(node_hierarchy, depth) : NULL;
+         evas_list_free(node_hierarchy);
+      }
+      
+      add_child = (start_node == NULL);
       for (n = node->children; n; n = n->next)
-         _etk_textblock_node_text_get(n, markup, text, start_iter, end_iter);
+      {
+         if (n == start_node)
+            add_child = ETK_TRUE;
+         if (add_child)
+            _etk_textblock_node_text_get(n, markup, text, start_iter, 
end_iter);
+         if (n == end_node)
+            add_child = ETK_FALSE;
+      }
    }
    
    etk_string_append(text, etk_string_get(end_tag));
-   if (node->type == ETK_TEXTBLOCK_NODE_LINE && node->next)
+   
+   if (node->type == ETK_TEXTBLOCK_NODE_LINE && 
_etk_textblock_next_line_get(node) && end_of_line)
       etk_string_append_char(text, '\n');
    
    etk_object_destroy(ETK_OBJECT(start_tag));
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_textblock.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- etk_textblock.h     20 Aug 2006 20:41:20 -0000      1.16
+++ etk_textblock.h     21 Aug 2006 11:18:28 -0000      1.17
@@ -202,12 +202,10 @@
 };
 
 /* Textblock's funcs */
-void etk_textblock_shutdown();
-
-Etk_Type *etk_textblock_type_get();
+Etk_Type      *etk_textblock_type_get();
 Etk_Textblock *etk_textblock_new();
 
-void etk_textblock_text_set(Etk_Textblock *tb, const char *text, Etk_Bool 
markup);
+void        etk_textblock_text_set(Etk_Textblock *tb, const char *text, 
Etk_Bool markup);
 Etk_String *etk_textblock_text_get(Etk_Textblock *tb, Etk_Bool markup);
 Etk_String *etk_textblock_range_text_get(Etk_Textblock *tb, Etk_Textblock_Iter 
*iter1, Etk_Textblock_Iter *iter2, Etk_Bool markup);
 
@@ -220,36 +218,34 @@
 void etk_textblock_delete_range(Etk_Textblock *tb, Etk_Textblock_Iter *iter1, 
Etk_Textblock_Iter *iter2);
 
 /* Textblock iter's funcs */
-Etk_Textblock_Iter *etk_textblock_iter_new(Etk_Textblock *tb);
-void etk_textblock_iter_free(Etk_Textblock_Iter *iter);
-
-void etk_textblock_iter_gravity_set(Etk_Textblock_Iter *iter, 
Etk_Textblock_Gravity gravity);
+Etk_Textblock_Iter   *etk_textblock_iter_new(Etk_Textblock *tb);
+void                  etk_textblock_iter_free(Etk_Textblock_Iter *iter);
+void                  etk_textblock_iter_gravity_set(Etk_Textblock_Iter *iter, 
Etk_Textblock_Gravity gravity);
 Etk_Textblock_Gravity etk_textblock_iter_gravity_get(Etk_Textblock_Iter *iter);
 
-void etk_textblock_iter_backward_start(Etk_Textblock_Iter *iter);
-void etk_textblock_iter_forward_end(Etk_Textblock_Iter *iter);
+void     etk_textblock_iter_backward_start(Etk_Textblock_Iter *iter);
+void     etk_textblock_iter_forward_end(Etk_Textblock_Iter *iter);
 Etk_Bool etk_textblock_iter_backward_char(Etk_Textblock_Iter *iter);
 Etk_Bool etk_textblock_iter_forward_char(Etk_Textblock_Iter *iter);
 
 void etk_textblock_iter_copy(Etk_Textblock_Iter *dest, const 
Etk_Textblock_Iter *src);
-int etk_textblock_iter_compare(Etk_Textblock_Iter *iter1, Etk_Textblock_Iter 
*iter2);
+int  etk_textblock_iter_compare(Etk_Textblock_Iter *iter1, Etk_Textblock_Iter 
*iter2);
 
 /* Textblock object's funcs */
-Evas_Object *etk_textblock_object_add(Etk_Textblock *tb, Evas *evas);
-
-void etk_textblock_object_wrap_set(Evas_Object *tbo, Etk_Textblock_Wrap wrap);
+Evas_Object       *etk_textblock_object_add(Etk_Textblock *tb, Evas *evas);
+void               etk_textblock_object_wrap_set(Evas_Object *tbo, 
Etk_Textblock_Wrap wrap);
 Etk_Textblock_Wrap etk_textblock_object_wrap_get(Evas_Object *tbo);
 
-void etk_textblock_object_cursor_visible_set(Evas_Object *tbo, Etk_Bool 
visible);
-Etk_Bool etk_textblock_object_cursor_visible_get(Evas_Object *tbo);
 Etk_Textblock_Iter *etk_textblock_object_cursor_get(Evas_Object *tbo);
 Etk_Textblock_Iter *etk_textblock_object_selection_bound_get(Evas_Object *tbo);
+void                etk_textblock_object_cursor_visible_set(Evas_Object *tbo, 
Etk_Bool visible);
+Etk_Bool            etk_textblock_object_cursor_visible_get(Evas_Object *tbo);
 
 /* Misc funcs */
-int etk_textblock_unicode_length_get(const char *unicode_string);
+int      etk_textblock_unicode_length_get(const char *unicode_string);
 Etk_Bool etk_textblock_is_white_char(int c);
-void etk_textblock_char_size_get(Evas *evas, const char *font_face, int 
font_size, int *w, int *h);
-void etk_textblock_printf(Etk_Textblock *tb);
+void     etk_textblock_char_size_get(Evas *evas, const char *font_face, int 
font_size, int *w, int *h);
+void     etk_textblock_printf(Etk_Textblock *tb);
 
 /** @} */
  



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to