From fe622071f69379a77a0b62a75e6243515ed79df1 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 17 Jan 2002 01:08:59 +0000 Subject: [PATCH] update cursor_y_pos with clamped delta rather than theoretical delta 2002-01-16 Havoc Pennington * 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 | 7 +++++++ ChangeLog.pre-2-0 | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-2 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ gtk/gtktextview.c | 41 +++++++++++++++++++++++++++++------------ 8 files changed, 78 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 382001b16e..2be9a43aaa 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2002-01-16 Havoc Pennington + + * 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 * gtk/gtkfilesel.c (gtk_file_selection_map): Refresh diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 6578876b3d..e862ac9d03 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -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? */ + + 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); + + newval = adj->value; + oldval = adj->value; - gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos); + newval += count * adj->page_increment; - newval = adj->value; + set_adjustment_clamped (adj, newval); + cursor_y_pos += adj->value - oldval; - newval += count * adj->page_increment; - - cursor_y_pos += newval - adj->value; - set_adjustment_clamped (adj, newval); - - 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); + 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. */