summaryrefslogtreecommitdiff
path: root/gtk/gtktextdisplay.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-11-30 21:33:36 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-11-30 21:33:36 +0000
commit126efafc406d5945663b5bd86c7833796e12e349 (patch)
tree0279486a55ab6814906f6dd602d251565b50bcc9 /gtk/gtktextdisplay.c
parent1b45c64014d37e89fcaa2600cbda266f4d8cb5ca (diff)
downloadgtk+-126efafc406d5945663b5bd86c7833796e12e349.tar.gz
Don't paint in the trailing end of a wrapped line when the selection
Tue Nov 30 16:25:29 2004 Owen Taylor <otaylor@redhat.com> * gtk/gtktextdisplay.c (render_para): Don't paint in the trailing end of a wrapped line when the selection starts after the line. (#159984, Matthias Clasen) * gtk/gtktextdisplay.c (gtk_text_layout_draw): pass in byte_count + 1 for selection_end index when the selection end is past the end of the line so that render_para() can distinguish it from selection-end *at* the end of the line. Fixes newlines not being selected.
Diffstat (limited to 'gtk/gtktextdisplay.c')
-rw-r--r--gtk/gtktextdisplay.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 4b621b4315..2a3e4853a0 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -538,8 +538,13 @@ render_para (GtkTextRenderer *text_renderer,
PANGO_SCALE * x + line_rect.x,
PANGO_SCALE * y + baseline);
- if (selection_start_index <= byte_offset + line->length &&
- selection_end_index > byte_offset) /* Some selected */
+ /* Check if some part of the line is selected; the newline
+ * that is after line->length for the last line of the
+ * paragraph counts as part of the line for this
+ */
+ if ((selection_start_index < byte_offset + line->length ||
+ (selection_start_index == byte_offset + line->length && pango_layout_iter_at_last_line (iter))) &&
+ selection_end_index > byte_offset)
{
GdkRegion *clip_region = get_selected_clip (text_renderer, layout, line,
x + line_display->x_offset,
@@ -754,7 +759,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
if (gtk_text_iter_compare (&selection_end, &line_end) <= 0)
selection_end_index = gtk_text_iter_get_visible_line_index (&selection_end);
else
- selection_end_index = MAX(byte_count, 1);
+ selection_end_index = byte_count + 1; /* + 1 to flag past-the-end */
}
}