[gtk+] GtkTextViewAccessible: Respect display lines
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkTextViewAccessible: Respect display lines
- Date: Tue, 15 Nov 2011 05:25:43 +0000 (UTC)
commit 4904a2f45b12e364a44f661a71ff7adb8878e07a
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 15 00:21:56 2011 -0500
GtkTextViewAccessible: Respect display lines
This special tweak was lost when porting from GailTextUtil.
https://bugzilla.gnome.org/show_bug.cgi?id=663994
gtk/a11y/gtktextviewaccessible.c | 85 ++++++++++++++++++++++++++++++++++----
1 files changed, 76 insertions(+), 9 deletions(-)
---
diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c
index 439e286..b620c9c 100644
--- a/gtk/a11y/gtktextviewaccessible.c
+++ b/gtk/a11y/gtktextviewaccessible.c
@@ -173,6 +173,7 @@ gtk_text_view_accessible_get_text_after_offset (AtkText *text,
gint *end_offset)
{
GtkWidget *widget;
+ GtkTextView *view;
GtkTextBuffer *buffer;
GtkTextIter pos;
GtkTextIter start, end;
@@ -181,12 +182,29 @@ gtk_text_view_accessible_get_text_after_offset (AtkText *text,
if (widget == 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_text_after (buffer, boundary_type,
- &pos, &start, &end);
+ start = end = pos;
+ 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);
*end_offset = gtk_text_iter_get_offset (&end);
+
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)
{
GtkWidget *widget;
+ GtkTextView *view;
GtkTextBuffer *buffer;
GtkTextIter pos;
GtkTextIter start, end;
@@ -206,12 +225,31 @@ gtk_text_view_accessible_get_text_at_offset (AtkText *text,
if (widget == 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_text_at (buffer, boundary_type,
- &pos, &start, &end);
+ start = end = pos;
+ 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);
*end_offset = gtk_text_iter_get_offset (&end);
+
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)
{
GtkWidget *widget;
+ GtkTextView *view;
GtkTextBuffer *buffer;
GtkTextIter pos;
GtkTextIter start, end;
@@ -231,12 +270,40 @@ gtk_text_view_accessible_get_text_before_offset (AtkText *text,
if (widget == 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_text_before (buffer, boundary_type,
- &pos, &start, &end);
+ start = end = pos;
+
+ 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);
*end_offset = gtk_text_iter_get_offset (&end);
+
return gtk_text_buffer_get_slice (buffer, &start, &end, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]