]> Pileus Git - ~andy/gtk/commitdiff
update cursor_y_pos with clamped delta rather than theoretical delta
authorHavoc Pennington <hp@redhat.com>
Thu, 17 Jan 2002 01:08:59 +0000 (01:08 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Thu, 17 Jan 2002 01:08:59 +0000 (01:08 +0000)
2002-01-16  Havoc Pennington  <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_scroll_pages): update
cursor_y_pos with clamped delta rather than theoretical delta
(#68788). Also, if we can't page up/down further then jump
to top/bottom of the document.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextview.c

index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 382001b16e937401cd1e46aa353997bf4143caed..2be9a43aaa5e069cb0251740cd569b0278c36c84 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-16  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_scroll_pages): update
+       cursor_y_pos with clamped delta rather than theoretical delta
+       (#68788). Also, if we can't page up/down further then jump 
+       to top/bottom of the document.
+
 Wed Jan 16 19:33:41 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh
index 6578876b3dc87128f16a8baa3aedc65ea14c57bd..e862ac9d030d920ad43575f8f6a4b82e47162e35 100644 (file)
@@ -4459,6 +4459,7 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
                             gint         count)
 {
   gdouble newval;
+  gdouble oldval;
   GtkAdjustment *adj;
   gint cursor_x_pos, cursor_y_pos;
   GtkTextIter new_insert;
@@ -4486,22 +4487,38 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
 
   gtk_text_layout_validate_yrange (text_view->layout, &anchor, y0, y1);
   /* FIXME do we need to update the adjustment ranges here? */
-  
-  gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos);
-
-  newval = adj->value;
 
-  newval += count * adj->page_increment;
+  if (count < 0 && adj->value <= (adj->lower + 1e-12))
+    {
+      /* already at top, just be sure we are at offset 0 */
+      gtk_text_buffer_get_start_iter (get_buffer (text_view), &new_insert);
+      gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
+    }
+  else if (count > 0 && adj->value >= (adj->upper - adj->page_size - 1e-12))
+    {
+      /* already at bottom, just be sure we are at the end */
+      gtk_text_buffer_get_end_iter (get_buffer (text_view), &new_insert);
+      gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
+    }
+  else
+    {
+      gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos);
 
-  cursor_y_pos += newval - adj->value;
-  set_adjustment_clamped (adj, newval);
+      newval = adj->value;
+      oldval = adj->value;
+  
+      newval += count * adj->page_increment;
 
-  gtk_text_layout_get_iter_at_pixel (text_view->layout, &new_insert, cursor_x_pos, cursor_y_pos);
-  clamp_iter_onscreen (text_view, &new_insert);
-  gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
+      set_adjustment_clamped (adj, newval);
+      cursor_y_pos += adj->value - oldval;
 
-  gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, cursor_y_pos);
+      gtk_text_layout_get_iter_at_pixel (text_view->layout, &new_insert, cursor_x_pos, cursor_y_pos);
+      clamp_iter_onscreen (text_view, &new_insert);
+      gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
 
+      gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, cursor_y_pos);
+    }
+  
   /* Adjust to have the cursor _entirely_ onscreen, move_mark_onscreen
    * only guarantees 1 pixel onscreen.
    */