GtkTextViewAccessible: Respect display lines

This special tweak was lost when porting from GailTextUtil.

https://bugzilla.gnome.org/show_bug.cgi?id=663994
This commit is contained in:
Matthias Clasen 2011-11-15 00:21:56 -05:00
parent 76cd14410c
commit 4904a2f45b

View File

@ -173,6 +173,7 @@ gtk_text_view_accessible_get_text_after_offset (AtkText *text,
gint *end_offset) gint *end_offset)
{ {
GtkWidget *widget; GtkWidget *widget;
GtkTextView *view;
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
GtkTextIter pos; GtkTextIter pos;
GtkTextIter start, end; GtkTextIter start, end;
@ -181,12 +182,29 @@ gtk_text_view_accessible_get_text_after_offset (AtkText *text,
if (widget == NULL) if (widget == NULL)
return NULL; return NULL;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); view = GTK_TEXT_VIEW (widget);
buffer = gtk_text_view_get_buffer (view);
gtk_text_buffer_get_iter_at_offset (buffer, &pos, offset); gtk_text_buffer_get_iter_at_offset (buffer, &pos, offset);
_gtk_text_buffer_get_text_after (buffer, boundary_type, start = end = pos;
&pos, &start, &end); if (boundary_type == ATK_TEXT_BOUNDARY_LINE_START)
{
gtk_text_view_forward_display_line (view, &end);
start = end;
gtk_text_view_forward_display_line (view, &end);
}
else if (boundary_type == ATK_TEXT_BOUNDARY_LINE_END)
{
gtk_text_view_forward_display_line_end (view, &end);
start = end;
gtk_text_view_forward_display_line (view, &end);
gtk_text_view_forward_display_line_end (view, &end);
}
else
_gtk_text_buffer_get_text_after (buffer, boundary_type, &pos, &start, &end);
*start_offset = gtk_text_iter_get_offset (&start); *start_offset = gtk_text_iter_get_offset (&start);
*end_offset = gtk_text_iter_get_offset (&end); *end_offset = gtk_text_iter_get_offset (&end);
return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE); return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE);
} }
@ -198,6 +216,7 @@ gtk_text_view_accessible_get_text_at_offset (AtkText *text,
gint *end_offset) gint *end_offset)
{ {
GtkWidget *widget; GtkWidget *widget;
GtkTextView *view;
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
GtkTextIter pos; GtkTextIter pos;
GtkTextIter start, end; GtkTextIter start, end;
@ -206,12 +225,31 @@ gtk_text_view_accessible_get_text_at_offset (AtkText *text,
if (widget == NULL) if (widget == NULL)
return NULL; return NULL;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); view = GTK_TEXT_VIEW (widget);
buffer = gtk_text_view_get_buffer (view);
gtk_text_buffer_get_iter_at_offset (buffer, &pos, offset); gtk_text_buffer_get_iter_at_offset (buffer, &pos, offset);
_gtk_text_buffer_get_text_at (buffer, boundary_type, start = end = pos;
&pos, &start, &end); if (boundary_type == ATK_TEXT_BOUNDARY_LINE_START)
{
gtk_text_view_backward_display_line_start (view, &start);
gtk_text_view_forward_display_line (view, &end);
}
else if (boundary_type == ATK_TEXT_BOUNDARY_LINE_END)
{
gtk_text_view_backward_display_line_start (view, &start);
if (!gtk_text_iter_is_start (&start))
{
gtk_text_view_backward_display_line (view, &start);
gtk_text_view_forward_display_line_end (view, &start);
}
gtk_text_view_forward_display_line_end (view, &end);
}
else
_gtk_text_buffer_get_text_at (buffer, boundary_type, &pos, &start, &end);
*start_offset = gtk_text_iter_get_offset (&start); *start_offset = gtk_text_iter_get_offset (&start);
*end_offset = gtk_text_iter_get_offset (&end); *end_offset = gtk_text_iter_get_offset (&end);
return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE); return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE);
} }
@ -223,6 +261,7 @@ gtk_text_view_accessible_get_text_before_offset (AtkText *text,
gint *end_offset) gint *end_offset)
{ {
GtkWidget *widget; GtkWidget *widget;
GtkTextView *view;
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
GtkTextIter pos; GtkTextIter pos;
GtkTextIter start, end; GtkTextIter start, end;
@ -231,12 +270,40 @@ gtk_text_view_accessible_get_text_before_offset (AtkText *text,
if (widget == NULL) if (widget == NULL)
return NULL; return NULL;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); view = GTK_TEXT_VIEW (widget);
buffer = gtk_text_view_get_buffer (view);
gtk_text_buffer_get_iter_at_offset (buffer, &pos, offset); gtk_text_buffer_get_iter_at_offset (buffer, &pos, offset);
_gtk_text_buffer_get_text_before (buffer, boundary_type, start = end = pos;
&pos, &start, &end);
if (boundary_type == ATK_TEXT_BOUNDARY_LINE_START)
{
gtk_text_view_backward_display_line_start (view, &start);
end = start;
gtk_text_view_backward_display_line (view, &start);
}
else if (boundary_type == ATK_TEXT_BOUNDARY_LINE_END)
{
gtk_text_view_backward_display_line_start (view, &start);
if (!gtk_text_iter_is_start (&start))
{
gtk_text_view_backward_display_line (view, &start);
end = start;
if (!gtk_text_iter_is_start (&start))
{
gtk_text_view_backward_display_line (view, &start);
gtk_text_view_forward_display_line_end (view, &start);
}
gtk_text_view_forward_display_line_end (view, &end);
}
else
end = start;
}
else
_gtk_text_buffer_get_text_before (buffer, boundary_type, &pos, &start, &end);
*start_offset = gtk_text_iter_get_offset (&start); *start_offset = gtk_text_iter_get_offset (&start);
*end_offset = gtk_text_iter_get_offset (&end); *end_offset = gtk_text_iter_get_offset (&end);
return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE); return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE);
} }