I solve this problem (but this patch is NOT for latest CVS version).

But may work :-). not tested


--- /home/davinchi/downloaded/e17/libs/evas/src/lib/canvas/evas_object_textblock.c	2005-04-03 19:22:16 +0500
+++ src/lib/canvas/evas_object_textblock.c	2005-05-18 22:50:08 +0500
@@ -1684,7 +1684,7 @@ evas_object_textblock_layout_node_pos_ge
 {
    Evas_Object_Textblock *o;
    Evas_Object_List *l;
-   int p = 0;
+   int p, ps = 0;
    Layout_Node *lnode = NULL;
    
    o = (Evas_Object_Textblock *)(obj->object_data);
@@ -1694,15 +1694,20 @@ evas_object_textblock_layout_node_pos_ge
 	lnode = (Layout_Node *)l;
 	if (lnode->text)
 	  {
-	     p = lnode->text_pos + lnode->text_len;
-	     if (p > pos)
-	       {
-		  p = lnode->text_pos;
-		  break;
-	       }
+	     //fprintf(stderr,"lnode->text = %s\nlnode->text_len = %d\n", lnode->text, lnode->text_len);
+	     ps = p;
+	     p += lnode->text_len;
+	     if (p > pos) break;
+
+//	     p = lnode->text_pos + lnode->text_len;
+//	     if (p > pos)
+//	       {
+//		  p = lnode->text_pos;
+//		  break;
+//	       }
 	  }
      }
-   *pstart = p;
+   *pstart = ps;
    if (lnode && !lnode->text) lnode = NULL;
    return lnode;
 }
@@ -2120,20 +2125,53 @@ evas_object_textblock_char_pos_get(Evas_
    MAGIC_CHECK_END();
    if (o->format.dirty)
      evas_object_textblock_format_calc(obj);
-   lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
+   //lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
+   lnode = evas_object_textblock_layout_node_pos_get(obj, pos, &ps);
+   //fprintf(stderr,"lnode->text = %s\no->pos = %d\npos = %d\n", lnode->text, o->pos, pos);
    if (lnode)
      {
-	int ret, x = 0, y = 0, w = 0, h = 0;
+	int ret, x = 0, y = 0, w = 0, h = 0, pos1, is_last = 0;
 	
 	if (lnode->layout.font.font)
 	  {
+	     /* Get relative posittion (from lnode start)
+	      * if it is are equal to text_len - then use new algorithm
+	      */
+	     pos1 = pos - lnode->text_pos;
+
+	     //fprintf(stderr,"pos1 = %d, lnode->text_len = %d\n", pos1,
+	     //		lnode->text_len);
+	     /* FIXED: if it's a last char, than old algorithm
+	      * set pos1 to 0 and x, y, w, h = 0
+	      * and cursor is moved to begin of line :-(
+	      */
+	     /* Fixed with this ugly fix :-)
+	     */
+	     if(pos1 == lnode->text_len)
+	       {
+		  pos1--;
+		  is_last = 1;
+	       }
+
+
 	     ret = ENFN->font_char_coords_get(ENDT, lnode->layout.font.font,
 					      lnode->text,
-					      pos - lnode->text_pos,
+					      pos1,
 					      &x, &y, &w, &h);
 	     y = lnode->layout.line.y;
 	     x += lnode->layout.line.x;
 	     h = lnode->layout.line.mascent + lnode->layout.line.mdescent;
+
+	     /* If it's last then we set pos1 to previous position, get
+	      * it's x and width, and add width to x coordinate.
+	      * That's way we get x after last character
+	      */
+	     if(is_last)
+	       {
+		  x = x + w;
+		  w = 0;
+	       }
+
 	     if (cx) *cx = x;
 	     if (cy) *cy = y;
 	     if (cw) *cw = w;

Reply via email to