summaryrefslogtreecommitdiff
path: root/gtk/gtktextdisplay.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-02-20 23:29:49 +0100
committerBenjamin Otte <otte@redhat.com>2011-02-20 23:43:42 +0100
commitc647085e76c4986a97856b539773510e06c348c4 (patch)
treec3dd4421ee8c8770e56b76a735a530ffcd5aaefd /gtk/gtktextdisplay.c
parent608c1e40eb776f57c58350cbe55f239599391006 (diff)
downloadgtk+-c647085e76c4986a97856b539773510e06c348c4.tar.gz
textview: Translate the cairo context instead of keeping y value
This avoids overflow when transforming a large value to a pango unit. To reproduce the problem: seq 200000 > test.txt && tets/print-editor test.txt Then scroll to around line 140.000 to see it (depends on font size of course).
Diffstat (limited to 'gtk/gtktextdisplay.c')
-rw-r--r--gtk/gtktextdisplay.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 383f52d1a9..e217f8ad9c 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -847,7 +847,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
cairo_t *cr,
GList **widgets)
{
- gint current_y;
+ gint offset_y;
GSList *cursor_list;
GtkTextRenderer *text_renderer;
GtkTextIter selection_start, selection_end;
@@ -865,7 +865,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
if (!gdk_cairo_get_clip_rectangle (cr, &clip))
return;
- line_list = gtk_text_layout_get_lines (layout, clip.y, clip.y + clip.height, &current_y);
+ line_list = gtk_text_layout_get_lines (layout, clip.y, clip.y + clip.height, &offset_y);
if (line_list == NULL)
return; /* nothing on the screen */
@@ -873,6 +873,9 @@ gtk_text_layout_draw (GtkTextLayout *layout,
text_renderer = get_text_renderer ();
text_renderer_begin (text_renderer, widget, cr);
+ /* text_renderer_begin/end does cairo_save/restore */
+ cairo_translate (cr, 0, offset_y);
+
gtk_text_layout_wrap_loop_start (layout);
if (gtk_text_buffer_get_selection_bounds (layout->buffer,
@@ -926,7 +929,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
}
render_para (text_renderer, line_display,
- 0, current_y,
+ 0, 0,
selection_start_index, selection_end_index);
/* We paint the cursors last, because they overlap another chunk
@@ -962,7 +965,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
}
cursor_location.x = line_display->x_offset + cursor->x;
- cursor_location.y = current_y + line_display->top_margin + cursor->y;
+ cursor_location.y = line_display->top_margin + cursor->y;
cursor_location.width = 0;
cursor_location.height = cursor->height;
@@ -974,7 +977,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
}
} /* line_display->height > 0 */
- current_y += line_display->height;
+ cairo_translate (cr, 0, line_display->height);
gtk_text_layout_free_line_display (layout, line_display);
tmp_list = g_slist_next (tmp_list);