Re: [Bug 60630] Changed - Cursor position not always displayed in GtkTextView



> To: gtk-bugs gtk org, padraig obriain sun com
> Subject: [Bug 60630] Changed - Cursor position not always displayed in 
GtkTextView
> 
> http://bugzilla.gnome.org/show_bug.cgi?id=60630
> 
> *** shadow/60630	Mon Sep 17 08:16:53 2001
> --- shadow/60630.tmp.2769	Tue Sep 18 04:32:45 2001
> ***************
> *** 21,23 ****
> --- 21,30 ----
>   Move the cursor to just before the last "text" in line 2. Press the up
>   arrow key. The cursor is at the end of line 1 but the start of line 1 is on
>   the screen.
> + 
> + ------- Additional Comments From padraig obriain sun com  2001-09-18 04:32 
-------
> + The function gtk_text_layout_get_iter_location() seems to return the
> + wrong rectangle. The problem seems to be the behavior of
> + pango_layout_index_to_pos() when the byte index corresponds to the end
> + of the line. The function pango_layout_iter_get_run_extents() is
> + called with NULL ink extents.
> 

I propose the following change to fix this problem. Can this change be 
committed?

RCS file: /cvs/gnome/gtk+/gtk/gtktextlayout.c,v
retrieving revision 1.69
diff -u -p -r1.69 gtktextlayout.c
--- gtktextlayout.c     2001/09/07 22:32:02     1.69
+++ gtktextlayout.c     2001/09/18 08:53:56
@@ -2289,15 +2289,30 @@ gtk_text_layout_get_iter_location (GtkTe
 
   x_offset = display->x_offset * PANGO_SCALE;
 
-  byte_index = gtk_text_iter_get_line_index (iter);
+  if (gtk_text_iter_ends_line (iter))
+    {
+      gtk_text_iter_backward_cursor_position (iter);
+      byte_index = gtk_text_iter_get_line_index (iter);
+ 
+      pango_layout_index_to_pos (display->layout, byte_index, &pango_rect);
   
-  pango_layout_index_to_pos (display->layout, byte_index, &pango_rect);
+      rect->x = PANGO_PIXELS (x_offset + pango_rect.x + pango_rect.width);
+      rect->y += PANGO_PIXELS (pango_rect.y + pango_rect.height) 
+                 + display->top_margin;
+      rect->width = PANGO_PIXELS (0);
+      rect->height = PANGO_PIXELS (pango_rect.height);
+    }
+  else
+    { 
+      byte_index = gtk_text_iter_get_line_index (iter);
+ 
+      pango_layout_index_to_pos (display->layout, byte_index, &pango_rect);
   
-  rect->x = PANGO_PIXELS (x_offset + pango_rect.x);
-  rect->y += PANGO_PIXELS (pango_rect.y) + display->top_margin;
-  rect->width = PANGO_PIXELS (pango_rect.width);
-  rect->height = PANGO_PIXELS (pango_rect.height);
-
+      rect->x = PANGO_PIXELS (x_offset + pango_rect.x);
+      rect->y += PANGO_PIXELS (pango_rect.y) + display->top_margin;
+      rect->width = PANGO_PIXELS (pango_rect.width);
+      rect->height = PANGO_PIXELS (pango_rect.height);
+    }
   gtk_text_layout_free_line_display (layout, display);
 }





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]